Fix permission detection for updating emojis #1125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #1069
Issue: When the emoji pack state event has a different permission level than the base room event permission level, Cinny incorrectly determines the permission level required to send the event. This can lead to situations where the user should be able to edit the emojis but is told by cinny that they can not (as reported in the original issue) or to situations where Cinny's UI indicates that the user should be able to edit emojis, but encounters an error when they try to send the event, because they lack permissions.
Diagnosis: The
RoomEmojis
molecule incorrectly checks the user's power level against the default level for state events.Resolution: Rather than independently getting the user's powerlevel then checking it against the state event level using
hasSufficientPowerLevelFor()
, use the built-in methodmaySendStateEvent()
to check whetherim.ponies.room_emote
. This appears to be the intended method for determining whether the user may send a state event such as this one.Design Decisions / Future Work: This solution hard-codes the
im.ponies.room_emote
event name despite the fact that it is only a temporary name for this state event. The eventual migration to a finalized event name is considered by this author to be a separate issue, however, and one which will require comprehensive changes to the way emojis are managed, and is therefore unfit for this small bugfix. Note thatim.ponies.room_emotes
is already hardcoded for the detection, use, updating, and creation of room image packs.Type of change
Checklist: