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
9c66302c
Commit
9c66302c
authored
Jun 17, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Error responses weren't being shown for corrections
parent
19f6bce2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
24 deletions
+36
-24
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+34
-21
src/headless/converse-muc.js
src/headless/converse-muc.js
+2
-3
No files found.
src/headless/converse-chatboxes.js
View file @
9c66302c
...
...
@@ -417,7 +417,28 @@ converse.plugins.add('converse-chatboxes', {
}
},
shouldShowErrorMessage
()
{
/**
* @private
* @method _converse.ChatBox#shouldShowErrorMessage
* @returns {boolean}
*/
shouldShowErrorMessage
(
stanza
)
{
const
id
=
stanza
.
getAttribute
(
'
id
'
);
if
(
id
)
{
const
msgs
=
this
.
messages
.
where
({
'
msgid
'
:
id
});
const
referenced_msgs
=
msgs
.
filter
(
m
=>
m
.
get
(
'
type
'
)
!==
'
error
'
);
if
(
!
referenced_msgs
.
length
&&
stanza
.
querySelector
(
'
body
'
)
===
null
)
{
// If the error refers to a message not included in our store,
// and it doesn't have a <body> tag, we assume that this was a
// CSI message (which we don't store).
// See https://github.com/conversejs/converse.js/issues/1317
return
;
}
const
dupes
=
msgs
.
filter
(
m
=>
m
.
get
(
'
type
'
)
===
'
error
'
);
if
(
dupes
.
length
)
{
return
;
}
}
// Gets overridden in ChatRoom
return
true
;
},
...
...
@@ -988,34 +1009,26 @@ converse.plugins.add('converse-chatboxes', {
});
},
async
onErrorMessage
(
message
)
{
/* Handler method for all incoming error message stanzas
*/
const
from_jid
=
Strophe
.
getBareJidFromJid
(
message
.
getAttribute
(
'
from
'
));
/**
* Handler method for all incoming error stanza stanzas.
* @private
* @method _converse.ChatBox#onErrorMessage
* @param { XMLElement } stanza - The error message stanza
*/
async
onErrorMessage
(
stanza
)
{
const
from_jid
=
Strophe
.
getBareJidFromJid
(
stanza
.
getAttribute
(
'
from
'
));
if
(
utils
.
isSameBareJID
(
from_jid
,
_converse
.
bare_jid
))
{
return
true
;
return
;
}
const
chatbox
=
this
.
getChatBox
(
from_jid
);
if
(
!
chatbox
)
{
return
true
;
}
const
id
=
message
.
getAttribute
(
'
id
'
);
if
(
id
)
{
const
msgs
=
chatbox
.
messages
.
where
({
'
msgid
'
:
id
});
if
(
!
msgs
.
length
||
msgs
.
filter
(
m
=>
m
.
get
(
'
type
'
)
===
'
error
'
).
length
)
{
// If the error refers to a message not included in our store.
// We assume that this was a CSI message (which we don't store).
// See https://github.com/conversejs/converse.js/issues/1317
//
// We also ignore duplicate error messages.
return
;
}
return
;
}
const
should_show
=
await
chatbox
.
shouldShowErrorMessage
(
message
);
const
should_show
=
await
chatbox
.
shouldShowErrorMessage
(
stanza
);
if
(
!
should_show
)
{
return
;
}
const
attrs
=
await
chatbox
.
getMessageAttributesFromStanza
(
message
,
message
);
const
attrs
=
await
chatbox
.
getMessageAttributesFromStanza
(
stanza
,
stanza
);
chatbox
.
messages
.
create
(
attrs
);
},
...
...
src/headless/converse-muc.js
View file @
9c66302c
...
...
@@ -1337,7 +1337,6 @@ converse.plugins.add('converse-muc', {
},
/**
* @async
* @private
* @method _converse.ChatRoom#shouldShowErrorMessage
* @returns {Promise<boolean>}
...
...
@@ -1348,7 +1347,7 @@ converse.plugins.add('converse-muc', {
return
false
;
}
}
return
true
;
return
_converse
.
ChatBox
.
prototype
.
shouldShowErrorMessage
.
call
(
this
,
stanza
)
;
},
getErrorMessage
(
stanza
)
{
...
...
@@ -1357,7 +1356,7 @@ converse.plugins.add('converse-muc', {
}
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.
"
);
}
else
{
return
_converse
.
ChatBox
.
prototype
.
getErrorMessage
.
apply
(
this
,
arguments
);
return
_converse
.
ChatBox
.
prototype
.
getErrorMessage
.
call
(
this
,
stanza
);
}
},
...
...
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