X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fmuc.lua;h=badcffcedf0f3701b5c933b7fc3cfdd4250755e1;hb=7cde004ab530110577c5107636bc010576f29df1;hp=305157d832658970d7bac53ea91a92eea508e5c0;hpb=14b07e19c6db6eefe35fac05b1772e7ee9a74436;p=prosody.git diff --git a/util/muc.lua b/util/muc.lua index 305157d8..badcffce 100644 --- a/util/muc.lua +++ b/util/muc.lua @@ -1,4 +1,4 @@ --- Prosody IM v0.4 +-- Prosody IM -- Copyright (C) 2008-2009 Matthew Wild -- Copyright (C) 2008-2009 Waqas Hussain -- @@ -159,13 +159,13 @@ local function room_send_history(room, to) end end if room._data['subject'] then - room:route_stanza(st.message({type='groupchat', from=room, to=to}):tag("subject"):text(room._data['subject'])); + room:route_stanza(st.message({type='groupchat', from=room.jid, to=to}):tag("subject"):text(room._data['subject'])); end end local function room_get_disco_info(self, stanza) end local function room_get_disco_items(self, stanza) end -local function room_set_subject(room, current_nick, room, subject) +local function room_set_subject(room, current_nick, subject) -- TODO check nick's authority if subject == "" then subject = nil; end room._data['subject'] = subject; @@ -195,7 +195,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc log("debug", "%s leaving %s", current_nick, room); local data = self._participants[current_nick]; data.role = 'none'; - room_broadcast_presence(room, pr); + room_broadcast_presence(self, pr); self._participants[current_nick] = nil; self._jid_nick[from] = nil; end @@ -209,7 +209,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc else -- change nick if self._participants[to] then log("debug", "%s couldn't change nick", current_nick); - origin.send(st.error_reply(stanza, "cancel", "conflict")); + origin.send(st.error_reply(stanza, "cancel", "conflict"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); else local data = self._participants[current_nick]; local to_nick = select(3, jid_split(to)); @@ -240,7 +240,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc end if not new_nick then log("debug", "%s couldn't join due to nick conflict: %s", from, to); - origin.send(st.error_reply(stanza, "cancel", "conflict")); + origin.send(st.error_reply(stanza, "cancel", "conflict"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); else log("debug", "%s joining as %s", from, to); local data; @@ -262,7 +262,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc elseif type ~= 'result' then -- bad type origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? end - elseif not current_nick and type ~= "error" then -- not in room + elseif not current_nick and type ~= "error" and type ~= "result" then -- not in room origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM origin.send(st.error_reply(stanza, "modify", "bad-request")); @@ -274,7 +274,7 @@ local function room_handle_to_occupant(self, origin, stanza) -- PM, vCards, etc if o_data then log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid); local jid = o_data.jid; - if stanza.name=='iq' and type=='get' and stanza.tags[1].attr.xmlns == 'vcard-temp' then jid = jid_bare(jid); end + -- TODO if stanza.name=='iq' and type=='get' and stanza.tags[1].attr.xmlns == 'vcard-temp' then jid = jid_bare(jid); end stanza.attr.to, stanza.attr.from = jid, current_nick; self:route_stanza(stanza); elseif type ~= "error" and type ~= "result" then -- recipient not in room @@ -315,7 +315,7 @@ local function room_handle_to_room(self, origin, stanza) -- presence changes and local current_nick = self._jid_nick[stanza.attr.from]; if current_nick then stanza.attr.to = current_nick; - room_handle_to_occupant(origin, stanza); + room_handle_to_occupant(self, origin, stanza); stanza.attr.to = to; elseif type ~= "error" and type ~= "result" then origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); @@ -338,14 +338,10 @@ end local function room_handle_stanza(self, origin, stanza) local to_node, to_host, to_resource = jid_split(stanza.attr.to); - if to_resource and not to_node then - if type == "error" or type == "result" then return; end - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- host/resource - elseif to_resource then + if to_resource then room_handle_to_occupant(self, origin, stanza); - elseif to_node then - room_handle_to_room(self, origin, stanza) - else -- to the main muc domain + else + room_handle_to_room(self, origin, stanza); end end