Comparison

plugins/muc/muc.lib.lua @ 6098:1d7e5d091980

plugins/muc/muc.lib: Add some missing return values
author daurnimator <quae@daurnimator.com>
date Fri, 21 Feb 2014 17:40:16 -0500
parent 6097:538cdc3d8225
child 6099:c8a749298d51
comparison
equal deleted inserted replaced
6097:538cdc3d8225 6098:1d7e5d091980
992 local from = stanza.attr.from; 992 local from = stanza.attr.from;
993 local current_nick = self._jid_nick[from]; 993 local current_nick = self._jid_nick[from];
994 local occupant = self._occupants[current_nick]; 994 local occupant = self._occupants[current_nick];
995 if not occupant then -- not in room 995 if not occupant then -- not in room
996 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 996 origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
997 return true;
997 elseif occupant.role == "visitor" then 998 elseif occupant.role == "visitor" then
998 origin.send(st.error_reply(stanza, "auth", "forbidden")); 999 origin.send(st.error_reply(stanza, "auth", "forbidden"));
1000 return true;
999 else 1001 else
1000 local from = stanza.attr.from; 1002 local from = stanza.attr.from;
1001 stanza.attr.from = current_nick; 1003 stanza.attr.from = current_nick;
1002 local subject = stanza:get_child_text("subject"); 1004 local subject = stanza:get_child_text("subject");
1003 if subject then 1005 if subject then
1010 end 1012 end
1011 else 1013 else
1012 self:broadcast_message(stanza, self:get_historylength() > 0 and stanza:get_child("body")); 1014 self:broadcast_message(stanza, self:get_historylength() > 0 and stanza:get_child("body"));
1013 end 1015 end
1014 stanza.attr.from = from; 1016 stanza.attr.from = from;
1017 return true;
1015 end 1018 end
1016 end 1019 end
1017 1020
1018 function room_mt:handle_kickable_to_room(origin, stanza) 1021 function room_mt:handle_kickable_to_room(origin, stanza)
1019 local current_nick = self._jid_nick[stanza.attr.from]; 1022 local current_nick = self._jid_nick[stanza.attr.from];
1020 log("debug", "%s kicked from %s for sending an error message", current_nick, self.jid); 1023 log("debug", "%s kicked from %s for sending an error message", current_nick, self.jid);
1021 self:handle_to_occupant(origin, build_unavailable_presence_from_error(stanza)); -- send unavailable 1024 self:handle_to_occupant(origin, build_unavailable_presence_from_error(stanza)); -- send unavailable
1025 return true;
1022 end 1026 end
1023 1027
1024 -- hack - some buggy clients send presence updates to the room rather than their nick 1028 -- hack - some buggy clients send presence updates to the room rather than their nick
1025 function room_mt:handle_presence_to_room(origin, stanza) 1029 function room_mt:handle_presence_to_room(origin, stanza)
1026 local type = stanza.attr.type; 1030 local type = stanza.attr.type;
1028 if current_nick then 1032 if current_nick then
1029 local to = stanza.attr.to; 1033 local to = stanza.attr.to;
1030 stanza.attr.to = current_nick; 1034 stanza.attr.to = current_nick;
1031 self:handle_to_occupant(origin, stanza); 1035 self:handle_to_occupant(origin, stanza);
1032 stanza.attr.to = to; 1036 stanza.attr.to = to;
1037 return true;
1033 elseif type ~= "error" and type ~= "result" then 1038 elseif type ~= "error" and type ~= "result" then
1034 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 1039 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
1040 return true;
1035 end 1041 end
1036 end 1042 end
1037 1043
1038 function room_mt:handle_invite_to_room(origin, stanza, payload) 1044 function room_mt:handle_invite_to_room(origin, stanza, payload)
1039 local _from, _to = stanza.attr.from, stanza.attr.to; 1045 local _from, _to = stanza.attr.from, stanza.attr.to;
1058 if self:get_members_only() and not self:get_affiliation(_invitee) then 1064 if self:get_members_only() and not self:get_affiliation(_invitee) then
1059 log("debug", "%s invited %s into members only room %s, granting membership", _from, _invitee, _to); 1065 log("debug", "%s invited %s into members only room %s, granting membership", _from, _invitee, _to);
1060 self:set_affiliation(_from, _invitee, "member", nil, "Invited by " .. self._jid_nick[_from]) 1066 self:set_affiliation(_from, _invitee, "member", nil, "Invited by " .. self._jid_nick[_from])
1061 end 1067 end
1062 self:_route_stanza(invite); 1068 self:_route_stanza(invite);
1069 return true;
1063 else 1070 else
1064 origin.send(st.error_reply(stanza, "cancel", "jid-malformed")); 1071 origin.send(st.error_reply(stanza, "cancel", "jid-malformed"));
1072 return true;
1065 end 1073 end
1066 end 1074 end
1067 1075
1068 function room_mt:handle_message_to_room(origin, stanza) 1076 function room_mt:handle_message_to_room(origin, stanza)
1069 local type = stanza.attr.type; 1077 local type = stanza.attr.type;
1077 local payload = (#x.tags == 1 and x.tags[1]); 1085 local payload = (#x.tags == 1 and x.tags[1]);
1078 if payload and payload.name == "invite" and payload.attr.to then 1086 if payload and payload.name == "invite" and payload.attr.to then
1079 return self:handle_invite_to_room(origin, stanza, payload) 1087 return self:handle_invite_to_room(origin, stanza, payload)
1080 else 1088 else
1081 origin.send(st.error_reply(stanza, "cancel", "bad-request")); 1089 origin.send(st.error_reply(stanza, "cancel", "bad-request"));
1090 return true;
1082 end 1091 end
1083 else 1092 else
1084 if type == "error" or type == "result" then return; end 1093 if type == "error" or type == "result" then return; end
1085 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 1094 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
1095 return true;
1086 end 1096 end
1087 end 1097 end
1088 1098
1089 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc 1099 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc
1090 if stanza.name == "iq" then 1100 if stanza.name == "iq" then