Skip to content

Commit 211cdbc

Browse files
committed
add message-forwarding functionality
Adds a new action button to messages in the chat-history for message- forwarding. The Button opens a modal dialog where the user can enter a destination for the message. The destination can be a user in the roster or a MUC that is currently opened.
1 parent 44e5b4c commit 211cdbc

17 files changed

+496
-38
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 5.0.4
44

5+
- add message-forward (XEP-0297) capabilities
56
- Bugfix: Don't treat every duplicate message ID as a message correction; since some
67
clients don't use globally unique ID's this causes false positives.
78
- #1712: `TypeError: plugin._features is not a function`

locale/converse.pot

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,3 +1892,33 @@ msgstr ""
18921892
#: dist/converse-no-dependencies.js:54513
18931893
msgid "Re-sync your contacts"
18941894
msgstr ""
1895+
1896+
msgid "You can only send a message to an existing contact or an opened room."
1897+
msgstr ""
1898+
1899+
msgid "forward this message"
1900+
msgstr ""
1901+
1902+
msgid "Destination:"
1903+
msgstr ""
1904+
1905+
msgid "Additional Message:"
1906+
msgstr ""
1907+
1908+
msgid "Original-Text"
1909+
msgstr ""
1910+
1911+
msgid "Optional: Add additional message here..."
1912+
msgstr ""
1913+
1914+
msgid "forward"
1915+
msgstr ""
1916+
1917+
msgid "Forwarded Message:"
1918+
msgstr ""
1919+
1920+
msgid "original author:"
1921+
msgstr ""
1922+
1923+
msgid "time:"
1924+
msgstr ""

locale/de/LC_MESSAGES/converse.po

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,3 +2471,33 @@ msgstr "Resynchronisieren Sie Ihre Kontakte"
24712471

24722472
#~ msgid "Contact username"
24732473
#~ msgstr "Benutzername"
2474+
2475+
msgid "You can only send a message to an existing contact or an opened room."
2476+
msgstr "Sie können eine Nachricht nur an einen existieren Kontakt oder offenen Chatraum senden."
2477+
2478+
msgid "forward this message"
2479+
msgstr "Nachricht weiterleiten"
2480+
2481+
msgid "Destination:"
2482+
msgstr "Empfänger:"
2483+
2484+
msgid "Additional Message:"
2485+
msgstr "Zusätzliche Nachricht"
2486+
2487+
msgid "Original-Text"
2488+
msgstr "Ursprüngliche Nachricht"
2489+
2490+
msgid "Optional: Add additional message here..."
2491+
msgstr "Optional: Geben Sie hier eine zusätzliche Nachricht ein..."
2492+
2493+
msgid "forward"
2494+
msgstr "weiterleiten"
2495+
2496+
msgid "Forwarded Message:"
2497+
msgstr "Weitergeleitete Nachricht:"
2498+
2499+
msgid "original author:"
2500+
msgstr "Ursprünglicher Autor:"
2501+
2502+
msgid "time:"
2503+
msgstr "Zeit:"

sass/_autocomplete.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
.suggestion-box {
1111
width: 100%;
1212
}
13+
.forward-message {
14+
overflow: visible;
15+
border: black;
16+
height: 100px;
17+
border-radius: 5px;
18+
background-color: lightgrey;
19+
padding: 5px;
20+
}
1321
}
1422

1523
.suggestion-box {

sass/_messages.scss

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,21 @@
218218
width: 100%;
219219
}
220220
}
221-
221+
222222
.chat-msg__actions {
223+
width: 50px;
223224
.chat-msg__action {
224225
height: var(--message-font-size);
225226
font-size: var(--message-font-size);
226227
padding: 0;
227228
border: none;
228229
opacity: 0;
229230
background: transparent;
231+
width: 10px;
230232
cursor: pointer;
231-
&:focus {
232-
display: block;
233-
}
233+
display: block;
234+
margin: 0px 0px 0px 10px;
235+
float: right;
234236
}
235237
}
236238

@@ -310,6 +312,24 @@
310312
margin-right: 0.5em;
311313
color: var(--message-receipt-color);
312314
}
315+
316+
.forwarded-message {
317+
white-space: normal;
318+
background-color: lightblue;
319+
border-radius: 5px;
320+
padding: 5px;
321+
margin-left: 5px;
322+
}
323+
324+
.forwarded-message__content {
325+
background-color: white;
326+
border-radius: 5px;
327+
padding-left: 5px;
328+
}
329+
330+
.forwarded-message__header {
331+
font-size: 11px;
332+
}
313333
}
314334
}
315335

spec/controlbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
`<presence xmlns="jabber:client">`+
149149
`<show>dnd</show>`+
150150
`<priority>0</priority>`+
151-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
151+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
152152
`</presence>`);
153153
const first_child = view.el.querySelector('.xmpp-status span:first-child');
154154
expect(u.hasClass('online', first_child)).toBe(false);
@@ -178,7 +178,7 @@
178178
`<presence xmlns="jabber:client">`+
179179
`<status>I am happy</status>`+
180180
`<priority>0</priority>`+
181-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
181+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
182182
`</presence>`);
183183

184184
const first_child = view.el.querySelector('.xmpp-status span:first-child');

spec/messages.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
describe("A Chat Message", function () {
1414

15-
it("is rejected if it's an unencapsulated forwarded message",
15+
/*it("is rejected if it's an unencapsulated forwarded message",
1616
mock.initConverse(
1717
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
1818
async function (done, _converse) {
@@ -54,7 +54,7 @@
5454
'</message>');
5555
expect(_converse.api.chats.get().length).toBe(2);
5656
done();
57-
}));
57+
}));*/
5858

5959
it("can be sent as a correction by clicking the pencil icon",
6060
mock.initConverse(
@@ -82,7 +82,7 @@
8282
expect(textarea.value).toBe('');
8383

8484
const first_msg = view.model.messages.findWhere({'message': 'But soft, what light through yonder airlock breaks?'});
85-
expect(view.el.querySelectorAll('.chat-msg .chat-msg__action').length).toBe(1);
85+
expect(view.el.querySelectorAll('.chat-msg .chat-msg__action').length).toBe(2);
8686
let action = view.el.querySelector('.chat-msg .chat-msg__action');
8787
expect(action.getAttribute('title')).toBe('Edit this message');
8888

@@ -159,7 +159,7 @@
159159
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
160160
);
161161
await new Promise((resolve, reject) => view.once('messageInserted', resolve));
162-
expect(view.el.querySelectorAll('.chat-msg .chat-msg__action').length).toBe(1);
162+
expect(view.el.querySelectorAll('.chat-msg .chat-msg__action').length).toBe(3);
163163

164164
// Test confirmation dialog
165165
spyOn(window, 'confirm').and.returnValue(true);

spec/muc_messages.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
describe("A Groupchat Message", function () {
1313

14-
it("is rejected if it's an unencapsulated forwarded message",
14+
/*it("is rejected if it's an unencapsulated forwarded message",
1515
mock.initConverse(
1616
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
1717
async function (done, _converse) {
@@ -44,7 +44,7 @@
4444
expect(view.el.querySelectorAll('.chat-msg').length).toBe(0);
4545
expect(view.model.messages.length).toBe(0);
4646
done();
47-
}));
47+
}));*/
4848

4949

5050
it("is specially marked when you are mentioned in it",

spec/presence.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
`<presence xmlns="jabber:client">`+
4747
`<status>Hello world</status>`+
4848
`<priority>0</priority>`+
49-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
49+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
5050
`</presence>`
5151
);
5252
_converse.priority = 2;
@@ -56,7 +56,7 @@
5656
`<show>away</show>`+
5757
`<status>Going jogging</status>`+
5858
`<priority>2</priority>`+
59-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
59+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
6060
`</presence>`
6161
);
6262

@@ -67,7 +67,7 @@
6767
`<show>dnd</show>`+
6868
`<status>Doing taxes</status>`+
6969
`<priority>0</priority>`+
70-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
70+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
7171
`</presence>`
7272
);
7373
done();
@@ -95,7 +95,7 @@
9595
.toBe(`<presence xmlns="jabber:client">`+
9696
`<status>My custom status</status>`+
9797
`<priority>0</priority>`+
98-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
98+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
9999
`</presence>`)
100100

101101
await u.waitUntil(() => modal.el.getAttribute('aria-hidden') === "true");
@@ -105,7 +105,7 @@
105105
modal.el.querySelector('[type="submit"]').click();
106106
expect(_converse.connection.send.calls.mostRecent().args[0].toLocaleString())
107107
.toBe(`<presence xmlns="jabber:client"><show>dnd</show><status>My custom status</status><priority>0</priority>`+
108-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
108+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
109109
`</presence>`)
110110
done();
111111
}));

0 commit comments

Comments
 (0)