Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 7705:0a29a5e64f1d
mod_muc/muc.lib: Allow passing different <x> elements to be passed to :publicise_occupant_status()
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 26 Oct 2016 13:06:08 +0200 |
parent | 7686:8d6f367bed8c |
child | 7706:d92e186c2a1c |
comparison
equal
deleted
inserted
replaced
7704:5022e6181193 | 7705:0a29a5e64f1d |
---|---|
189 end | 189 end |
190 end | 190 end |
191 | 191 |
192 -- Broadcasts an occupant's presence to the whole room | 192 -- Broadcasts an occupant's presence to the whole room |
193 -- Takes the x element that goes into the stanzas | 193 -- Takes the x element that goes into the stanzas |
194 function room_mt:publicise_occupant_status(occupant, base_x, nick, actor, reason) | 194 function room_mt:publicise_occupant_status(occupant, x, nick, actor, reason) |
195 local base_x = x.base or x; | |
195 -- Build real jid and (optionally) occupant jid template presences | 196 -- Build real jid and (optionally) occupant jid template presences |
196 local base_presence do | 197 local base_presence do |
197 -- Try to use main jid's presence | 198 -- Try to use main jid's presence |
198 local pr = occupant:get_presence(); | 199 local pr = occupant:get_presence(); |
199 if pr and (pr.attr.type ~= "unavailable" and occupant.role ~= nil) then | 200 if pr and (pr.attr.type ~= "unavailable" and occupant.role ~= nil) then |
224 end | 225 end |
225 | 226 |
226 local full_p, full_x; | 227 local full_p, full_x; |
227 local function get_full_p() | 228 local function get_full_p() |
228 if full_p == nil then | 229 if full_p == nil then |
229 full_x = st.clone(base_x); | 230 full_x = st.clone(x.full or base_x); |
230 self:build_item_list(occupant, full_x, false, nick, actor_nick, actor, reason); | 231 self:build_item_list(occupant, full_x, false, nick, actor_nick, actor, reason); |
231 full_p = st.clone(base_presence):add_child(full_x); | 232 full_p = st.clone(base_presence):add_child(full_x); |
232 end | 233 end |
233 return full_p, full_x; | 234 return full_p, full_x; |
234 end | 235 end |
235 | 236 |
236 local anon_p, anon_x; | 237 local anon_p, anon_x; |
237 local function get_anon_p() | 238 local function get_anon_p() |
238 if anon_p == nil then | 239 if anon_p == nil then |
239 anon_x = st.clone(base_x); | 240 anon_x = st.clone(x.anon or base_x); |
240 self:build_item_list(occupant, anon_x, true, nick, actor_nick, nil, reason); | 241 self:build_item_list(occupant, anon_x, true, nick, actor_nick, nil, reason); |
241 anon_p = st.clone(base_presence):add_child(anon_x); | 242 anon_p = st.clone(base_presence):add_child(anon_x); |
242 end | 243 end |
243 return anon_p, anon_x; | 244 return anon_p, anon_x; |
244 end | 245 end |
247 if can_see_real_jids(whois, occupant) then | 248 if can_see_real_jids(whois, occupant) then |
248 self_p, self_x = get_full_p(); | 249 self_p, self_x = get_full_p(); |
249 else | 250 else |
250 -- Can always see your own full jids | 251 -- Can always see your own full jids |
251 -- But not allowed to see actor's | 252 -- But not allowed to see actor's |
252 self_x = st.clone(base_x); | 253 self_x = st.clone(x.self or base_x); |
253 self:build_item_list(occupant, self_x, false, nick, actor_nick, nil, reason); | 254 self:build_item_list(occupant, self_x, false, nick, actor_nick, nil, reason); |
254 self_p = st.clone(base_presence):add_child(self_x); | 255 self_p = st.clone(base_presence):add_child(self_x); |
255 end | 256 end |
256 | 257 |
257 -- General populance | 258 -- General populance |