Software /
code /
prosody
File
plugins/muc/occupant_id.lib.lua @ 13531:3a75472a3b9d
doap: Update XEP for mostly editorial changes
XEP-0004: Changes <reported> which is not implemented
XEP-0030: A note on some implementations not advertising disco#info
XEP-0106: Now references PRECIS which we don't have access to
XEP-0107: Editorial fixing of a typo
XEP-0133: Removal of 'Get User Password' already done in 21a1b9fb08a1, editorial changes
XEP-0153: Editorial changes
XEP-0198: Editorial changes and clarifications
XEP-0223: Updated security considerations
XEP-0292: The difference is that the iq syntax implemented in mod_vcard4 is removed. To become compliant, simply unload this module.
XEP-0313: Editorial and minor changes
XEP-0398: Advanced to Stable, no other changes
XEP-0398: Now mentions the implementation method used in mod_vcard_legacy
XEP-0402: Changes only affecting clients
XEP-0421: Added requirements we already satisfy
XEP-0440: Editorial changes
XEP-0478: Editorial changes
Due to their size, review of changes to XEP-0045 and XEP-0060 has been left for later.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 26 Oct 2024 18:06:49 +0200 |
parent | 12977:74b9e05af71e |
child | 13577:a45b209302c1 |
line wrap: on
line source
-- Implementation of https://xmpp.org/extensions/inbox/occupant-id.html -- XEP-0421: Anonymous unique occupant identifiers for MUCs -- (C) 2020 Maxime “pep” Buquet <pep@bouah.net> -- (C) 2020 Matthew Wild <mwild1@gmail.com> local uuid = require "prosody.util.uuid"; local hmac_sha256 = require "prosody.util.hashes".hmac_sha256; local b64encode = require "prosody.util.encodings".base64.encode; local xmlns_occupant_id = "urn:xmpp:occupant-id:0"; 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)); return occupant.stable_id; end local function update_occupant(event) local stanza, room, occupant, dest_occupant = event.stanza, event.room, event.occupant, event.dest_occupant; -- "muc-occupant-pre-change" provides "dest_occupant" but not "occupant". if dest_occupant ~= nil then occupant = dest_occupant; end -- strip any existing <occupant-id/> tags to avoid forgery stanza:remove_children("occupant-id", xmlns_occupant_id); local unique_id = get_occupant_id(room, occupant); stanza:tag("occupant-id", { xmlns = xmlns_occupant_id, id = unique_id }):up(); end local function muc_private(event) local stanza, room = event.stanza, event.room; local occupant = room._occupants[stanza.attr.from]; update_occupant({ stanza = stanza, room = room, occupant = occupant, }); end if module:get_option_boolean("muc_occupant_id", true) then module:add_feature(xmlns_occupant_id); module:hook("muc-disco#info", function (event) event.reply:tag("feature", { var = xmlns_occupant_id }):up(); end); module:hook("muc-broadcast-presence", update_occupant); module:hook("muc-occupant-pre-join", update_occupant); module:hook("muc-occupant-pre-change", update_occupant); module:hook("muc-occupant-groupchat", update_occupant); module:hook("muc-private-message", muc_private); end return { get_room_salt = get_room_salt; get_occupant_id = get_occupant_id; };