Software /
code /
prosody-modules
Comparison
mod_muc_occupant_id/mod_muc_occupant_id.lua @ 3916:f1e28dcb3791
mod_muc_occupant_id: Ensure id is added to self-presences, nick changes, etc.
author | Maxime “pep” Buquet <pep@bouah.net> |
---|---|
date | Thu, 27 Feb 2020 00:39:40 +0100 |
parent | 3904:d14fc974efbc |
child | 3945:cf682a02b6d8 |
comparison
equal
deleted
inserted
replaced
3915:80dffbbd056b | 3916:f1e28dcb3791 |
---|---|
28 | 28 |
29 return room._data.occupant_ids[bare]; | 29 return room._data.occupant_ids[bare]; |
30 end | 30 end |
31 | 31 |
32 local function update_occupant(event) | 32 local function update_occupant(event) |
33 local stanza, occupant, room = event.stanza, event.occupant, event.room; | 33 local stanza, room, occupant, dest_occupant = event.stanza, event.room, event.occupant, event.dest_occupant; |
34 | |
35 -- "muc-occupant-pre-change" provides "dest_occupant" but not "occupant". | |
36 if dest_occupant ~= nil then | |
37 occupant = dest_occupant; | |
38 end | |
34 | 39 |
35 -- strip any existing <occupant-id/> tags to avoid forgery | 40 -- strip any existing <occupant-id/> tags to avoid forgery |
36 stanza:remove_children("occupant-id", xmlns_occupant_id); | 41 stanza:remove_children("occupant-id", xmlns_occupant_id); |
37 | 42 |
38 local unique_id = generate_id(occupant, room); | 43 local unique_id = generate_id(occupant, room); |
45 end); | 50 end); |
46 | 51 |
47 -- TODO: Handle MUC-PMs | 52 -- TODO: Handle MUC-PMs |
48 module:hook("muc-broadcast-presence", update_occupant); | 53 module:hook("muc-broadcast-presence", update_occupant); |
49 module:hook("muc-occupant-pre-join", update_occupant); | 54 module:hook("muc-occupant-pre-join", update_occupant); |
55 module:hook("muc-occupant-pre-change", update_occupant); | |
50 module:hook("muc-occupant-groupchat", update_occupant); | 56 module:hook("muc-occupant-groupchat", update_occupant); |