Closed Bug 1377952 Opened 7 years ago Closed 5 years ago

Show Admins and Mods in the Joined Room.

Categories

(Chat Core :: Matrix, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Instantbird 72

People

(Reporter: matrixisreal, Assigned: clokep, Mentored)

References

Details

Attachments

(1 file, 3 obsolete files)

Admins are users with Power level 100 and Moderators with 50.
So we might map admins to founders and mods to ops.
Assignee: nobody → pavankarthikboddeda
Attached patch powers.patch (obsolete) — Splinter Review
Attachment #8883086 - Flags: feedback?(clokep)
Comment on attachment 8883086 [details] [diff] [review]
powers.patch

Review of attachment 8883086 [details] [diff] [review]:
-----------------------------------------------------------------

::: chat/protocols/matrix/matrix.js
@@ +23,5 @@
>  MatrixParticipant.prototype = {
>    __proto__: GenericConvChatBuddyPrototype,
>    get alias() { return this._roomMember.name; },
> +  get op() { return this._roomMember.powerLevel == 50; },
> +  get founder() { return this._roomMember.powerLevel == 100; },

Is it possible to have other power level values? If so, how about using "50 <= this._roomMember.powerLevel < 100" for op and "this._roomMember.powerLevel >= 100" for founder?

@@ +166,5 @@
>        }
>      });
> +    this._client.on("RoomMember.powerLevel", function(event, member) {
> +      // Has to be changed to
> +      // if (account.conversations.has(member.roomId))

I think you don't need to put this comment in the code. Just update the patch on the other bug when this one is merged.
Attachment #8883086 - Flags: feedback+
> 
> Is it possible to have other power level values? If so, how about using "50
> <= this._roomMember.powerLevel < 100" for op and
> "this._roomMember.powerLevel >= 100" for founder?
> 

Hi, 
Here I quote a small description on Power levels from https://matrix.org/docs/spec/client_server/r0.2.0.html#id153

"By default all users have a power level of 0, other than the room creator whose power level defaults to 100. Users can grant other users increased power levels up to their own power level."

So, power levels from "any negative number" to 100 are possible.
Then, we better use "50 <= this._roomMember.powerLevel < 100". Yeah!
But "this._roomMember.powerLevel == 100" is enough for founders.
 
> I think you don't need to put this comment in the code. Just update the
> patch on the other bug when this one is merged.

Hmm.. Yeah, working with different bugs on the same code is a bit confusing :P
Comment on attachment 8883086 [details] [diff] [review]
powers.patch

Review of attachment 8883086 [details] [diff] [review]:
-----------------------------------------------------------------

::: chat/protocols/matrix/matrix.js
@@ +23,5 @@
>  MatrixParticipant.prototype = {
>    __proto__: GenericConvChatBuddyPrototype,
>    get alias() { return this._roomMember.name; },
> +  get op() { return this._roomMember.powerLevel == 50; },
> +  get founder() { return this._roomMember.powerLevel == 100; },

From the description it sounds like the only formal power level is founder. Did you just use the 50 arbitrarily or is there some other app that uses that?

@@ +166,5 @@
>        }
>      });
> +    this._client.on("RoomMember.powerLevel", function(event, member) {
> +      // Has to be changed to
> +      // if (account.conversations.has(member.roomId))

Yeah, please don't include this here!
Attachment #8883086 - Flags: feedback?(clokep) → feedback+
Depends on: 1394397
Assignee: pavankarthikboddeda → nobody
Blocks: 1572636
Attached patch Patch v2 (obsolete) — Splinter Review

This implements ops/half-ops for Matrix.

I actually wrote this before realizing there was a patch on this bug already, but the implementation pretty much ended up being the same.

This:

To test this you can connect to Matrix and join "#test:matrix.org".

Assignee: nobody → clokep
Attachment #8883086 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #9104110 - Flags: review?(florian)
Attached patch Patch v2.1 (obsolete) — Splinter Review

Oops, eslint for an error I had missed when changing a normal function to an arrow function.

Attachment #9104110 - Attachment is obsolete: true
Attachment #9104110 - Flags: review?(florian)
Attachment #9104117 - Flags: review?(florian)
Attached patch Patch v3Splinter Review

Sorry for the noise. I found a bug on this while working on subsequent patches.

Attachment #9104117 - Attachment is obsolete: true
Attachment #9104117 - Flags: review?(florian)
Attachment #9104123 - Flags: review?(florian)
Comment on attachment 9104123 [details] [diff] [review]
Patch v3

Paul had expressed interest in taking a look at this.
Attachment #9104123 - Flags: review?(paul)
Comment on attachment 9104123 [details] [diff] [review]
Patch v3

Review of attachment 9104123 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me.  When logged in to a matrix chat account, I could see the yellow stars next to some participants in the room.
Attachment #9104123 - Flags: review?(paul) → review+
Attachment #9104123 - Flags: review?(florian)

Pushed by clokep@gmail.com:
https://hg.mozilla.org/comm-central/rev/5f93ed1690ab
Show Admins and Mods in Matrix rooms. r=pmorris

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Instantbird 72

Please note that nothing prevents someone having a powerlevel higher than 100. This is just the default for "founders". Some homeservers might have other values (or you can edit the DB to get a higher PL, but need to do so on every participating server).

So I'd have put return this._roomMember.powerLevelNorm >= 100;.

But matrix permissions are more complex, so founder == max power level in the room might be even better. Or just "founder" as anyone who has the right to change the permissions in the room (this._roomMember.powerLevelNorm >= m.room.power_levels, as seen set to 99 in the following example).

That said, the current implementation is fine for 99.5% of the rooms I am in, so feel free to ignore this to concentrate on more important stuff. I could try to submit a PR myself to flex the contribution pipeline.

{
  "type": "m.room.power_levels",
  "unsigned": {
    "replaces_state": "$1576229797338615onFBj:matrix.org",
    "prev_sender": "@mod1:mod1.org",
    "age": 104,
    "prev_content": {
     <...>
  },
  "event_id": "$01001010001FHeaZ:mod2.net",
  "origin_server_ts": 1576229992129,
  "content": {
    "ban": 50,
    "invite": 0,
    "events": {
      "m.room.topic": 50,
      "m.room.avatar": 50,
      "im.vector.modular.widgets": 50,
      "m.room.canonical_alias": 50,
      "m.room.power_levels": 99,
      "m.room.history_visibility": 100,
      "m.room.name": 50,
      "m.room.tombstone": 50,
      "m.room.encryption": 50
    },
    "kick": 50,
    "events_default": 0,
    "users_default": 0,
    "state_default": 50,
    "redact": 50,
    "users": {
      "@mod2:mod2.net": 100,
      "@mod1:mod1.org": 100
    }
  },
  "state_key": "",
  "sender": "@mod2:mod2.net",
  "room_id": "!theroomID:matrix.org"
}

Hi Mayeul! Thanks for taking an interest in some of the Matrix work! It is nice to have someone more familiar with the Matrix internals taking a look at it.

My understanding was that "power levels" can go to whatever, but the JavaScript SDK has a concept of "normalized" power levels (see docs: https://matrix-org.github.io/matrix-js-sdk/2.4.1/module-models_room-member.html). Unfortunately the docs don't have much information, so I kind of took a guess that it would be right "most" of the time. Does that make sense?

I think you're probably correct that a founder should be someone who has "all" the powers (can ban, invite, kick, redact, etc.), but I think the way it is shown in Thunderbird isn't specific enough since it just gives a relative power (nothing, silver star, gold star, flag) next to the user's name.

If this doesn't work in specific cases I'd be all for fixing it (and we should probably file a separate bug for that)!

Thanks again for your thoughts. I hope the above makes sense.

Flags: needinfo?(oss+mozilla)
Flags: needinfo?(oss+mozilla)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: