--- Prosody IM v0.4
+-- Prosody IM
-- Copyright (C) 2008-2009 Matthew Wild
-- Copyright (C) 2008-2009 Waqas Hussain
--
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;
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
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));
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;
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"));
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
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"));
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