Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add message-forwarding functionality #1732

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 6.0.0 (Unreleased)

- add message-forward (XEP-0297) capabilities
- #129: Add support for XEP-0156: Disovering Alternative XMPP Connection Methods. Only XML is supported for now.
- #1105: Preliminary support for storing persistent data in IndexedDB instead of localStorage
- #1089: When filtering the roster for `online` users, show all non-offline users.
Expand Down
30 changes: 30 additions & 0 deletions locale/converse.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1919,3 +1919,33 @@ msgstr ""
#: dist/converse-no-dependencies.js:55061
msgid "Re-sync your contacts"
msgstr ""

msgid "You can only send a message to an existing contact or an opened room."
msgstr ""

msgid "forward this message"
msgstr ""

msgid "Destination:"
msgstr ""

msgid "Additional Message:"
msgstr ""

msgid "Original-Text"
msgstr ""

msgid "Optional: Add additional message here..."
msgstr ""

msgid "forward"
msgstr ""

msgid "Forwarded Message:"
msgstr ""

msgid "original author:"
msgstr ""

msgid "time:"
msgstr ""
30 changes: 30 additions & 0 deletions locale/de/LC_MESSAGES/converse.po
Original file line number Diff line number Diff line change
Expand Up @@ -2493,3 +2493,33 @@ msgstr "Resynchronisieren Sie Ihre Kontakte"

#~ msgid "Contact username"
#~ msgstr "Benutzername"

msgid "You can only send a message to an existing contact or an opened room."
msgstr "Sie können eine Nachricht nur an einen existieren Kontakt oder offenen Chatraum senden."

msgid "forward this message"
msgstr "Nachricht weiterleiten"

msgid "Destination:"
msgstr "Empfänger:"

msgid "Additional Message:"
msgstr "Zusätzliche Nachricht"

msgid "Original-Text"
msgstr "Ursprüngliche Nachricht"

msgid "Optional: Add additional message here..."
msgstr "Optional: Geben Sie hier eine zusätzliche Nachricht ein..."

msgid "forward"
msgstr "weiterleiten"

msgid "Forwarded Message:"
msgstr "Weitergeleitete Nachricht:"

msgid "original author:"
msgstr "Ursprünglicher Autor:"

msgid "time:"
msgstr "Zeit:"
8 changes: 8 additions & 0 deletions sass/_autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
.suggestion-box {
width: 100%;
}
.forward-message {
overflow: visible;
border: black;
height: 100px;
border-radius: 5px;
background-color: lightgrey;
padding: 5px;
}
}

.suggestion-box {
Expand Down
28 changes: 24 additions & 4 deletions sass/_messages.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@
width: 100%;
}
}

.chat-msg__actions {
width: 50px;
.chat-msg__action {
height: var(--message-font-size);
font-size: var(--message-font-size);
Expand All @@ -227,10 +228,11 @@
border: none;
opacity: 0;
background: transparent;
width: 10px;
cursor: pointer;
&:focus {
display: block;
}
display: block;
margin: 0px 0px 0px 10px;
float: right;
}
}

Expand Down Expand Up @@ -310,6 +312,24 @@
margin-right: 0.5em;
color: var(--message-receipt-color);
}

.forwarded-message {
white-space: normal;
background-color: lightblue;
border-radius: 5px;
padding: 5px;
margin-left: 5px;
}

.forwarded-message__content {
background-color: white;
border-radius: 5px;
padding-left: 5px;
}

.forwarded-message__header {
font-size: 11px;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions spec/controlbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
`<presence xmlns="jabber:client">`+
`<show>dnd</show>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`);
const first_child = view.el.querySelector('.xmpp-status span:first-child');
expect(u.hasClass('online', first_child)).toBe(false);
Expand Down Expand Up @@ -174,7 +174,7 @@
`<presence xmlns="jabber:client">`+
`<status>I am happy</status>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`);

const first_child = view.el.querySelector('.xmpp-status span:first-child');
Expand Down
5 changes: 3 additions & 2 deletions spec/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
['rosterGroupsFetched', 'chatBoxesFetched'], {},
async function (done, _converse) {

_converse.whitelisted_plugins = _converse.whitelisted_plugins.filter(e => e !== 'converse-forward-message');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second parameter of initConverse 3 lines above is a settings map.
So you can pass in {blacklisted_plugins: ['converse-forward-message']} there instead of doing this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it. Then the test fails again. The problem is, that I check with the following if the plugin is enabled:
if (!_converse.whitelisted_plugins.includes('converse-forward-message'))
So when I add it to the blacklisted plugins it is also a whitelisted plugin. That's why it will not reject the message and the test fails. I'm thinking about also adding || _converse.blacklisted_plugins.includes('converse-forward-message') to the if-statement. I don't really like the solution anyways, but could not find a better way from preventing converse to send an error-message on forwarded-messages, if the plugin is enabled.

I also tried to find out why the tests for xep-0363. For me all tests work and I cannot find anything in the code (by just looking) that jumps out. I updated the pull-Request anyway to the latest commit.

await test_utils.waitForRoster(_converse, 'current', 2);
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
const forwarded_contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@montague.lit';
Expand Down Expand Up @@ -83,7 +84,7 @@
expect(textarea.value).toBe('');

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

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

// Test confirmation dialog
spyOn(window, 'confirm').and.returnValue(true);
Expand Down
10 changes: 5 additions & 5 deletions spec/presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
`<presence xmlns="jabber:client">`+
`<status>Hello world</status>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`
);
_converse.priority = 2;
Expand All @@ -52,7 +52,7 @@
`<show>away</show>`+
`<status>Going jogging</status>`+
`<priority>2</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`
);

Expand All @@ -63,7 +63,7 @@
`<show>dnd</show>`+
`<status>Doing taxes</status>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`
);
done();
Expand Down Expand Up @@ -91,7 +91,7 @@
.toBe(`<presence xmlns="jabber:client">`+
`<status>My custom status</status>`+
`<priority>0</priority>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Hxbsr5fazs62i+O0GxIXf2OEDNs=" xmlns="http://jabber.org/protocol/caps"/>`+
`<c hash="sha-1" node="https://conversejs.org" ver="Js7MzULrV40dmSBGeP+rd0MNV9c=" xmlns="http://jabber.org/protocol/caps"/>`+
`</presence>`)

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