Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 1750:a1c18470eeee
MUC: Fixed: Unavailable presence was being sent for all role and affiliation changes. Now sent only for kicked occupants.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 07 Sep 2009 20:41:42 +0500 |
| parents | cf2ade983e12 |
| children | 55ee6e792e3e |
comparison
equal
deleted
inserted
replaced
| 1749:cf2ade983e12 | 1750:a1c18470eeee |
|---|---|
| 443 end | 443 end |
| 444 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end | 444 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end |
| 445 if jid_bare(actor) == jid then return nil, "cancel", "not-allowed"; end | 445 if jid_bare(actor) == jid then return nil, "cancel", "not-allowed"; end |
| 446 self._affiliations[jid] = affiliation; | 446 self._affiliations[jid] = affiliation; |
| 447 local role = self:get_default_role(affiliation); | 447 local role = self:get_default_role(affiliation); |
| 448 local p = st.presence({type = "unavailable"}) | 448 local p = st.presence() |
| 449 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 449 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
| 450 :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up(); | 450 :tag("item", {affiliation=affiliation or "none", role=role or "none"}):up(); |
| 451 local x = p.tags[1]; | 451 local x = p.tags[1]; |
| 452 local item = x.tags[1]; | 452 local item = x.tags[1]; |
| 453 if not role then -- getting kicked | 453 if not role then -- getting kicked |
| 454 p.attr.type = "unavailable"; | |
| 454 if affiliation == "outcast" then | 455 if affiliation == "outcast" then |
| 455 x:tag("status", {code="301"}):up(); -- banned | 456 x:tag("status", {code="301"}):up(); -- banned |
| 456 else | 457 else |
| 457 x:tag("status", {code="321"}):up(); -- affiliation change | 458 x:tag("status", {code="321"}):up(); -- affiliation change |
| 458 end | 459 end |
| 490 if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end | 491 if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end |
| 491 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end | 492 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end |
| 492 local occupant = self._occupants[nick]; | 493 local occupant = self._occupants[nick]; |
| 493 if not occupant then return nil, "modify", "not-acceptable"; end | 494 if not occupant then return nil, "modify", "not-acceptable"; end |
| 494 if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end | 495 if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end |
| 495 local p = st.presence({from = nick, type = "unavailable"}) | 496 local p = st.presence({from = nick}) |
| 496 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 497 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
| 497 :tag("item", {affiliation=occupant.affiliation or "none", nick=nick, role=role or "none"}):up(); | 498 :tag("item", {affiliation=occupant.affiliation or "none", nick=nick, role=role or "none"}):up(); |
| 498 if not role then -- kick | 499 if not role then -- kick |
| 500 p.attr.type = "unavailable"; | |
| 499 self._occupants[nick] = nil; | 501 self._occupants[nick] = nil; |
| 500 for jid in pairs(occupant.sessions) do -- remove for all sessions of the nick | 502 for jid in pairs(occupant.sessions) do -- remove for all sessions of the nick |
| 501 self._jid_nick[jid] = nil; | 503 self._jid_nick[jid] = nil; |
| 502 end | 504 end |
| 503 p:tag("status", {code = "307"}):up(); | 505 p:tag("status", {code = "307"}):up(); |
