Comparison

plugins/muc/muc.lib.lua @ 6123:7f82bbd249fe

plugins/muc/muc.lib: Remove `payload` argument from `handle_mediated_*`; extract it from inside.
author daurnimator <quae@daurnimator.com>
date Wed, 19 Mar 2014 16:28:11 -0400
parent 6122:44a846744814
child 6124:203f2b4933b0
comparison
equal deleted inserted replaced
6122:44a846744814 6123:7f82bbd249fe
981 stanza.attr.to = to; 981 stanza.attr.to = to;
982 end 982 end
983 return handled; 983 return handled;
984 end 984 end
985 985
986 function room_mt:handle_mediated_invite(origin, stanza, payload) 986 function room_mt:handle_mediated_invite(origin, stanza)
987 local payload = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite")
987 local _from, _to = stanza.attr.from, stanza.attr.to; 988 local _from, _to = stanza.attr.from, stanza.attr.to;
988 local current_nick = self:get_occupant_jid(_from) 989 local current_nick = self:get_occupant_jid(_from)
989 if not current_nick then -- Should be in room to send invite TODO: allow admins to send at any time 990 if not current_nick then -- Should be in room to send invite TODO: allow admins to send at any time
990 origin.send(st.error_reply(stanza, "auth", "forbidden")); 991 origin.send(st.error_reply(stanza, "auth", "forbidden"));
991 return true; 992 return true;
1028 log("debug", "%s invited %s into members only room %s, granting membership", from, invitee, room.jid); 1029 log("debug", "%s invited %s into members only room %s, granting membership", from, invitee, room.jid);
1029 room:set_affiliation(from, invitee, "member", nil, "Invited by " .. current_nick) 1030 room:set_affiliation(from, invitee, "member", nil, "Invited by " .. current_nick)
1030 end 1031 end
1031 end) 1032 end)
1032 1033
1033 function room_mt:handle_mediated_decline(origin, stanza, payload) 1034 function room_mt:handle_mediated_decline(origin, stanza)
1035 local payload = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline")
1034 local declinee = jid_prep(payload.attr.to); 1036 local declinee = jid_prep(payload.attr.to);
1035 if declinee then 1037 if declinee then
1036 local from, to = stanza.attr.from, stanza.attr.to; 1038 local from, to = stanza.attr.from, stanza.attr.to;
1037 -- TODO: Validate declinee 1039 -- TODO: Validate declinee
1038 local reason = payload:get_child_text("reason") 1040 local reason = payload:get_child_text("reason")
1064 if x then 1066 if x then
1065 local payload = x.tags[1]; 1067 local payload = x.tags[1];
1066 if payload == nil then 1068 if payload == nil then
1067 -- fallthrough 1069 -- fallthrough
1068 elseif payload.name == "invite" and payload.attr.to then 1070 elseif payload.name == "invite" and payload.attr.to then
1069 return self:handle_mediated_invite(origin, stanza, payload) 1071 return self:handle_mediated_invite(origin, stanza)
1070 elseif payload.name == "decline" and payload.attr.to then 1072 elseif payload.name == "decline" and payload.attr.to then
1071 return self:handle_mediated_decline(origin, stanza, payload) 1073 return self:handle_mediated_decline(origin, stanza)
1072 end 1074 end
1073 origin.send(st.error_reply(stanza, "cancel", "bad-request")); 1075 origin.send(st.error_reply(stanza, "cancel", "bad-request"));
1074 return true; 1076 return true;
1075 end 1077 end
1076 else 1078 else