Software /
code /
prosody
Comparison
plugins/muc/hats.lib.lua @ 10714:9ecad2304297
MUC: Switch hats to new presence APIs
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 11 Apr 2020 16:45:27 +0100 |
parent | 10693:76bb806cdd4b |
child | 11245:43b43e7156b8 |
comparison
equal
deleted
inserted
replaced
10713:38159b9adf9f | 10714:9ecad2304297 |
---|---|
1 local st = require "util.stanza"; | 1 local st = require "util.stanza"; |
2 local muc_util = module:require "muc/util"; | |
2 | 3 |
3 local xmlns_hats = "xmpp:prosody.im/protocol/hats:1"; | 4 local xmlns_hats = "xmpp:prosody.im/protocol/hats:1"; |
4 | 5 |
5 module:hook("muc-broadcast-presence", function (event) | 6 -- Strip any hats claimed by the client (to prevent spoofing) |
6 -- Strip any hats claimed by the client (to prevent spoofing) | 7 muc_util.add_filtered_namespace(xmlns_hats); |
7 event.stanza:remove_children("hats", xmlns_hats); | |
8 | 8 |
9 module:hook("muc-build-occupant-presence", function (event) | |
9 local aff_data = event.room:get_affiliation_data(event.occupant.bare_jid); | 10 local aff_data = event.room:get_affiliation_data(event.occupant.bare_jid); |
10 local hats = aff_data and aff_data.hats; | 11 local hats = aff_data and aff_data.hats; |
11 if not hats then return; end | 12 if not hats then return; end |
12 local hats_el; | 13 local hats_el; |
13 for hat_id, hat_data in pairs(hats) do | 14 for hat_id, hat_data in pairs(hats) do |