aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/occupant_id.lib.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-10-05 18:13:51 +0200
committerKim Alvefur <zash@zash.se>2021-10-05 18:13:51 +0200
commit2798f91821c0e98ce8ed7f33b4c776289ad1d7f8 (patch)
tree738e263c3fe3810cf53375577796582476c98999 /plugins/muc/occupant_id.lib.lua
parent1c904b2ed3d83b56ec7650e981c156a9df63de4e (diff)
downloadprosody-2798f91821c0e98ce8ed7f33b4c776289ad1d7f8.tar.gz
prosody-2798f91821c0e98ce8ed7f33b4c776289ad1d7f8.zip
MUC: Add method for getting the occupant id salt to allow reuse
Diffstat (limited to 'plugins/muc/occupant_id.lib.lua')
-rw-r--r--plugins/muc/occupant_id.lib.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/plugins/muc/occupant_id.lib.lua b/plugins/muc/occupant_id.lib.lua
index 1a44462c..1d310b3d 100644
--- a/plugins/muc/occupant_id.lib.lua
+++ b/plugins/muc/occupant_id.lib.lua
@@ -10,16 +10,21 @@ local b64encode = require "util.encodings".base64.encode;
local xmlns_occupant_id = "urn:xmpp:occupant-id:0";
-local function get_occupant_id(room, occupant)
- if occupant.stable_id then
- return occupant.stable_id;
- end
-
+local function get_room_salt(room)
local salt = room._data.occupant_id_salt;
if not salt then
salt = uuid.generate();
room._data.occupant_id_salt = salt;
end
+ return salt;
+end
+
+local function get_occupant_id(room, occupant)
+ if occupant.stable_id then
+ return occupant.stable_id;
+ end
+
+ local salt = get_room_salt(room)
occupant.stable_id = b64encode(hmac_sha256(occupant.bare_jid, salt));
@@ -66,5 +71,6 @@ if module:get_option_boolean("muc_occupant_id", true) then
end
return {
+ get_room_salt = get_room_salt;
get_occupant_id = get_occupant_id;
};