diff plugins/muc/occupant_id.lib.lua @ 13905:0e346f4d88ce

MUC: Add get_occupant_id_from_jid() method, which works on real JIDs This is useful to get the occupant ID of someone who is affiliated, but not currently joined to the room.
author Matthew Wild <mwild1@gmail.com>
date Fri, 20 Jun 2025 18:55:39 +0100
parents a45b209302c1
children
line wrap: on
line diff
--- a/plugins/muc/occupant_id.lib.lua	Mon Nov 11 12:52:54 2024 +0000
+++ b/plugins/muc/occupant_id.lib.lua	Fri Jun 20 18:55:39 2025 +0100
@@ -31,6 +31,11 @@
 	return occupant.stable_id;
 end
 
+local function get_occupant_id_from_jid(room, real_bare_jid)
+	local salt = get_room_salt(room)
+	return b64encode(hmac_sha256(real_bare_jid, salt));
+end
+
 local function update_occupant(event)
 	local stanza, room, occupant, dest_occupant = event.stanza, event.room, event.occupant, event.dest_occupant;
 
@@ -73,4 +78,5 @@
 return {
 	get_room_salt = get_room_salt;
 	get_occupant_id = get_occupant_id;
+	get_occupant_id_from_jid = get_occupant_id_from_jid;
 };