Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 1740:b37ccf9bec89
MUC: Send appropriate error to banned users on join.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 07 Sep 2009 20:27:52 +0500 |
| parents | 393abf245322 |
| children | 1483a62d69bb |
comparison
equal
deleted
inserted
replaced
| 1739:393abf245322 | 1740:b37ccf9bec89 |
|---|---|
| 255 if not new_nick then | 255 if not new_nick then |
| 256 log("debug", "%s couldn't join due to nick conflict: %s", from, to); | 256 log("debug", "%s couldn't join due to nick conflict: %s", from, to); |
| 257 origin.send(st.error_reply(stanza, "cancel", "conflict"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); | 257 origin.send(st.error_reply(stanza, "cancel", "conflict"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); |
| 258 else | 258 else |
| 259 log("debug", "%s joining as %s", from, to); | 259 log("debug", "%s joining as %s", from, to); |
| 260 local data; | |
| 261 -- if not rooms:get(room) and not rooms_info:get(room) then -- new room | |
| 262 -- rooms_info:set(room, 'name', (jid_split(room))); | |
| 263 -- data = {affiliation='owner', role='moderator', jid=from, sessions={[from]=get_filtered_presence(stanza)}}; | |
| 264 -- end | |
| 265 if not next(self._affiliations) then -- new room, no owners | 260 if not next(self._affiliations) then -- new room, no owners |
| 266 self._affiliations[jid_bare(from)] = "owner"; | 261 self._affiliations[jid_bare(from)] = "owner"; |
| 267 end | 262 end |
| 268 if not data then -- new occupant | 263 local affiliation = self:get_affiliation(from); |
| 269 local affiliation = self:get_affiliation(from); | 264 local role = self:get_default_role(affiliation) |
| 270 data = {affiliation=affiliation, role=self:get_default_role(affiliation), jid=from, sessions={[from]=get_filtered_presence(stanza)}}; | 265 if role then -- new occupant |
| 266 self._occupants[to] = {affiliation=affiliation, role=role, jid=from, sessions={[from]=get_filtered_presence(stanza)}}; | |
| 267 self._jid_nick[from] = to; | |
| 268 self:send_occupant_list(from); | |
| 269 pr.attr.from = to; | |
| 270 self:broadcast_presence(pr); | |
| 271 self:send_history(from); | |
| 272 else -- banned | |
| 273 origin.send(st.error_reply(stanza, "auth", "forbidden"):tag("x", {xmlns = "http://jabber.org/protocol/muc"})); | |
| 271 end | 274 end |
| 272 self._occupants[to] = data; | |
| 273 self._jid_nick[from] = to; | |
| 274 self:send_occupant_list(from); | |
| 275 pr.attr.from = to; | |
| 276 self:broadcast_presence(pr); | |
| 277 self:send_history(from); | |
| 278 end | 275 end |
| 279 end | 276 end |
| 280 elseif type ~= 'result' then -- bad type | 277 elseif type ~= 'result' then -- bad type |
| 281 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? | 278 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? |
| 282 end | 279 end |
