Skip to content

Commit a693fcb

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 1f673b7 commit a693fcb

15 files changed

+661
-21
lines changed

CHANGES.md

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

33
## 6.0.0 (Unreleased)
44

5+
- add message-forward (XEP-0297) capabilities
56
- #129: Add support for XEP-0156: Disovering Alternative XMPP Connection Methods. Only XML is supported for now.
67
- #1105: Preliminary support for storing persistent data in IndexedDB instead of localStorage
78
- #1089: When filtering the roster for `online` users, show all non-offline users.

locale/converse.pot

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,3 +1919,33 @@ msgstr ""
19191919
#: dist/converse-no-dependencies.js:55061
19201920
msgid "Re-sync your contacts"
19211921
msgstr ""
1922+
1923+
msgid "You can only send a message to an existing contact or an opened room."
1924+
msgstr ""
1925+
1926+
msgid "forward this message"
1927+
msgstr ""
1928+
1929+
msgid "Destination:"
1930+
msgstr ""
1931+
1932+
msgid "Additional Message:"
1933+
msgstr ""
1934+
1935+
msgid "Original-Text"
1936+
msgstr ""
1937+
1938+
msgid "Optional: Add additional message here..."
1939+
msgstr ""
1940+
1941+
msgid "forward"
1942+
msgstr ""
1943+
1944+
msgid "Forwarded Message:"
1945+
msgstr ""
1946+
1947+
msgid "original author:"
1948+
msgstr ""
1949+
1950+
msgid "time:"
1951+
msgstr ""

locale/de/LC_MESSAGES/converse.po

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

24942494
#~ msgid "Contact username"
24952495
#~ msgstr "Benutzername"
2496+
2497+
msgid "You can only send a message to an existing contact or an opened room."
2498+
msgstr "Sie können eine Nachricht nur an einen existieren Kontakt oder offenen Chatraum senden."
2499+
2500+
msgid "forward this message"
2501+
msgstr "Nachricht weiterleiten"
2502+
2503+
msgid "Destination:"
2504+
msgstr "Empfänger:"
2505+
2506+
msgid "Additional Message:"
2507+
msgstr "Zusätzliche Nachricht"
2508+
2509+
msgid "Original-Text"
2510+
msgstr "Ursprüngliche Nachricht"
2511+
2512+
msgid "Optional: Add additional message here..."
2513+
msgstr "Optional: Geben Sie hier eine zusätzliche Nachricht ein..."
2514+
2515+
msgid "forward"
2516+
msgstr "weiterleiten"
2517+
2518+
msgid "Forwarded Message:"
2519+
msgstr "Weitergeleitete Nachricht:"
2520+
2521+
msgid "original author:"
2522+
msgstr "Ursprünglicher Autor:"
2523+
2524+
msgid "time:"
2525+
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
@@ -217,8 +217,9 @@
217217
width: 100%;
218218
}
219219
}
220-
220+
221221
.chat-msg__actions {
222+
width: 50px;
222223
.chat-msg__action {
223224
height: var(--message-font-size);
224225
font-size: var(--message-font-size);
@@ -227,10 +228,11 @@
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
@@ -145,7 +145,7 @@
145145
`<presence xmlns="jabber:client">`+
146146
`<show>dnd</show>`+
147147
`<priority>0</priority>`+
148-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
148+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
149149
`</presence>`);
150150
const first_child = view.el.querySelector('.xmpp-status span:first-child');
151151
expect(u.hasClass('online', first_child)).toBe(false);
@@ -174,7 +174,7 @@
174174
`<presence xmlns="jabber:client">`+
175175
`<status>I am happy</status>`+
176176
`<priority>0</priority>`+
177-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
177+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
178178
`</presence>`);
179179

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

spec/messages.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
['rosterGroupsFetched', 'chatBoxesFetched'], {},
1818
async function (done, _converse) {
1919

20+
_converse.whitelisted_plugins = _converse.whitelisted_plugins.filter(e => e !== 'converse-forward-message');
2021
await test_utils.waitForRoster(_converse, 'current', 2);
2122
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
2223
const forwarded_contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@montague.lit';
@@ -83,7 +84,7 @@
8384
expect(textarea.value).toBe('');
8485

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

@@ -160,7 +161,7 @@
160161
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
161162
);
162163
await new Promise(resolve => view.once('messageInserted', resolve));
163-
expect(view.el.querySelectorAll('.chat-msg .chat-msg__action').length).toBe(1);
164+
expect(view.el.querySelectorAll('.chat-msg .chat-msg__action').length).toBe(3);
164165

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

spec/presence.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
`<presence xmlns="jabber:client">`+
4343
`<status>Hello world</status>`+
4444
`<priority>0</priority>`+
45-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
45+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
4646
`</presence>`
4747
);
4848
_converse.priority = 2;
@@ -52,7 +52,7 @@
5252
`<show>away</show>`+
5353
`<status>Going jogging</status>`+
5454
`<priority>2</priority>`+
55-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
55+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
5656
`</presence>`
5757
);
5858

@@ -63,7 +63,7 @@
6363
`<show>dnd</show>`+
6464
`<status>Doing taxes</status>`+
6565
`<priority>0</priority>`+
66-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
66+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
6767
`</presence>`
6868
);
6969
done();
@@ -91,7 +91,7 @@
9191
.toBe(`<presence xmlns="jabber:client">`+
9292
`<status>My custom status</status>`+
9393
`<priority>0</priority>`+
94-
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
94+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
9595
`</presence>`)
9696

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

0 commit comments

Comments
 (0)