-
-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add maySendStateEvent method, ported from react-sdk (but fixed). #94
Conversation
(Jenkins is broken) |
var user_levels = []; | ||
var current_user_level = 0; | ||
|
||
var state_default = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this 0
, but 50
at line 262? it is odd that the required power level is 50
if there is an m.room.power_levels
with no state_default
, but 0
if there is no m.room.power_levels
at all
(It is also odd that the spec doesn't clarify this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so in this case I'd like your opinion on matrix-org/matrix-spec-proposals#286 which is where I'm fixing the spec to document the default levels. I think it's a bug in synapse that the default is 0 with no power levels event, but apparently this is now baked into room history so we have to make the spec fit the bug.
It is not the easiest to follow bit of code, but looks ok to me modulo the above comment |
A quick thought: could we make this |
Could do: my plan was probably to make a separate maySendEvent function if necessary and then probably back both functions with the same one internally. Either way it's a backwards compatible change (assuming you'd add the param to the end). |
Just trying to fend off having to support three functions in the js-sdk API forever. No strong feelings here though. |
* according to the room's state. | ||
*/ | ||
RoomState.prototype.maySendStateEvent = function(stateEventType, userId) { | ||
if (!this.getMember(userId)) { return false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only tests for presence of m.room.member
events. This will return a RoomMember
with membership = leave
if they leave the room.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also help yourself by using RoomMember.powerLevel
to get the actual power level of that member, which already takes into account users_default
and explicit users
entries.
Add maySendStateEvent method, ported from react-sdk (but fixed).
Plus tests.