Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 6113:f535f7de44b6
plugins/muc/muc.lib: Remove unused methods (breaks api)
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Wed, 19 Mar 2014 13:56:14 -0400 |
| parents | 819e00a86239 |
| children | 055efbb6d10c |
comparison
equal
deleted
inserted
replaced
| 6112:819e00a86239 | 6113:f535f7de44b6 |
|---|---|
| 652 stanza.attr.to = jid; | 652 stanza.attr.to = jid; |
| 653 self:_route_stanza(stanza); | 653 self:_route_stanza(stanza); |
| 654 end | 654 end |
| 655 stanza.attr.from, stanza.attr.to = from, to; | 655 stanza.attr.from, stanza.attr.to = from, to; |
| 656 return true; | 656 return true; |
| 657 end | |
| 658 | |
| 659 function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc | |
| 660 local from, to = stanza.attr.from, stanza.attr.to; | |
| 661 local room = jid_bare(to); | |
| 662 local current_nick = self._jid_nick[from]; | |
| 663 log("debug", "room: %s, current_nick: %s, stanza: %s", room or "nil", current_nick or "nil", stanza:top_tag()); | |
| 664 if (select(2, jid_split(from)) == muc_domain) then error("Presence from the MUC itself!!!"); end | |
| 665 if stanza.name == "presence" then | |
| 666 return self:handle_presence_to_occupant(origin, stanza) | |
| 667 elseif stanza.name == "iq" then | |
| 668 return self:handle_iq_to_occupant(origin, stanza) | |
| 669 elseif stanza.name == "message" then | |
| 670 return self:handle_message_to_occupant(origin, stanza) | |
| 671 end | |
| 672 end | 657 end |
| 673 | 658 |
| 674 function room_mt:send_form(origin, stanza) | 659 function room_mt:send_form(origin, stanza) |
| 675 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner") | 660 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner") |
| 676 :add_child(self:get_form_layout(stanza.attr.from):form()) | 661 :add_child(self:get_form_layout(stanza.attr.from):form()) |
| 951 self:process_form(origin, stanza); | 936 self:process_form(origin, stanza); |
| 952 return true; | 937 return true; |
| 953 end | 938 end |
| 954 end | 939 end |
| 955 | 940 |
| 956 function room_mt:handle_iq_to_room(origin, stanza) | |
| 957 local type = stanza.attr.type; | |
| 958 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; | |
| 959 if xmlns == "http://jabber.org/protocol/disco#info" and type == "get" and not stanza.tags[1].attr.node then | |
| 960 return self:handle_disco_info_get_query(origin, stanza) | |
| 961 elseif xmlns == "http://jabber.org/protocol/disco#items" and type == "get" and not stanza.tags[1].attr.node then | |
| 962 return self:handle_disco_items_get_query(origin, stanza) | |
| 963 elseif xmlns == "http://jabber.org/protocol/muc#admin" then | |
| 964 local item = stanza.tags[1].tags[1]; | |
| 965 if item and item.name == "item" then | |
| 966 if type == "set" then | |
| 967 return self:handle_admin_item_set_command(origin, stanza) | |
| 968 elseif type == "get" then | |
| 969 return self:handle_admin_item_get_command(origin, stanza) | |
| 970 end | |
| 971 elseif type == "set" or type == "get" then | |
| 972 origin.send(st.error_reply(stanza, "cancel", "bad-request")); | |
| 973 return true; | |
| 974 end | |
| 975 elseif xmlns == "http://jabber.org/protocol/muc#owner" and (type == "get" or type == "set") and stanza.tags[1].name == "query" then | |
| 976 if stanza.attr.type == "get" then | |
| 977 return self:handle_owner_query_get_to_room(origin, stanza) | |
| 978 elseif stanza.attr.type == "set" then | |
| 979 return self:handle_owner_query_set_to_room(origin, stanza) | |
| 980 end | |
| 981 else | |
| 982 return nil; | |
| 983 end | |
| 984 end | |
| 985 | |
| 986 function room_mt:handle_groupchat_to_room(origin, stanza) | 941 function room_mt:handle_groupchat_to_room(origin, stanza) |
| 987 local from = stanza.attr.from; | 942 local from = stanza.attr.from; |
| 988 local current_nick = self._jid_nick[from]; | 943 local current_nick = self._jid_nick[from]; |
| 989 local occupant = self._occupants[current_nick]; | 944 local occupant = self._occupants[current_nick]; |
| 990 if not occupant then -- not in room | 945 if not occupant then -- not in room |
| 1109 else | 1064 else |
| 1110 return nil; | 1065 return nil; |
| 1111 end | 1066 end |
| 1112 end | 1067 end |
| 1113 | 1068 |
| 1114 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc | |
| 1115 if stanza.name == "iq" then | |
| 1116 return self:handle_iq_to_room(origin, stanza) | |
| 1117 elseif stanza.name == "message" then | |
| 1118 return self:handle_message_to_room(origin, stanza) | |
| 1119 elseif stanza.name == "presence" then | |
| 1120 return self:handle_presence_to_room(origin, stanza) | |
| 1121 end | |
| 1122 end | |
| 1123 | |
| 1124 function room_mt:handle_stanza(origin, stanza) | |
| 1125 local to_node, to_host, to_resource = jid_split(stanza.attr.to); | |
| 1126 local handled | |
| 1127 if to_resource then | |
| 1128 handled = self:handle_to_occupant(origin, stanza); | |
| 1129 else | |
| 1130 handled = self:handle_to_room(origin, stanza); | |
| 1131 end | |
| 1132 | |
| 1133 if not handled then | |
| 1134 local type = stanza.attr.type | |
| 1135 if stanza.name ~= "iq" or type == "get" or type == "set" then | |
| 1136 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | |
| 1137 end | |
| 1138 end | |
| 1139 end | |
| 1140 | |
| 1141 function room_mt:route_stanza(stanza) | 1069 function room_mt:route_stanza(stanza) |
| 1142 module:send(stanza) | 1070 module:send(stanza) |
| 1143 end | 1071 end |
| 1144 | 1072 |
| 1145 function room_mt:get_affiliation(jid) | 1073 function room_mt:get_affiliation(jid) |
