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
ce08819a
Commit
ce08819a
authored
Feb 18, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Retracted moderated sent message should not be editable.
parent
ead8cdbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
2 deletions
+59
-2
spec/retractions.js
spec/retractions.js
+57
-0
src/headless/utils/stanza.js
src/headless/utils/stanza.js
+2
-2
No files found.
spec/retractions.js
View file @
ce08819a
...
...
@@ -358,6 +358,7 @@
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg--retracted
'
).
length
===
1
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
retracted
'
)).
toBeTruthy
();
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
(
false
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--retracted
'
).
length
).
toBe
(
1
);
const
msg_el
=
view
.
el
.
querySelector
(
'
.chat-msg--retracted .chat-msg__message
'
);
expect
(
msg_el
.
textContent
.
trim
()).
toBe
(
'
eve has removed this message
'
);
...
...
@@ -448,6 +449,7 @@
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderated
'
)).
toBe
(
'
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
);
done
();
}));
...
...
@@ -497,6 +499,7 @@
`
);
await
view
.
model
.
onMessage
(
received_stanza
);
await
u
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
===
1
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
const
retract_button
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__content .chat-msg__action-retract
'
));
retract_button
.
click
();
...
...
@@ -539,6 +542,7 @@
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderated
'
)).
toBe
(
'
retracted
'
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderated_by
'
)).
toBe
(
_converse
.
bare_jid
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderation_reason
'
)).
toBe
(
reason
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
(
false
);
done
();
}));
});
...
...
@@ -685,6 +689,59 @@
expect
(
error_messages
[
1
].
textContent
).
toBe
(
"
Timeout Error: No response from server
"
);
done
();
}));
it
(
"
can be retracted by a moderator
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
lounge@montague.lit
'
;
const
features
=
[...
mock
.
default_muc_features
,
Strophe
.
NS
.
MODERATE
];
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
muc_jid
,
'
romeo
'
,
features
);
const
view
=
_converse
.
api
.
chatviews
.
get
(
muc_jid
);
const
occupant
=
view
.
model
.
getOwnOccupant
();
expect
(
occupant
.
get
(
'
role
'
)).
toBe
(
'
moderator
'
);
view
.
model
.
sendMessage
(
'
Visit this site to get free bitcoin
'
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
===
1
);
const
stanza_id
=
'
retraction-id-1
'
;
const
msg_obj
=
view
.
model
.
messages
.
at
(
0
);
const
reflection_stanza
=
u
.
toStanza
(
`
<message xmlns="jabber:client"
from="
${
msg_obj
.
get
(
'
from
'
)}
"
to="
${
_converse
.
connection
.
jid
}
"
type="groupchat">
<msg_body>
${
msg_obj
.
get
(
'
message
'
)}
</msg_body>
<stanza-id xmlns="urn:xmpp:sid:0"
id="
${
stanza_id
}
"
by="lounge@montague.lit"/>
<origin-id xmlns="urn:xmpp:sid:0" id="
${
msg_obj
.
get
(
'
origin_id
'
)}
"/>
</message>`
);
await
view
.
model
.
onMessage
(
reflection_stanza
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg__body.chat-msg__body--received
'
).
length
,
500
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
editable
'
)).
toBe
(
true
);
// The server responds with a retraction message
const
reason
=
"
This content is inappropriate for this forum!
"
const
retraction
=
u
.
toStanza
(
`
<message type="groupchat" id='retraction-id-1' from="
${
muc_jid
}
" to="
${
muc_jid
}
/romeo">
<apply-to id="
${
stanza_id
}
" xmlns="urn:xmpp:fasten:0">
<moderated by='
${
_converse
.
bare_jid
}
' xmlns='urn:xmpp:message-moderate:0'>
<retract xmlns='urn:xmpp:message-retract:0' />
<reason>
${
reason
}
</reason>
</moderated>
</apply-to>
</message>`
);
await
view
.
model
.
onMessage
(
retraction
);
expect
(
view
.
model
.
messages
.
length
).
toBe
(
1
);
expect
(
view
.
model
.
messages
.
at
(
0
).
get
(
'
moderated
'
)).
toBe
(
'
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
);
done
();
}));
});
...
...
src/headless/utils/stanza.js
View file @
ce08819a
...
...
@@ -91,7 +91,7 @@ const stanza_utils = {
return
{};
}
return
{
'
ed
ti
able
'
:
false
,
'
ed
it
able
'
:
false
,
'
moderated
'
:
'
retracted
'
,
'
moderated_by
'
:
moderated
.
getAttribute
(
'
by
'
),
'
moderated_id
'
:
applies_to_id
,
...
...
@@ -105,7 +105,7 @@ const stanza_utils = {
const
retracted
=
sizzle
(
`retracted[xmlns="
${
Strophe
.
NS
.
RETRACT
}
"]`
,
tombstone
).
pop
();
if
(
retracted
)
{
return
{
'
ed
ti
able
'
:
false
,
'
ed
it
able
'
:
false
,
'
is_tombstone
'
:
true
,
'
moderated_by
'
:
tombstone
.
getAttribute
(
'
by
'
),
'
retracted
'
:
tombstone
.
getAttribute
(
'
stamp
'
),
...
...
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