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
58c5e967
Commit
58c5e967
authored
Jan 08, 2021
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle forwarded mentions coming from the MUC, not the host
parent
5e6a6ba6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
9 deletions
+21
-9
spec/autocomplete.js
spec/autocomplete.js
+3
-0
spec/muc-mentions.js
spec/muc-mentions.js
+3
-3
spec/muc_messages.js
spec/muc_messages.js
+1
-0
spec/retractions.js
spec/retractions.js
+1
-1
src/headless/plugins/muc/muc.js
src/headless/plugins/muc/muc.js
+13
-5
No files found.
spec/autocomplete.js
View file @
58c5e967
...
...
@@ -38,6 +38,7 @@ describe("The nickname autocomplete feature", function () {
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
Hello world
'
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
last
()?.
get
(
'
received
'
));
// Test that pressing @ brings up all options
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
...
@@ -91,6 +92,7 @@ describe("The nickname autocomplete feature", function () {
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
Hello world
'
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
last
()?.
get
(
'
received
'
));
// Test that pressing @ brings up all options
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
...
@@ -145,6 +147,7 @@ describe("The nickname autocomplete feature", function () {
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
Hello world
'
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
last
()?.
get
(
'
received
'
));
// Test that pressing @ brings up all options
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
...
...
spec/muc-mentions.js
View file @
58c5e967
/*global mock, converse */
const
{
Strophe
,
dayjs
}
=
converse
.
env
;
const
{
dayjs
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
// See: https://xmpp.org/rfcs/rfc3921.html
...
...
@@ -37,7 +37,7 @@ describe("MUC Mention Notfications", function () {
const
base_time
=
new
Date
();
let
message
=
u
.
toStanza
(
`
<message from="
${
Strophe
.
getDomainFromJid
(
muc_jid
)
}
">
<message from="
${
muc_jid
}
">
<mentions xmlns='urn:xmpp:mmn:0'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='
${
dayjs
(
base_time
).
subtract
(
5
,
'
minutes
'
).
toISOString
()}
'/>
...
...
@@ -61,7 +61,7 @@ describe("MUC Mention Notfications", function () {
expect
(
room_el
.
querySelector
(
'
.msgs-indicator
'
)?.
textContent
.
trim
()).
toBe
(
'
1
'
);
message
=
u
.
toStanza
(
`
<message from="
${
Strophe
.
getDomainFromJid
(
muc_jid
)
}
">
<message from="
${
muc_jid
}
">
<mentions xmlns='urn:xmpp:mmn:0'>
<forwarded xmlns='urn:xmpp:forward:0'>
<delay xmlns='urn:xmpp:delay' stamp='
${
dayjs
(
base_time
).
subtract
(
4
,
'
minutes
'
).
toISOString
()}
'/>
...
...
spec/muc_messages.js
View file @
58c5e967
...
...
@@ -519,6 +519,7 @@ describe("A Groupchat Message", function () {
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
'
I wrote this message!
'
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
last
()?.
get
(
'
received
'
));
expect
(
view
.
model
.
messages
.
last
().
get
(
'
sender
'
)).
toBe
(
'
me
'
);
done
();
}));
...
...
spec/retractions.js
View file @
58c5e967
...
...
@@ -791,7 +791,7 @@ describe("Message Retractions", function () {
</message>`
);
await
view
.
model
.
handleMessageStanza
(
retraction
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderated
'
)).
toBe
(
'
retracted
'
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderated
'
)
===
'
retracted
'
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderation_reason
'
)).
toBe
(
reason
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
is_ephemeral
'
)).
toBe
(
false
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
(
false
);
...
...
src/headless/plugins/muc/muc.js
View file @
58c5e967
...
...
@@ -440,12 +440,9 @@ const ChatRoomMixin = {
handleMessageFromMUCHost
(
stanza
)
{
const
conn_status
=
this
.
session
.
get
(
'
connection_status
'
);
if
(
conn_status
===
converse
.
ROOMSTATUS
.
ENTERED
)
{
// We're not interested in activity indicators or forwarded
// mentions when already joined to the room.
// Also prevents forwarded mentions from being counted twice.
// We're not interested in activity indicators when already joined to the room
return
;
}
const
rai
=
sizzle
(
`rai[xmlns="
${
Strophe
.
NS
.
RAI
}
"]`
,
stanza
).
pop
();
const
active_mucs
=
Array
.
from
(
rai
?.
querySelectorAll
(
'
activity
'
)
||
[]).
map
(
m
=>
m
.
textContent
);
if
(
active_mucs
.
includes
(
this
.
get
(
'
jid
'
)))
{
...
...
@@ -454,7 +451,13 @@ const ChatRoomMixin = {
'
num_unread_general
'
:
0
// Either/or between activity and unreads
});
}
},
handleForwardedMentions
(
stanza
)
{
if
(
this
.
session
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
ENTERED
)
{
// Avoid counting mentions twice
return
;
}
const
msgs
=
sizzle
(
`mentions[xmlns="
${
Strophe
.
NS
.
MENTIONS
}
"] forwarded[xmlns="
${
Strophe
.
NS
.
FORWARD
}
"] message[type="groupchat"]`
,
stanza
...
...
@@ -481,6 +484,11 @@ const ChatRoomMixin = {
* @param { XMLElement } stanza
*/
async
handleMessageStanza
(
stanza
)
{
if
(
stanza
.
getAttribute
(
'
type
'
)
!==
'
groupchat
'
)
{
this
.
handleForwardedMentions
(
stanza
);
return
;
}
if
(
isArchived
(
stanza
))
{
// MAM messages are handled in converse-mam.
// We shouldn't get MAM messages here because
...
...
@@ -542,7 +550,7 @@ const ChatRoomMixin = {
stanza
=>
!!
this
.
handleMessageStanza
(
stanza
)
||
true
,
null
,
'
message
'
,
'
groupchat
'
,
null
,
null
,
muc_jid
,
{
'
matchBareFromJid
'
:
true
}
...
...
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