Remove unfurls for hyperlinks removed in a message correction
This commit is contained in:
parent
f9e6c3ff95
commit
8378ce739b
|
@ -11,6 +11,7 @@
|
||||||
- Don't apply message corrections when the MUC occupant-id doesn't match.
|
- Don't apply message corrections when the MUC occupant-id doesn't match.
|
||||||
- Update `nick` attribute on ChatRoom when user nickname changes
|
- Update `nick` attribute on ChatRoom when user nickname changes
|
||||||
- Restrict editing of MUC messages to ones with the same XEP-0421 occupant ID
|
- Restrict editing of MUC messages to ones with the same XEP-0421 occupant ID
|
||||||
|
- Remove unfurls for links removed in a subsequent message correction
|
||||||
- #2870: Fix for multiple URLs to be linkified when sent together in chat and adds a test for this.
|
- #2870: Fix for multiple URLs to be linkified when sent together in chat and adds a test for this.
|
||||||
- #2879: Quotes, lines not aligned to the first line
|
- #2879: Quotes, lines not aligned to the first line
|
||||||
- #2925: Fix missing disco-items in browser storage.
|
- #2925: Fix missing disco-items in browser storage.
|
||||||
|
|
|
@ -934,6 +934,7 @@ const ChatBox = ModelWithContact.extend({
|
||||||
'correcting': false,
|
'correcting': false,
|
||||||
'edited': (new Date()).toISOString(),
|
'edited': (new Date()).toISOString(),
|
||||||
'message': attrs.body,
|
'message': attrs.body,
|
||||||
|
'ogp_metadata': [],
|
||||||
'origin_id': u.getUniqueId(),
|
'origin_id': u.getUniqueId(),
|
||||||
'received': undefined,
|
'received': undefined,
|
||||||
older_versions,
|
older_versions,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*global mock, converse */
|
/*global mock, converse */
|
||||||
|
|
||||||
const { u } = converse.env;
|
const { Strophe, u } = converse.env;
|
||||||
|
|
||||||
describe("A Groupchat Message", function () {
|
describe("A Groupchat Message", function () {
|
||||||
|
|
||||||
|
@ -106,7 +106,6 @@ describe("A Groupchat Message", function () {
|
||||||
const el = await u.waitUntil(() => view.querySelector('.chat-msg__text'));
|
const el = await u.waitUntil(() => view.querySelector('.chat-msg__text'));
|
||||||
expect(el.textContent).toBe(unfurl_url);
|
expect(el.textContent).toBe(unfurl_url);
|
||||||
|
|
||||||
|
|
||||||
const metadata_stanza = u.toStanza(`
|
const metadata_stanza = u.toStanza(`
|
||||||
<message xmlns="jabber:client" from="${muc_jid}" to="${_converse.jid}" type="groupchat">
|
<message xmlns="jabber:client" from="${muc_jid}" to="${_converse.jid}" type="groupchat">
|
||||||
<apply-to xmlns="urn:xmpp:fasten:0" id="eda6c790-b4f3-4c07-b5e2-13fff99e6c04">
|
<apply-to xmlns="urn:xmpp:fasten:0" id="eda6c790-b4f3-4c07-b5e2-13fff99e6c04">
|
||||||
|
@ -402,4 +401,89 @@ describe("A Groupchat Message", function () {
|
||||||
api.settings.set('allowed_image_domains', undefined);
|
api.settings.set('allowed_image_domains', undefined);
|
||||||
await u.waitUntil(() => view.querySelector('converse-message-unfurl .chat-image') !== null);
|
await u.waitUntil(() => view.querySelector('converse-message-unfurl .chat-image') !== null);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it("will not render an unfurl that has been removed in a subsequent correction", mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {
|
||||||
|
const nick = 'romeo';
|
||||||
|
const muc_jid = 'lounge@muc.montague.lit';
|
||||||
|
await mock.openAndEnterChatRoom(_converse, muc_jid, nick);
|
||||||
|
const view = _converse.chatboxviews.get(muc_jid);
|
||||||
|
|
||||||
|
const unfurl_image_src = "https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg";
|
||||||
|
const unfurl_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
|
||||||
|
|
||||||
|
spyOn(_converse.connection, 'send').and.callThrough();
|
||||||
|
|
||||||
|
const textarea = await u.waitUntil(() => view.querySelector('textarea.chat-textarea'));
|
||||||
|
const message_form = view.querySelector('converse-muc-message-form');
|
||||||
|
textarea.value = unfurl_url;
|
||||||
|
const enter_event = {
|
||||||
|
'target': textarea,
|
||||||
|
'preventDefault': function preventDefault () {},
|
||||||
|
'stopPropagation': function stopPropagation () {},
|
||||||
|
'keyCode': 13 // Enter
|
||||||
|
}
|
||||||
|
message_form.onKeyDown(enter_event);
|
||||||
|
|
||||||
|
await u.waitUntil(() => view.querySelectorAll('.chat-msg').length === 1);
|
||||||
|
expect(view.querySelector('.chat-msg__text').textContent)
|
||||||
|
.toBe(unfurl_url);
|
||||||
|
|
||||||
|
let msg = _converse.connection.send.calls.all()[0].args[0];
|
||||||
|
expect(Strophe.serialize(msg))
|
||||||
|
.toBe(
|
||||||
|
`<message from="${_converse.jid}" id="${msg.getAttribute('id')}" to="${muc_jid}" type="groupchat" xmlns="jabber:client">`+
|
||||||
|
`<body>${unfurl_url}</body>`+
|
||||||
|
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||||
|
`<origin-id id="${msg.querySelector('origin-id')?.getAttribute('id')}" xmlns="urn:xmpp:sid:0"/>`+
|
||||||
|
`</message>`);
|
||||||
|
|
||||||
|
const el = await u.waitUntil(() => view.querySelector('.chat-msg__text'));
|
||||||
|
expect(el.textContent).toBe(unfurl_url);
|
||||||
|
|
||||||
|
const metadata_stanza = u.toStanza(`
|
||||||
|
<message xmlns="jabber:client" from="${muc_jid}" to="${_converse.jid}" type="groupchat">
|
||||||
|
<apply-to xmlns="urn:xmpp:fasten:0" id="${msg.getAttribute('id')}">
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:site_name" content="YouTube" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:url" content="${unfurl_url}" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:title" content="Rick Astley - Never Gonna Give You Up (Video)" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:image" content="${unfurl_image_src}" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:image:width" content="1280" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:image:height" content="720" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:description" content="Rick Astley&#39;s official music video for "Never Gonna Give You Up" Listen to Rick Astley: https://RickAstley.lnk.to/_listenYD Subscribe to the official Rick Ast..." />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:type" content="video.other" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:video:url" content="https://www.youtube.com/embed/dQw4w9WgXcQ" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:video:secure_url" content="https://www.youtube.com/embed/dQw4w9WgXcQ" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:video:type" content="text/html" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:video:width" content="1280" />
|
||||||
|
<meta xmlns="http://www.w3.org/1999/xhtml" property="og:video:height" content="720" />
|
||||||
|
</apply-to>
|
||||||
|
</message>`);
|
||||||
|
_converse.connection._dataRecv(mock.createRequest(metadata_stanza));
|
||||||
|
|
||||||
|
const unfurl = await u.waitUntil(() => view.querySelector('converse-message-unfurl'));
|
||||||
|
expect(unfurl.querySelector('.card-img-top').getAttribute('src')).toBe(unfurl_image_src);
|
||||||
|
expect(unfurl.querySelector('.card-img-top').getAttribute('href')).toBe(unfurl_url);
|
||||||
|
|
||||||
|
// Modify the message to use a different URL
|
||||||
|
expect(textarea.value).toBe('');
|
||||||
|
message_form.onKeyDown({
|
||||||
|
target: textarea,
|
||||||
|
keyCode: 38 // Up arrow
|
||||||
|
});
|
||||||
|
expect(textarea.value).toBe(unfurl_url);
|
||||||
|
textarea.value = "never mind";
|
||||||
|
message_form.onKeyDown(enter_event);
|
||||||
|
|
||||||
|
const getSentMessages = () => _converse.connection.send.calls.all().map(c => c.args[0]).filter(s => s.nodeName === 'message');
|
||||||
|
await u.waitUntil(() => getSentMessages().length == 2);
|
||||||
|
msg = getSentMessages().pop();
|
||||||
|
expect(Strophe.serialize(msg))
|
||||||
|
.toBe(
|
||||||
|
`<message from="${_converse.jid}" id="${msg.getAttribute('id')}" to="${muc_jid}" type="groupchat" xmlns="jabber:client">`+
|
||||||
|
`<body>never mind</body>`+
|
||||||
|
`<active xmlns="http://jabber.org/protocol/chatstates"/>`+
|
||||||
|
`<replace id="${msg.querySelector('replace')?.getAttribute('id')}" xmlns="urn:xmpp:message-correct:0"/>`+
|
||||||
|
`<origin-id id="${msg.querySelector('origin-id')?.getAttribute('id')}" xmlns="urn:xmpp:sid:0"/>`+
|
||||||
|
`</message>`);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user