Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 6099:c8a749298d51
plugins/muc/muc.lib: Make use of return values to send service-unavailable errors
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Fri, 21 Feb 2014 17:52:40 -0500 |
| parents | 1d7e5d091980 |
| children | c78ba94d3261 |
comparison
equal
deleted
inserted
replaced
| 6098:1d7e5d091980 | 6099:c8a749298d51 |
|---|---|
| 980 if stanza.attr.type == "get" then | 980 if stanza.attr.type == "get" then |
| 981 return self:handle_owner_query_get_to_room(origin, stanza) | 981 return self:handle_owner_query_get_to_room(origin, stanza) |
| 982 elseif stanza.attr.type == "set" then | 982 elseif stanza.attr.type == "set" then |
| 983 return self:handle_owner_query_set_to_room(origin, stanza) | 983 return self:handle_owner_query_set_to_room(origin, stanza) |
| 984 end | 984 end |
| 985 elseif type == "set" or type == "get" then | 985 else |
| 986 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | 986 return nil; |
| 987 return true; | |
| 988 end | 987 end |
| 989 end | 988 end |
| 990 | 989 |
| 991 function room_mt:handle_groupchat_to_room(origin, stanza) | 990 function room_mt:handle_groupchat_to_room(origin, stanza) |
| 992 local from = stanza.attr.from; | 991 local from = stanza.attr.from; |
| 1033 local to = stanza.attr.to; | 1032 local to = stanza.attr.to; |
| 1034 stanza.attr.to = current_nick; | 1033 stanza.attr.to = current_nick; |
| 1035 self:handle_to_occupant(origin, stanza); | 1034 self:handle_to_occupant(origin, stanza); |
| 1036 stanza.attr.to = to; | 1035 stanza.attr.to = to; |
| 1037 return true; | 1036 return true; |
| 1038 elseif type ~= "error" and type ~= "result" then | 1037 else |
| 1039 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | 1038 return nil; |
| 1040 return true; | |
| 1041 end | 1039 end |
| 1042 end | 1040 end |
| 1043 | 1041 |
| 1044 function room_mt:handle_invite_to_room(origin, stanza, payload) | 1042 function room_mt:handle_invite_to_room(origin, stanza, payload) |
| 1045 local _from, _to = stanza.attr.from, stanza.attr.to; | 1043 local _from, _to = stanza.attr.from, stanza.attr.to; |
| 1088 else | 1086 else |
| 1089 origin.send(st.error_reply(stanza, "cancel", "bad-request")); | 1087 origin.send(st.error_reply(stanza, "cancel", "bad-request")); |
| 1090 return true; | 1088 return true; |
| 1091 end | 1089 end |
| 1092 else | 1090 else |
| 1093 if type == "error" or type == "result" then return; end | 1091 return nil; |
| 1094 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | |
| 1095 return true; | |
| 1096 end | 1092 end |
| 1097 end | 1093 end |
| 1098 | 1094 |
| 1099 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc | 1095 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc |
| 1100 if stanza.name == "iq" then | 1096 if stanza.name == "iq" then |
| 1106 end | 1102 end |
| 1107 end | 1103 end |
| 1108 | 1104 |
| 1109 function room_mt:handle_stanza(origin, stanza) | 1105 function room_mt:handle_stanza(origin, stanza) |
| 1110 local to_node, to_host, to_resource = jid_split(stanza.attr.to); | 1106 local to_node, to_host, to_resource = jid_split(stanza.attr.to); |
| 1107 local handled | |
| 1111 if to_resource then | 1108 if to_resource then |
| 1112 self:handle_to_occupant(origin, stanza); | 1109 handled = self:handle_to_occupant(origin, stanza); |
| 1113 else | 1110 else |
| 1114 self:handle_to_room(origin, stanza); | 1111 handled = self:handle_to_room(origin, stanza); |
| 1112 end | |
| 1113 | |
| 1114 if not handled then | |
| 1115 local type = stanza.attr.type | |
| 1116 if stanza.name ~= "iq" or type == "get" or type == "set" then | |
| 1117 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | |
| 1118 end | |
| 1115 end | 1119 end |
| 1116 end | 1120 end |
| 1117 | 1121 |
| 1118 function room_mt:route_stanza(stanza) end -- Replace with a routing function, e.g., function(room, stanza) core_route_stanza(origin, stanza); end | 1122 function room_mt:route_stanza(stanza) end -- Replace with a routing function, e.g., function(room, stanza) core_route_stanza(origin, stanza); end |
| 1119 | 1123 |
