Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
161cbec0
Commit
161cbec0
authored
Jan 17, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For `forbidden` errors, show error message from server
parent
b2a4ff7a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
spec/muc.js
spec/muc.js
+19
-3
src/headless/utils/stanza.js
src/headless/utils/stanza.js
+6
-2
No files found.
spec/muc.js
View file @
161cbec0
...
...
@@ -5316,16 +5316,32 @@
view
.
onFormSubmitted
(
new
Event
(
'
submit
'
));
await
new
Promise
(
resolve
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
cons
t
stanza
=
u
.
toStanza
(
`
le
t
stanza
=
u
.
toStanza
(
`
<message xmlns="jabber:client" type="error" to="troll@montague.lit/resource" from="trollbox@montague.lit">
<error type="auth"><forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
(
resolve
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelector
(
'
.chat-error
'
).
textContent
.
trim
()).
toBe
(
"
Your message was not delivered because you weren't allowed to send it.
"
);
textarea
.
value
=
'
Hello again
'
;
view
.
onFormSubmitted
(
new
Event
(
'
submit
'
));
await
new
Promise
(
resolve
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelector
(
'
.chat-error
'
).
textContent
.
trim
()).
toBe
(
"
Your message was not delivered because you're not allowed to send messages in this groupchat.
"
);
stanza
=
u
.
toStanza
(
`
<message xmlns="jabber:client" type="error" to="troll@montague.lit/resource" from="trollbox@montague.lit">
<error type="auth">
<forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Thou shalt not!</text>
</error>
</message>`
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
new
Promise
(
resolve
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
view
.
el
.
querySelector
(
'
.message:last-child
'
).
textContent
.
trim
()).
toBe
(
'
Your message was not delivered because you weren
\'
t allowed to send it.
'
+
'
The message from the server is: "Thou shalt not!"
'
)
done
();
}));
...
...
src/headless/utils/stanza.js
View file @
161cbec0
...
...
@@ -234,8 +234,12 @@ const stanza_utils = {
getErrorMessage
(
stanza
,
is_muc
,
_converse
)
{
const
{
__
}
=
_converse
;
if
(
is_muc
)
{
if
(
sizzle
(
`forbidden[xmlns="
${
Strophe
.
NS
.
STANZAS
}
"]`
,
stanza
).
length
)
{
return
__
(
"
Your message was not delivered because you're not allowed to send messages in this groupchat.
"
);
const
forbidden
=
sizzle
(
`error forbidden[xmlns="
${
Strophe
.
NS
.
STANZAS
}
"]`
,
stanza
).
pop
();
if
(
forbidden
)
{
const
msg
=
__
(
"
Your message was not delivered because you weren't allowed to send it.
"
);
const
text
=
sizzle
(
`error text[xmlns="
${
Strophe
.
NS
.
STANZAS
}
"]`
,
stanza
).
pop
();
const
server_msg
=
text
?
__
(
'
The message from the server is: "%1$s"
'
,
text
.
textContent
)
:
''
;
return
server_msg
?
`
${
msg
}
${
server_msg
}
`
:
msg
;
}
else
if
(
sizzle
(
`not-acceptable[xmlns="
${
Strophe
.
NS
.
STANZAS
}
"]`
,
stanza
).
length
)
{
return
__
(
"
Your message was not delivered because you're not present in the groupchat.
"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment