Mercurial > prosody-modules
comparison mod_muc_mav/mod_muc_mav.lua @ 6539:4d7e2d0db2ab
mod_muc_mav: include occupant-id in affiliation list
| author | Stephen Paul Weber <singpolyma@singpolyma.net> |
|---|---|
| date | Mon, 18 May 2026 10:23:12 -0500 |
| parents | 8e87fbbb6cd3 |
| children | 7cb25e7d945d |
comparison
equal
deleted
inserted
replaced
| 6538:de1f17ed4dac | 6539:4d7e2d0db2ab |
|---|---|
| 5 local mod_muc = module:depends"muc"; | 5 local mod_muc = module:depends"muc"; |
| 6 | 6 |
| 7 local xmlns_mav = "urn:xmpp:muc:affiliations:1"; | 7 local xmlns_mav = "urn:xmpp:muc:affiliations:1"; |
| 8 local xmlns_muc = "http://jabber.org/protocol/muc"; | 8 local xmlns_muc = "http://jabber.org/protocol/muc"; |
| 9 local xmlns_muc_user = "http://jabber.org/protocol/muc#user"; | 9 local xmlns_muc_user = "http://jabber.org/protocol/muc#user"; |
| 10 local xmlns_occupant_id = "urn:xmpp:occupant-id:0"; | |
| 10 | 11 |
| 11 local mav_versions = {} | 12 local mav_versions = {} |
| 12 | 13 |
| 13 local function get_affiliations(room) | 14 local function get_affiliations(room) |
| 14 local jid_affiliations = {} | 15 local jid_affiliations = {} |
| 15 local x = st.stanza("x", {xmlns = xmlns_muc_user;}); | 16 local x = st.stanza("x", {xmlns = xmlns_muc_user;}); |
| 16 for jid, affiliation, affiliation_data in room:each_affiliation() do | 17 for jid, affiliation, affiliation_data in room:each_affiliation() do |
| 17 table.insert(jid_affiliations, jid.."\0"..affiliation); | 18 table.insert(jid_affiliations, jid.."\0"..affiliation); |
| 19 local occupant_id = room:get_occupant_id_from_jid(jid); | |
| 18 local nick = affiliation_data and affiliation_data.reserved_nickname; | 20 local nick = affiliation_data and affiliation_data.reserved_nickname; |
| 19 x:tag("item", {affiliation = affiliation or "none"; jid = jid; nick = nick;}):up(); | 21 x:tag("item", {affiliation = affiliation or "none"; jid = jid; nick = nick;}) |
| 22 :tag("occupant-id", { xmlns = xmlns_occupant_id, id = occupant_id }):up():up(); | |
| 20 end | 23 end |
| 21 table.sort(jid_affiliations); | 24 table.sort(jid_affiliations); |
| 22 local hash_input = table.concat(jid_affiliations, "\0"); | 25 local hash_input = table.concat(jid_affiliations, "\0"); |
| 23 local hash = base64.encode(hashes.sha256(hash_input)) | 26 local hash = base64.encode(hashes.sha256(hash_input)) |
| 24 x:tag("mav", {xmlns = xmlns_mav; ["until"] = hash;}):up(); | 27 x:tag("mav", {xmlns = xmlns_mav; ["until"] = hash;}):up(); |
