On Thu, May 17, 2018 at 05:24:38PM +0200, Jonas Wielicki wrote:
> # HG changeset patch
> # User Jonas Wielicki <[email protected]>
> # Date 1526569860 -7200
> # Thu May 17 17:11:00 2018 +0200
> # Node ID b828db4432de0ab634b4d44dd8880a969727e3bc
> # Parent aaff40ec700128306b1b843247a098b5d291bb87
> MUC: fix set_role invocation
>
> diff -r aaff40ec7001 -r b828db4432de plugins/muc/muc.lib.lua
> --- a/plugins/muc/muc.lib.lua Wed May 16 23:57:30 2018 +0100
> +++ b/plugins/muc/muc.lib.lua Thu May 17 17:11:00 2018 +0200
> @@ -852,7 +852,7 @@
> if item.attr.affiliation and
> item.attr.jid and not item.attr.role then
> jid_affiliation[item.attr.jid]
> = { ["affiliation"] = item.attr.affiliation, ["reason"] = reason };
> elseif item.attr.role and
> item.attr.nick and not item.attr.affiliation then
> -
> jidnick_role[item.attr.jid.."/"..item.attr.nick] = { ["role"] =
> item.attr.role, ["reason"] = reason };
> +
> jidnick_role[self.jid.."/"..item.attr.nick] = { ["role"] = item.attr.role,
> ["reason"] = reason };
> else
>
> origin.send(st.error_reply(stanza, "cancel", "bad-request"));
> return;
> @@ -1213,7 +1213,8 @@
> --- Checks whether the given role changes in jidnick_role can be applied by
> actor.
> -- Note: Empty tables can always be applied and won't have any effect.
> function room_mt:can_set_roles(actor, jidnick_role)
> - for jidnick, role in pairs(jidnick_role) do
> + for jidnick, role_info in pairs(jidnick_role) do
> + local role = role_info["role"];
Consider this line here:
> if role == "none" then role = nil; end
> if role and role ~= "moderator" and role ~= "participant" and
> role ~= "visitor" then return false, "modify", "not-acceptable"; end
> local can_set, err_type, err_condition =
> self:can_set_role(actor, jidnick, role)
> @@ -1249,7 +1250,7 @@
> :tag("reason"):text(reason or ""):up()
> :up();
> local presence_type = nil;
Is this really necessary, given the above?
> - if not role then -- kick
> + if not role or role == "none" then -- kick
> presence_type = "unavailable";
> self._occupants[occupant_jid] = nil;
> for jid in pairs(occupant.sessions) do -- remove for
> all sessions of the nick
> @@ -1271,7 +1272,7 @@
> if occupant.jid == jid then
> bp = st.clone(p);
> bp:add_child(x);
> - modified_nicks[occupant_jid] = p;
> + modified_nicks[occupant_jid] = bp;
> nb_modified_nicks = nb_modified_nicks + 1;
> end
> p:add_child(self_x);
>
> --
> You received this message because you are subscribed to the Google Groups
> "prosody-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/prosody-dev.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.