14 local bare_jid = event.occupant and event.occupant.bare_jid or event.bare_jid; |
14 local bare_jid = event.occupant and event.occupant.bare_jid or event.bare_jid; |
15 local aff_data = event.room:get_affiliation_data(bare_jid); |
15 local aff_data = event.room:get_affiliation_data(bare_jid); |
16 local hats = aff_data and aff_data.hats; |
16 local hats = aff_data and aff_data.hats; |
17 if not hats then return; end |
17 if not hats then return; end |
18 local hats_el; |
18 local hats_el; |
|
19 local legacy_hats_el; |
19 for hat_id, hat_data in pairs(hats) do |
20 for hat_id, hat_data in pairs(hats) do |
20 if hat_data.active then |
21 if hat_data.active then |
21 if not hats_el then |
22 if not hats_el then |
22 hats_el = st.stanza("hats", { xmlns = xmlns_hats }); |
23 hats_el = st.stanza("hats", { xmlns = xmlns_hats }); |
23 end |
24 end |
24 hats_el:tag("hat", { uri = hat_id, title = hat_data.title }):up(); |
25 hats_el:tag("hat", { uri = hat_id, title = hat_data.title }):up(); |
|
26 |
25 if hats_compat then |
27 if hats_compat then |
26 if not hats_el then |
28 if not hats_el then |
27 hats_el = st.stanza("hats", { xmlns = xmlns_hats_legacy }); |
29 legacy_hats_el = st.stanza("hats", { xmlns = xmlns_hats_legacy }); |
28 end |
30 end |
29 hats_el:tag("hat", { uri = hat_id, title = hat_data.title }):up(); |
31 legacy_hats_el:tag("hat", { uri = hat_id, title = hat_data.title }):up(); |
30 end |
32 end |
31 end |
33 end |
32 end |
34 end |
33 if not hats_el then return; end |
35 if not hats_el then return; end |
34 event.stanza:add_direct_child(hats_el); |
36 event.stanza:add_direct_child(hats_el); |
|
37 |
|
38 if legacy_hats_el then |
|
39 event.stanza:add_direct_child(legacy_hats_el); |
|
40 end |
35 end); |
41 end); |