Comparison

mod_muc_occupant_id/mod_muc_occupant_id.lua @ 3945:cf682a02b6d8

mod_muc_occupant_id: Handle MUC-PMs
author Maxime “pep” Buquet <pep@bouah.net>
date Sun, 15 Mar 2020 17:18:49 +0100
parent 3916:f1e28dcb3791
child 4010:ae27f3359df8
comparison
equal deleted inserted replaced
3944:7630d4ade7cd 3945:cf682a02b6d8
42 42
43 local unique_id = generate_id(occupant, room); 43 local unique_id = generate_id(occupant, room);
44 stanza:tag("occupant-id", { xmlns = xmlns_occupant_id, id = unique_id }):up(); 44 stanza:tag("occupant-id", { xmlns = xmlns_occupant_id, id = unique_id }):up();
45 end 45 end
46 46
47 local function muc_private(event)
48 local stanza, room = event.stanza, event.room;
49 local occupant = room._occupants[stanza.attr.from];
50
51 update_occupant({
52 stanza = stanza,
53 room = room,
54 occupant = occupant,
55 });
56 end
57
47 module:add_feature(xmlns_occupant_id); 58 module:add_feature(xmlns_occupant_id);
48 module:hook("muc-disco#info", function (event) 59 module:hook("muc-disco#info", function (event)
49 event.reply:tag("feature", { var = xmlns_occupant_id }):up(); 60 event.reply:tag("feature", { var = xmlns_occupant_id }):up();
50 end); 61 end);
51 62
52 -- TODO: Handle MUC-PMs
53 module:hook("muc-broadcast-presence", update_occupant); 63 module:hook("muc-broadcast-presence", update_occupant);
54 module:hook("muc-occupant-pre-join", update_occupant); 64 module:hook("muc-occupant-pre-join", update_occupant);
55 module:hook("muc-occupant-pre-change", update_occupant); 65 module:hook("muc-occupant-pre-change", update_occupant);
56 module:hook("muc-occupant-groupchat", update_occupant); 66 module:hook("muc-occupant-groupchat", update_occupant);
67 module:hook("muc-private-message", muc_private);