-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inform user if message couldn't be delivered because they're blocked
- Loading branch information
Showing
15 changed files
with
152 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*global mock, converse */ | ||
const { u, stx } = converse.env; | ||
|
||
fdescribe('A blocklist', function () { | ||
describe('A blocklist', function () { | ||
beforeEach(() => { | ||
jasmine.addMatchers({ toEqualStanza: jasmine.toEqualStanza }); | ||
window.sessionStorage.removeItem('[email protected]'); | ||
|
@@ -125,15 +125,18 @@ fdescribe('A blocklist', function () { | |
const IQ_stanzas = api.connection.get().IQ_stanzas; | ||
let sent_stanza = await u.waitUntil(() => IQ_stanzas.find((s) => s.querySelector('iq blocklist'))); | ||
|
||
_converse.api.connection.get()._dataRecv(mock.createRequest( | ||
stx`<iq xmlns="jabber:client" | ||
_converse.api.connection.get()._dataRecv( | ||
mock.createRequest( | ||
stx`<iq xmlns="jabber:client" | ||
to="${api.connection.get().jid}" | ||
type="result" | ||
id="${sent_stanza.getAttribute('id')}"> | ||
<blocklist xmlns='urn:xmpp:blocking'> | ||
<item jid='[email protected]'/> | ||
</blocklist> | ||
</iq>`)); | ||
</iq>` | ||
) | ||
); | ||
|
||
const blocklist = await api.waitUntil('blocklistInitialized'); | ||
expect(blocklist.length).toBe(1); | ||
|
@@ -148,9 +151,13 @@ fdescribe('A blocklist', function () { | |
</block> | ||
</iq>`); | ||
|
||
_converse.api.connection.get()._dataRecv(mock.createRequest( | ||
stx`<iq xmlns="jabber:client" type="result" id="${sent_stanza.getAttribute('id')}"/>`) | ||
); | ||
_converse.api.connection | ||
.get() | ||
._dataRecv( | ||
mock.createRequest( | ||
stx`<iq xmlns="jabber:client" type="result" id="${sent_stanza.getAttribute('id')}"/>` | ||
) | ||
); | ||
|
||
await u.waitUntil(() => blocklist.length === 2); | ||
expect(blocklist.models.map((m) => m.get('jid'))).toEqual(['[email protected]', '[email protected]']); | ||
|
@@ -165,12 +172,45 @@ fdescribe('A blocklist', function () { | |
</unblock> | ||
</iq>`); | ||
|
||
_converse.api.connection.get()._dataRecv(mock.createRequest( | ||
stx`<iq xmlns="jabber:client" type="result" id="${sent_stanza.getAttribute('id')}"/>`) | ||
); | ||
_converse.api.connection | ||
.get() | ||
._dataRecv( | ||
mock.createRequest( | ||
stx`<iq xmlns="jabber:client" type="result" id="${sent_stanza.getAttribute('id')}"/>` | ||
) | ||
); | ||
|
||
await u.waitUntil(() => blocklist.length === 1); | ||
expect(blocklist.models.map((m) => m.get('jid'))).toEqual(['[email protected]']); | ||
}) | ||
); | ||
}); | ||
|
||
describe('A Chat Message', function () { | ||
fit( | ||
"will show an error message if it's rejected due to being banned", | ||
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) { | ||
const { api } = _converse; | ||
await mock.waitForRoster(_converse, 'current', 1); | ||
const sender_jid = mock.cur_names[0].replace(/ /g, '.').toLowerCase() + '@montague.lit'; | ||
const chat = await api.chats.open(sender_jid); | ||
const msg_text = 'This message will not be sent, due to an error'; | ||
const message = await chat.sendMessage({ body: msg_text }); | ||
|
||
api.connection.get()._dataRecv(mock.createRequest(stx` | ||
<message xmlns="jabber:client" | ||
to="${api.connection.get().jid}" | ||
type="error" | ||
id="${message.get('msgid')}" | ||
from="${sender_jid}"> | ||
<error type="cancel"> | ||
<not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> | ||
<blocked xmlns='urn:xmpp:blocking:errors'/> | ||
</error> | ||
</message>`)); | ||
|
||
await u.waitUntil(() => message.get('is_error') === true); | ||
expect(message.get('error')).toBe('You are blocked from sending messages.'); | ||
}) | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,7 @@ | |
|
||
.chat-msg__error { | ||
color: var(--error-color); | ||
white-space: pre-wrap; | ||
} | ||
|
||
.chat-msg__media { | ||
|