prosody: Add module to expose stable client id across sessions

This commit is contained in:
Matthew Wild 2021-10-18 13:50:36 +01:00
parent deddef38f2
commit 83c757c786
3 changed files with 15 additions and 0 deletions

View File

@ -75,6 +75,7 @@ modules_enabled = {
"update_notify";
"turncredentials";
"admin_shell";
"snikket_client_id";
-- Spam/abuse management
"spam_reporting"; -- Allow users to report spam/abuse

View File

@ -131,6 +131,7 @@
- mod_update_notify
- mod_invites_default_group
- mod_invites_bootstrap
- mod_snikket_client_id
- name: "Install lua-ossl for encrypted push notifications"
apt:

View File

@ -0,0 +1,13 @@
-- This module assigns a client_id to sessions if they are using a "Snikket.*"
-- resource identifier. We assume that a resource string in this format is
-- static for the same client instance across every session.
--
-- In the future it is anticipated that this "hack" will be replaced by SASL 2
-- (XEP-0388) and/or Bind 2 (XEP-0386), however this is not yet implemented in
-- Prosody or any clients.
module:hook("resource-bind", function (event)
local id = event.session.resource:match("^Snikket%..+$");
if not id then return; end
event.session.client_id = id;
end, 1000);