Mercurial > prosody-hg
comparison plugins/mod_muc.lua @ 818:4dda65cd1405
MUC: Various fixes
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 18 Feb 2009 23:30:33 +0500 |
| parents | e3e3919b6c7e |
| children | c20545c0dc4d |
comparison
equal
deleted
inserted
replaced
| 817:e3e3919b6c7e | 818:4dda65cd1405 |
|---|---|
| 114 function set_subject(current_nick, room, subject) | 114 function set_subject(current_nick, room, subject) |
| 115 -- TODO check nick's authority | 115 -- TODO check nick's authority |
| 116 if subject == "" then subject = nil; end | 116 if subject == "" then subject = nil; end |
| 117 rooms_info:set(room, 'subject', subject); | 117 rooms_info:set(room, 'subject', subject); |
| 118 save_room(); | 118 save_room(); |
| 119 local msg = st.message({type='groupchat', from=from}) | 119 local msg = st.message({type='groupchat', from=current_nick}) |
| 120 :tag('subject'):text(subject):up(); | 120 :tag('subject'):text(subject):up(); |
| 121 broadcast_message_stanza(room, msg, false); | 121 broadcast_message_stanza(room, msg, false); |
| 122 --broadcast_message(current_nick, room, subject or "", nil); | 122 --broadcast_message(current_nick, room, subject or "", nil); |
| 123 return true; | 123 return true; |
| 124 end | 124 end |
| 229 if stanza.name == "presence" then | 229 if stanza.name == "presence" then |
| 230 local pr = get_filtered_presence(stanza); | 230 local pr = get_filtered_presence(stanza); |
| 231 pr.attr.from = to; | 231 pr.attr.from = to; |
| 232 if type == "error" then -- error, kick em out! | 232 if type == "error" then -- error, kick em out! |
| 233 if current_nick then | 233 if current_nick then |
| 234 local data = rooms:get(room, to); | 234 local data = rooms:get(room, current_nick); |
| 235 data.role = 'none'; | 235 data.role = 'none'; |
| 236 local pr = st.presence({type='unavailable', from=current_nick}):tag('status'):text('This participant is kicked from the room because he sent an error presence'):up() | 236 local pr = st.presence({type='unavailable', from=current_nick}):tag('status'):text('This participant is kicked from the room because he sent an error presence'):up() |
| 237 :tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) | 237 --:tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) |
| 238 :tag("item", {affiliation=data.affiliation, role=data.role}):up(); | 238 --:tag("item", {affiliation=data.affiliation, role=data.role}):up(); |
| 239 broadcast_presence_stanza(room, pr); | 239 broadcast_presence_stanza(room, pr); |
| 240 --broadcast_presence('unavailable', to, room); -- TODO also add <status>This participant is kicked from the room because he sent an error presence: badformed error stanza</status> | 240 --broadcast_presence('unavailable', current_nick, room); -- TODO also add <status>This participant is kicked from the room because he sent an error presence: badformed error stanza</status> |
| 241 rooms:remove(room, to); | 241 rooms:remove(room, current_nick); |
| 242 jid_nick:remove(from, room); | 242 jid_nick:remove(from, room); |
| 243 end | 243 end |
| 244 elseif type == "unavailable" then -- unavailable | 244 elseif type == "unavailable" then -- unavailable |
| 245 if current_nick then | 245 if current_nick then |
| 246 local data = rooms:get(room, to); | 246 local data = rooms:get(room, current_nick); |
| 247 data.role = 'none'; | 247 data.role = 'none'; |
| 248 broadcast_presence_stanza(room, pr); | 248 broadcast_presence_stanza(room, pr); |
| 249 --broadcast_presence('unavailable', to, room); | 249 --broadcast_presence('unavailable', current_nick, room); |
| 250 rooms:remove(room, to); | 250 rooms:remove(room, current_nick); |
| 251 jid_nick:remove(from, room); | 251 jid_nick:remove(from, room); |
| 252 end | 252 end |
| 253 elseif not type then -- available | 253 elseif not type then -- available |
| 254 if current_nick then | 254 if current_nick then |
| 255 if current_nick == to then -- simple presence | 255 if current_nick == to then -- simple presence |
| 256 broadcast_presence_stanza(room, pr); | 256 if #pr == #stanza then |
| 257 -- FIXME check if something was filtered. if it was, then user may be rejoining | 257 broadcast_presence_stanza(room, pr); |
| 258 else -- possible rejoin | |
| 259 local pr_ = st.presence({type='unavailable', from=from, to=current_nick}):tag('status'):text('Replaced by new connection'); | |
| 260 handle_to_occupant(origin, pr_); -- send unavailable | |
| 261 handle_to_occupant(origin, pr); -- resend available | |
| 262 end | |
| 258 else -- change nick | 263 else -- change nick |
| 259 if rooms:get(room, to) then | 264 if rooms:get(room, to) then |
| 260 origin.send(st.error_reply(stanza, "cancel", "conflict")); | 265 origin.send(st.error_reply(stanza, "cancel", "conflict")); |
| 261 else | 266 else |
| 262 local data = rooms:get(room, current_nick); | 267 local data = rooms:get(room, current_nick); |
