Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -16,6 +16,7 @@
- #3769: Various OMEMO fixes
- #3791: Fetching pubsub node configuration fails
- #3792: Node reconfiguration attempt uses incorrect field names
- Adding support for protocol handler
- Fix documentation formatting in security.rst
- Add approval banner in chats with requesting contacts or unsaved contacts
- Add mongolian as a language option
Expand Down
8 changes: 7 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@
"background_color": "#397491",
"display": "standalone",
"scope": "/",
"theme_color": "#397491"
"theme_color": "#397491",
"protocol_handlers": [
{
"protocol": "xmpp",
"url": "/dev?jid=%s"
}
]
}
11 changes: 10 additions & 1 deletion src/headless/plugins/chat/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ export function routeToChat (event) {
return;
}
event?.preventDefault();
const jid = location.hash.split('=').pop();
let jid = location.hash.split('=').pop();
// decodeURIComponent is needed in case the JID contains special characters
// that were URL-encoded, e.g. `user%40domain` instead of `user@domain`.
jid = decodeURIComponent(jid);

// Remove xmpp: prefix if present
if (jid.startsWith('xmpp:')) {
jid = jid.slice(5);
}

if (!u.isValidJID(jid)) {
return log.warn(`Invalid JID "${jid}" provided in URL fragment`);
}
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/chatview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ converse.plugins.add('converse-chatview', {
Object.assign(_converse, exports); // DEPRECATED
Object.assign(_converse.exports, exports);

if ('registerProtocolHandler' in navigator) {
try {
const handlerUrl = `${window.location.origin}${window.location.pathname}#converse/chat?jid=%s`;
navigator.registerProtocolHandler('xmpp', handlerUrl);
} catch (error) {
console.warn('Failed to register protocol handler:', error);
}
}
api.listen.on('connected', () => api.disco.own.features.add(Strophe.NS.SPOILER));
api.listen.on('chatBoxClosed', (model) => clearHistory(model.get('jid')));
}
Expand Down
Loading