| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-04-22 19:06:57 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-04-22 19:06:57 UTC |
| parent | 510b2a116fbe76c1484e93c660b44169fb880e80 |
| borogove/Chat.hx | +32 | -0 |
diff --git a/borogove/Chat.hx b/borogove/Chat.hx index e4780fb..7dfff8f 100644 --- a/borogove/Chat.hx +++ b/borogove/Chat.hx @@ -232,6 +232,13 @@ abstract class Chat { return []; } + /** + Can the current user remove this role from the participant? + **/ + public function canRemoveRole(participantId: String, role: Role):Bool { + return false; + } + /** Add a role to a participant **/ @@ -1777,6 +1784,31 @@ trace("XYZZY no MUC avatar locally matching so fetch vcard", chatId, avatarSha1H return []; } + override public function canRemoveRole(participantId: String, role: Role):Bool { + if (_nickInUse == null) return false; + + final p = presence[_nickInUse]; + if (p?.mucUser == null) return false; + + final pjid = JID.parse(participantId); + final pnick = pjid.resource; + final ppresence = presence[pnick]; + if (ppresence?.mucUser == null) return false; + if (ppresence?.mucUser?.jid == null) return false; + + if (p.mucUser.affiliation == "owner") { + return ["owner", "admin", "member", "outcast"].contains(role.id); + } + + if (p.mucUser.affiliation == "admin") { + if (ppresence.mucUser.affiliation == "owner") return false; + + return ["admin", "member", "outcast"].contains(role.id); + } + + return false; + } + override public function addRole(participantId: String, role: Role) { final pjid = JID.parse(participantId); final pnick = pjid.resource;