Skip to content

fix: allow redact-power users to end polls (MSC3381)#2413

Merged
krille-chan merged 2 commits into
famedly:mainfrom
Quantumheart:quantumheart/endpoll-allow-redact-power
Jul 18, 2026
Merged

fix: allow redact-power users to end polls (MSC3381)#2413
krille-chan merged 2 commits into
famedly:mainfrom
Quantumheart:quantumheart/endpoll-allow-redact-power

Conversation

@Quantumheart

Copy link
Copy Markdown
Contributor

Summary

I am working on a Matrix client called Kohera. I am currently, working through the polling spec 3381 and found that the power level redaction is not respected for moderators.

Changes

  • add !room.canRedact
  • add test "endPoll: creator may end, non-creator without redact power may not, redact power may end"

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small authorization fix in poll MSC code with matching tests; behavior now matches spec and receive-side validation.

Overview
endPoll no longer requires the current user to be the poll creator; users with room redact power (room.canRedact) may end someone else’s poll, matching MSC3381 and the existing _getEndPollEvent rules for accepting m.poll.end events.

Documentation on endPoll was added to describe who may end a poll. A test covers rejection for non-creators without redact power, success after granting redact power, and the creator path.

Reviewed by Cursor Bugbot for commit 6c5ce3e. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.66%. Comparing base (53a6a79) to head (6c5ce3e).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2413      +/-   ##
==========================================
+ Coverage   59.62%   59.66%   +0.03%     
==========================================
  Files         161      161              
  Lines       20329    20329              
==========================================
+ Hits        12121    12129       +8     
+ Misses       8208     8200       -8     
Files with missing lines Coverage Δ
...xtensions/msc_3381_polls/poll_event_extension.dart 83.60% <100.00%> (+13.11%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53a6a79...6c5ce3e. Read the comment docs.

@krille-chan krille-chan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the MSC:

If a m.poll.end event is received from someone other than the poll creator or user with permission to redact other's messages in the room, the event must be ignored by clients due to being invalid.

So you are right :) I also checked that we are already correctly parsing it manually, just this check was missing. Thank you very much

@krille-chan

Copy link
Copy Markdown
Contributor

@Quantumheart you need to sign your commit and make sure you accepted the CLA (the cla bot may be prompted once you signed your commit)

@Quantumheart
Quantumheart force-pushed the quantumheart/endpoll-allow-redact-power branch from e8ffb57 to 8718497 Compare July 16, 2026 15:20
@CLAassistant

CLAassistant commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Quantumheart
Quantumheart force-pushed the quantumheart/endpoll-allow-redact-power branch from 8718497 to ba79bc2 Compare July 16, 2026 16:06
The endPoll() send helper only permitted the poll creator to end a poll, whereas the receive-side validator (_getEndPollEvent) honours m.poll.end events from the creator or any user with redact power, per MSC3381. Align the send guard with the spec and the receive-side check by also allowing callers with room.canRedact.

Signed-off-by: quantumheart <canteen0072@proton.me>
@Quantumheart
Quantumheart force-pushed the quantumheart/endpoll-allow-redact-power branch from ba79bc2 to 52d19d8 Compare July 16, 2026 16:35

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 52d19d8. Configure here.

Comment thread test/msc_extensions/msc_3881_polls_test.dart
The denial-case expectLater was unawaited, so its async matcher could
run after the subsequent redact-power injection and race the assertion.

Signed-off-by: quantumheart <canteen0072@proton.me>
@Quantumheart

Copy link
Copy Markdown
Contributor Author

Resolved in 6c5ce3e — the denial-case expectLater is now awaited so the matcher completes before the redact-power injection. Test passes locally.

@Quantumheart

Copy link
Copy Markdown
Contributor Author

@krille-chan are you able to approve the workflow? Thanks in advance.

@krille-chan
krille-chan enabled auto-merge July 18, 2026 06:58
@krille-chan
krille-chan merged commit 5c1c48a into famedly:main Jul 18, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants