Mercurial > prosody-modules
annotate mod_muc_mav/mod_muc_mav.lua @ 6556:7477e97a9045
mod_firewall: Apply pre-reload state before re-reading config
This change makes load/reload a bit more robust. module.load() runs before
module.restore() and it reads from the config and updates the state (if
needed).
However, after this, module.restore() could run and apply the old state again.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 24 May 2026 20:03:20 +0100 |
| parents | 19bee2a6436a |
| children |
| rev | line source |
|---|---|
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
2 local hashes = require "util.hashes"; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
3 local base64 = require "util.encodings".base64; |
|
6540
7cb25e7d945d
mod_muc_mav: Prevent JIDs leaking to occupants who are not allowed
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6539
diff
changeset
|
4 local util_jid = require "util.jid"; |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
5 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
6 local mod_muc = module:depends"muc"; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
7 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
8 local xmlns_mav = "urn:xmpp:muc:affiliations:1"; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
9 local xmlns_muc = "http://jabber.org/protocol/muc"; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
10 local xmlns_muc_user = "http://jabber.org/protocol/muc#user"; |
|
6539
4d7e2d0db2ab
mod_muc_mav: include occupant-id in affiliation list
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6530
diff
changeset
|
11 local xmlns_occupant_id = "urn:xmpp:occupant-id:0"; |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
12 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
13 local mav_versions = {} |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
14 |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
15 local function get_affiliations(from, room, hash_only) |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
16 local mav_since = nil |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
17 local jid_affiliations = {} |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
18 local xs = {} |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
19 local x = st.stanza("x", {xmlns = xmlns_muc_user;}); |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
20 local count = 0 |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
21 for jid, affiliation, affiliation_data in room:each_affiliation() do |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
22 table.insert(jid_affiliations, jid.."\0"..affiliation); |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
23 if not hash_only then |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
24 local occupant_id = room:get_occupant_id_from_jid(jid); |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
25 local nick = affiliation_data and affiliation_data.reserved_nickname or nil; |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
26 local show_jid = (not room:is_anonymous_for(from) or util_jid.bare(from) == jid) and jid or nil |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
27 x:tag("item", {affiliation = affiliation or "none"; jid = show_jid; nick = nick;}) |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
28 :tag("occupant-id", { xmlns = xmlns_occupant_id, id = occupant_id }):up():up(); |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
29 count = count + 1 |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
30 if count > 400 then |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
31 table.sort(jid_affiliations) |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
32 local hash_input = table.concat(jid_affiliations, "\0") |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
33 local hash = base64.encode(hashes.sha256(hash_input)) |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
34 x:tag("mav", {xmlns = xmlns_mav; since = mav_since; ["until"] = hash;}):up() |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
35 table.insert(xs, x) |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
36 x = st.stanza("x", {xmlns = xmlns_muc_user;}) |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
37 count = 0 |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
38 mav_since = hash |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
39 end |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
40 end |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
41 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
42 table.sort(jid_affiliations); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
43 local hash_input = table.concat(jid_affiliations, "\0"); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
44 local hash = base64.encode(hashes.sha256(hash_input)) |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
45 if not hash_only and (count > 0 or #xs < 1) then |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
46 x:tag("mav", {xmlns = xmlns_mav; since = mav_since; ["until"] = hash;}):up(); |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
47 table.insert(xs, x); |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
48 end |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
49 return hash, xs; |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
50 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
51 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
52 local function handle_stanza_with_x(room, stanza, mav_current) |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
53 local muc_x = stanza:get_child("x", xmlns_muc_user); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
54 local is_initial = false; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
55 for child in muc_x:childtags("status") do |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
56 if child.attr.code == "110" then is_initial = true; end; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
57 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
58 if is_initial then |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
59 muc_x:tag("mav", {xmlns = xmlns_mav; ["until"] = mav_current;}):up(); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
60 else |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
61 -- TODO: stop recomputing the hash on every stanza in the presence flood |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
62 local mav_new = get_affiliations(stanza.attr.from, room, true); |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
63 if mav_current ~= mav_new then |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
64 module:log("info", "Update version of %s from %s to %s in affiliation update", stanza.attr.to, mav_current, mav_new); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
65 muc_x:tag("mav", {xmlns = xmlns_mav; ["since"] = mav_current; ["until"] = mav_new; }):up(); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
66 mav_versions[room.jid.."\0"..stanza.attr.to] = mav_new; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
67 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
68 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
69 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
70 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
71 local function room_route_stanza(room, stanza) |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
72 local muc_x = stanza:get_child("x", xmlns_muc_user); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
73 if muc_x then |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
74 local mav_current = mav_versions[room.jid.."\0"..stanza.attr.to]; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
75 if mav_current then |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
76 if stanza.name == "presence" or stanza.name == "message" then |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
77 handle_stanza_with_x(room, stanza, mav_current); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
78 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
79 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
80 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
81 module:send(stanza); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
82 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
83 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
84 -- TODO: Stop this hack |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
85 local original_room_route_stanza = mod_muc.room_mt.route_stanza; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
86 mod_muc.room_mt.route_stanza = room_route_stanza; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
87 function module.unload() |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
88 mod_muc.room_mt.route_stanza = original_room_route_stanza; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
89 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
90 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
91 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
92 module:hook("muc-disco#info", function(event) |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
93 event.reply:tag("feature", {var = xmlns_mav}):up(); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
94 end); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
95 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
96 module:hook("muc-occupant-pre-join", function(event) |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
97 local room, stanza = event.room, event.stanza; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
98 local muc_x = stanza:get_child("x", xmlns_muc); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
99 if not muc_x then return; end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
100 local mav_child = muc_x:get_child("mav", xmlns_mav); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
101 if not mav_child then return; end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
102 local mav_since = mav_child.attr["since"]; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
103 mav_versions[room.jid.."\0"..stanza.attr.from] = mav_since; |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
104 local mav_current, xs = get_affiliations(stanza.attr.from, room); |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
105 if mav_current ~= mav_since then |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
106 -- TODO: Support for diffs |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
107 -- Send full response |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
108 module:log("info", "Old version of %s is %s, sending full response for %s", stanza.attr.from, mav_since, mav_current); |
|
6543
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
109 for _, x in ipairs(xs) do |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
110 local announce_msg = st.message({ from = room.jid, to = stanza.attr.from }):add_child(x); |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
111 room:route_stanza(announce_msg); |
|
19bee2a6436a
mod_muc_mav: allow to work even in very large rooms
Stephen Paul Weber <singpolyma@singpolyma.net>
parents:
6542
diff
changeset
|
112 end |
|
6530
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
113 mav_versions[room.jid.."\0"..stanza.attr.from] = mav_current; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
114 else |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
115 module:log("info", "Old version of %s is %s, still current", stanza.attr.from, mav_since); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
116 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
117 end, -100); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
118 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
119 module:hook("muc-occupant-left", function(event) |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
120 local room, occupant = event.room, event.occupant; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
121 for jid in occupant:each_session() do |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
122 mav_versions[room.jid.."\0"..jid] = nil; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
123 end |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
124 end); |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
125 |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
126 module:hook("muc-occupant-pre-leave", function(event) |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
127 local room, stanza = event.room, event.stanza; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
128 mav_versions[room.jid.."\0"..stanza.attr.from] = nil; |
|
8e87fbbb6cd3
mod_muc_mav: Add module for XEP-0463: MUC Affiliations Versioning
Marvin W <hg@larma.de>
parents:
diff
changeset
|
129 end); |
