Commit e23c7ce5 authored by JC Brand's avatar JC Brand

More retraction updates

- Retracted moderated message are not editable
- Use "removed" for user-facing text
parent 13ffe5a6
{ {
"name": "converse.js", "name": "converse.js",
"version": "5.0.4", "version": "6.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
...@@ -17407,13 +17407,13 @@ ...@@ -17407,13 +17407,13 @@
"dev": true "dev": true
}, },
"twemoji": { "twemoji": {
"version": "12.1.3", "version": "12.1.4",
"resolved": "https://registry.npmjs.org/twemoji/-/twemoji-12.1.3.tgz", "resolved": "https://registry.npmjs.org/twemoji/-/twemoji-12.1.4.tgz",
"integrity": "sha512-Y5mC7vVovHZvCzdXDepJaU6FHPd7PaW6ZTBMWy9sGYafLBn1x0h2T6aGA3cpnz3WgWWg2QI+3D+9Rn4Z/ViitQ==", "integrity": "sha512-e37lUlVijmABF7wPCc09s1kKj3hcpzU8KL5zw2bBDIXOtOr4luLF+ODJaEqca8dZPmLR5ezrJYI93nhPovKBiQ==",
"requires": { "requires": {
"fs-extra": "^8.0.1", "fs-extra": "^8.0.1",
"jsonfile": "^5.0.0", "jsonfile": "^5.0.0",
"twemoji-parser": "12.1.0", "twemoji-parser": "12.1.1",
"universalify": "^0.1.2" "universalify": "^0.1.2"
}, },
"dependencies": { "dependencies": {
...@@ -17429,9 +17429,9 @@ ...@@ -17429,9 +17429,9 @@
} }
}, },
"twemoji-parser": { "twemoji-parser": {
"version": "12.1.0", "version": "12.1.1",
"resolved": "https://registry.npmjs.org/twemoji-parser/-/twemoji-parser-12.1.0.tgz", "resolved": "https://registry.npmjs.org/twemoji-parser/-/twemoji-parser-12.1.1.tgz",
"integrity": "sha512-jaHYltumP/E8nR+YzRrY753j9dEpL3zH8+pDXgf9h/10wHeW/9IIjs6mZ1Z/Syh8rIaOQObev1BAX/AinFmuOg==" "integrity": "sha512-XFUB4ReEvPbNPtiuyo/+crM4RldYbRRAhyE7Hw6EnfBdXECGydw7a49EGADayRvaeierP/m4DSv/OZQObh0LGA=="
}, },
"type-check": { "type-check": {
"version": "0.3.2", "version": "0.3.2",
......
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
expect(message.get('retracted')).toBeTruthy(); expect(message.get('retracted')).toBeTruthy();
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message'); const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message');
expect(msg_el.textContent.trim()).toBe('Mercutio has retracted this message'); expect(msg_el.textContent.trim()).toBe('Mercutio has removed this message');
expect(u.hasClass('chat-msg--followup', view.el.querySelector('.chat-msg--retracted'))).toBe(true); expect(u.hasClass('chat-msg--followup', view.el.querySelector('.chat-msg--retracted'))).toBe(true);
done(); done();
})); }));
...@@ -309,7 +309,7 @@ ...@@ -309,7 +309,7 @@
expect(message.get('retracted')).toBeTruthy(); expect(message.get('retracted')).toBeTruthy();
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message');
expect(el.textContent.trim()).toBe('Romeo Montague has retracted this message'); expect(el.textContent.trim()).toBe('Romeo Montague has removed this message');
done(); done();
})); }));
}); });
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
expect(view.model.messages.at(0).get('retracted')).toBeTruthy(); expect(view.model.messages.at(0).get('retracted')).toBeTruthy();
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message'); const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message');
expect(msg_el.textContent.trim()).toBe('eve has retracted this message'); expect(msg_el.textContent.trim()).toBe('eve has removed this message');
expect(msg_el.querySelector('.chat-msg--retracted q')).toBe(null); expect(msg_el.querySelector('.chat-msg--retracted q')).toBe(null);
done(); done();
})); }));
...@@ -421,7 +421,7 @@ ...@@ -421,7 +421,7 @@
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message'); const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message');
expect(msg_el.firstElementChild.textContent.trim()).toBe('romeo has retracted this message from mallory'); expect(msg_el.firstElementChild.textContent.trim()).toBe('romeo has removed this message');
const qel = msg_el.querySelector('q'); const qel = msg_el.querySelector('q');
expect(qel.textContent.trim()).toBe('This content is inappropriate for this forum!'); expect(qel.textContent.trim()).toBe('This content is inappropriate for this forum!');
...@@ -522,7 +522,7 @@ ...@@ -522,7 +522,7 @@
expect(view.model.messages.at(0).get('moderated')).toBe('retracted'); expect(view.model.messages.at(0).get('moderated')).toBe('retracted');
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const msg_el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(msg_el.textContent).toBe('romeo has retracted this message from mallory'); expect(msg_el.textContent).toBe('romeo has removed this message');
const qel = view.el.querySelector('.chat-msg--retracted .chat-msg__message q'); const qel = view.el.querySelector('.chat-msg--retracted .chat-msg__message q');
expect(qel.textContent).toBe('This content is inappropriate for this forum!'); expect(qel.textContent).toBe('This content is inappropriate for this forum!');
...@@ -587,7 +587,7 @@ ...@@ -587,7 +587,7 @@
expect(view.model.messages.at(0).get('is_ephemeral')).toBe(false); expect(view.model.messages.at(0).get('is_ephemeral')).toBe(false);
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(el.textContent).toBe('romeo has retracted this message'); expect(el.textContent).toBe('romeo has removed this message');
done(); done();
})); }));
...@@ -609,7 +609,7 @@ ...@@ -609,7 +609,7 @@
expect(view.model.messages.length).toBe(1); expect(view.model.messages.length).toBe(1);
expect(view.model.messages.at(0).get('retracted')).toBeTruthy(); expect(view.model.messages.at(0).get('retracted')).toBeTruthy();
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(el.textContent.trim()).toBe('romeo has retracted this message'); expect(el.textContent.trim()).toBe('romeo has removed this message');
const message = view.model.messages.at(0); const message = view.model.messages.at(0);
const stanza_id = message.get(`stanza_id ${view.model.get('jid')}`); const stanza_id = message.get(`stanza_id ${view.model.get('jid')}`);
...@@ -660,7 +660,7 @@ ...@@ -660,7 +660,7 @@
expect(view.model.messages.length).toBe(1); expect(view.model.messages.length).toBe(1);
expect(view.model.messages.at(0).get('retracted')).toBeTruthy(); expect(view.model.messages.at(0).get('retracted')).toBeTruthy();
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(el.textContent.trim()).toBe('romeo has retracted this message'); expect(el.textContent.trim()).toBe('romeo has removed this message');
await u.waitUntil(() => view.el.querySelectorAll('.chat-msg').length === 1); await u.waitUntil(() => view.el.querySelectorAll('.chat-msg').length === 1);
...@@ -763,7 +763,7 @@ ...@@ -763,7 +763,7 @@
expect(view.el.querySelectorAll('.chat-msg').length).toBe(2); expect(view.el.querySelectorAll('.chat-msg').length).toBe(2);
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(el.textContent.trim()).toBe('Mercutio has retracted this message'); expect(el.textContent.trim()).toBe('Mercutio has removed this message');
expect(u.hasClass('chat-msg--followup', el.parentElement)).toBe(false); expect(u.hasClass('chat-msg--followup', el.parentElement)).toBe(false);
done(); done();
})); }));
...@@ -841,7 +841,7 @@ ...@@ -841,7 +841,7 @@
expect(view.el.querySelectorAll('.chat-msg').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg').length).toBe(1);
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(el.textContent.trim()).toBe('eve has retracted this message'); expect(el.textContent.trim()).toBe('eve has removed this message');
done(); done();
})); }));
...@@ -926,7 +926,7 @@ ...@@ -926,7 +926,7 @@
expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1); expect(view.el.querySelectorAll('.chat-msg--retracted').length).toBe(1);
const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div'); const el = view.el.querySelector('.chat-msg--retracted .chat-msg__message div');
expect(el.textContent.trim()).toBe('A moderator has retracted this message from eve'); expect(el.textContent.trim()).toBe('A moderator has removed this message');
const qel = view.el.querySelector('.chat-msg--retracted .chat-msg__message q'); const qel = view.el.querySelector('.chat-msg--retracted .chat-msg__message q');
expect(qel.textContent.trim()).toBe('This message contains inappropriate content'); expect(qel.textContent.trim()).toBe('This message contains inappropriate content');
done(); done();
......
...@@ -315,9 +315,9 @@ converse.plugins.add('converse-message-view', { ...@@ -315,9 +315,9 @@ converse.plugins.add('converse-message-view', {
chatbox.occupants.findOccupant({'nick': Strophe.getResourceFromJid(retracted_by_mod)}); chatbox.occupants.findOccupant({'nick': Strophe.getResourceFromJid(retracted_by_mod)});
} }
const modname = this.model.mod ? this.model.mod.getDisplayName() : 'A moderator'; const modname = this.model.mod ? this.model.mod.getDisplayName() : 'A moderator';
return __('%1$s has retracted this message', modname); return __('%1$s has removed this message', modname);
} else { } else {
return __('%1$s has retracted this message', this.model.getDisplayName()); return __('%1$s has removed this message', this.model.getDisplayName());
} }
}, },
......
...@@ -1621,6 +1621,7 @@ converse.plugins.add('converse-muc', { ...@@ -1621,6 +1621,7 @@ converse.plugins.add('converse-muc', {
*/ */
handleModeration (attrs) { handleModeration (attrs) {
const MODERATION_ATTRIBUTES = [ const MODERATION_ATTRIBUTES = [
'editable',
'moderated', 'moderated',
'moderated_by', 'moderated_by',
'moderated_id', 'moderated_id',
......
...@@ -88,6 +88,7 @@ const stanza_utils = { ...@@ -88,6 +88,7 @@ const stanza_utils = {
return {}; return {};
} }
return { return {
'edtiable': false,
'moderated': 'retracted', 'moderated': 'retracted',
'moderated_by': moderated.getAttribute('by'), 'moderated_by': moderated.getAttribute('by'),
'moderated_id': applies_to_id, 'moderated_id': applies_to_id,
...@@ -101,9 +102,10 @@ const stanza_utils = { ...@@ -101,9 +102,10 @@ const stanza_utils = {
const retracted = sizzle(`retracted[xmlns="${Strophe.NS.RETRACT}"]`, tombstone).pop(); const retracted = sizzle(`retracted[xmlns="${Strophe.NS.RETRACT}"]`, tombstone).pop();
if (retracted) { if (retracted) {
return { return {
'edtiable': false,
'is_tombstone': true, 'is_tombstone': true,
'retracted': tombstone.getAttribute('stamp'),
'moderated_by': tombstone.getAttribute('by'), 'moderated_by': tombstone.getAttribute('by'),
'retracted': tombstone.getAttribute('stamp'),
'moderation_reason': get(tombstone.querySelector('reason'), 'textContent') 'moderation_reason': get(tombstone.querySelector('reason'), 'textContent')
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment