-
-
Notifications
You must be signed in to change notification settings - Fork 823
Implement a message for user account suspension, as per MSC3823. #8722
Conversation
Unfortunately, I have no idea how to write a test for such a feature. |
988688f
to
cd2e636
Compare
Users may have their account temporarily suspended from a homeserver, e.g. due to ToS violations. This prevents them from sending new messages but not from logging, reading messages or redacting their own messages. This patch displays an error message comparable to "some of your messages have not been sent". See matrix-org/synapse#12845 for more details. Notes: Support for MSC3823. Display an error message if the user's account has been suspended. Type: enhancement
The test failure seems to be a timeout in unrelated code. |
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.
generally lgtm - just concerns about the code style (some of which should be enforced by the linter, but empirically aren't).
Please also include screenshots to make design review easier, as they will need to look at the copy.
For testing: a cypress test would be appreciated. It allows you to run a Synapse and call endpoints, which should be enough to trigger and test suspension. |
Also, test added. |
@Yoric that screenshot looks rather broken It is likely even worse with different scaling/font settings. |
Yes, I believe that this is what what the status bar currently looks like on 1000x660 (the default size for cypress), even without my patch. |
The cypress test passes locally but fails with the following error message in CI:
I don't have the authorization to relaunch tests. |
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.
I've also re-run the cypress tests in hopes of fixing them. The cypress test looks valid, though we should structure the code around it to match our sort of best practices rather than past mistakes.
//cy.stopSynapse(synapse); | ||
}); | ||
|
||
const TEXT = "Hello, world"; |
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.
variables should be grouped together, and this is of questionable case - what do the other tests do?
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.
Moving things up, but I don't understand what makes this questionable. TEXT
is used ~6 times around the code, why shouldn't it be a constant?
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.
it should be a constant, but we don't usually mix all caps and lowerCamelCase in our definition bodies.
|
||
// Pretend to send a message but inject an error response. | ||
function sendWithErrorResponse(text, response) { | ||
cy.intercept("http://localhost:*/_matrix/client/r0/rooms/*/send/m.room.message/*", req => { |
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.
can we not just call a synapse API to suspend the user?
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.
can we not just call a synapse API to suspend the user?
Not yet.
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.
I'm not entirely comfortable landing this feature if there's no way to use it...
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.
Well, we have a chicken and egg problem.
Our process is:
- Write a MSC (done).
- Write a prototype as a spam-check module for Synapse (WIP, close to done).
- Write a front-end (this).
- Test it (blocked by 2 & 3).
- Once we're satisfied that it works, port the prototype to Synapse proper.
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.
Testing shouldn't be blocked by a frontend implementation, otherwise we'd get nothing done :p
This sitting on a branch/here is fine while the rest of the feature is worked out, particularly considering this will be needing design review as well.
For the test here it's moderately important that we don't just intercept random endpoints and instead use the API provided by Synapse to do things: this means getting an admin API to suspend a user.
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.
We cannot land this without suitable tests, so to unblock this the tests need to be written. It is currently the only blocker for this PR.
I'm currently doing my best to find a way to write a test that matches your criteria without having to:
- throw away several weeks worth of work by three people;
- start several more weeks of work in a different direction that doesn't match our requirements.
Is there any chance you could find an alternative solution?
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.
The alternative is we don't land this, I'm afraid. Tests are a hard requirement and I can't single-handedly bypass the requirements we've set out for our testing infrastructure.
A plausible test is one which installs the spam checker module onto a dedicated synapse (since we can support running different flavours of Synapse already) and trigger that with a message of some kind.
I do not believe that any of the proposed solutions I've raised are multiple weeks worth of work. Please engage the web team sooner to avoid having to reconsider several people's work.
also, apologies, the other blocker I missed is the CSS issue.
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.
A plausible test is one which installs the spam checker module onto a dedicated synapse (since we can support running different flavours of Synapse already) and trigger that with a message of some kind.
Very well, if that's what it takes. What's the procedure to create a dedicated Synapse for use with the front end's cypress tests?
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.
We have a "consent" template already that I think you should be able to largely copy/paste. Visiting #element-dev:matrix.org would be better than asking here though, to spread the support load and get an answer more quickly.
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.
Thank you.
Until you open the right panel, surely? |
You are right. Note that the problem already shows up prior to this patch, though. I would suggest fixing this for good in a followup issue, as I clearly do not have a fine enough understanding of the CSS of Element Web for this purpose, plus this feels like a bit too much scope extension for this PR. |
Note: Latest cypress error seems to be a timeout in unrelated code. |
cy.get(".mx_RoomView_body .mx_EventTile").contains(".mx_EventTile[data-scroll-tokens]", text); | ||
|
||
// Give an error a little time to show up. It shouldn't. | ||
cy.wait(1_000); |
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.
we don't use this syntax:
cy.wait(1_000); | |
cy.wait(1000); |
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.
Will do, but may I suggest amending this policy? 16_777_384 is much more readable than 16777384.
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.
I personally disagree on that, tbh :p
I'm not sure what others on the team think, but I suspect since we haven't done so up until now we aren't likely to remember to do it, so will end up fighting the linter instead of working with it.
|
||
// Pretend to send a message but inject an error response. | ||
function sendWithErrorResponse(text, response) { | ||
cy.intercept("http://localhost:*/_matrix/client/r0/rooms/*/send/m.room.message/*", req => { |
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.
sorry, I really think this needs to be an admin API call and not something we intercept. We should be testing that we behave correctly when Synapse tells us the account is suspended, not when we lie to it (otherwise we'd write an entirely different, less helpful, test).
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.
That feels like it would block an ongoing project.
Could we proceed as follows?
- Land it with the intercept.
- Perform the tests that we cannot perform until this feature has landed.
- Design an admin API.
- Spend a few weeks (or however long is required) bikeshedding, implementing and landing the admin API(s) with back-end.
- Once we have an admin API, add a second test (or replace the existing test with a new one) that uses the admin API?
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.
It would block the project, yes. Landing partial or incomplete code isn't viable as an option: we've literally never returned to temporary code, despite several promises that we will. We no longer take the chance, sorry.
"Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. To learn more, visit <detailsLink>this page</detailsLink>.": "Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. To learn more, visit <detailsLink>this page</detailsLink>.", | ||
"Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. Please contact the administrator of %(homeserverDomain)s.": "Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. Please contact the administrator of %(homeserverDomain)s.", |
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.
as already mentioned by @t3chguy, the status bar itself looks broken with this change, so we'd need to fix that before landing this PR.
The options for that are:
- Wait for someone on the web team to get to it in the backlog (slow, and likely way too slow for your timelines).
- Get your hands dirty and learn some CSS 😇
- Find someone who is able to help with writing that CSS and have them contribute ideas/guidance/code to this PR
Personally, I'd encourage option 2, particularly if you're expecting to be in the Element Web area for future changes.
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.
As already responded to @t3chguy, the status bar itself is already broken prior to this change.
I would really, really, really like to avoid scope creep. Can we please postpone this to a followup issue?
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.
Even if it was broken before, we can't reasonably land something which has a near-100% chance of causing the bug. It just doesn't line up with our code quality requirements, sorry.
"Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. To learn more, visit <detailsLink>this page</detailsLink>.": "Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. To learn more, visit <detailsLink>this page</detailsLink>.", | ||
"Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. Please contact the administrator of %(homeserverDomain)s.": "Your message wasn't sent. Your account is suspended: you cannot send messages, invites or join new rooms. Please contact the administrator of %(homeserverDomain)s.", |
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.
for a future review iteration: design will need to be consulted for the message copy here.
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.
Who exactly?
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.
can either get copy review internally from Write Club, or we can request design review once this hits a later stage of code review.
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.
Who's/what's Write Club?
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.
Search the corp space :)
It looks like progress here has halted for now. Thank you for your work on this. The code and the Netlify build will continue to exist, so this can still be used to validate the MSC if needed, but I'm going to close the PR until it's being actively worked on. |
Users may have their account temporarily suspended from a homeserver,
e.g. due to ToS violations. This prevents them from sending new messages
but not from reading messages or redacting their own messages.
This patch displays an error message comparable to "some of your messages have not been sent".
See matrix-org/synapse#12845 for more details.
Here's what your changelog entry will look like:
✨ Features