Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Implement a message for user account suspension, as per MSC3823. #8722

Closed
wants to merge 13 commits into from

Conversation

Yoric
Copy link
Contributor

@Yoric Yoric commented May 31, 2022

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

  • Implement a message for user account suspension, as per MSC3823. (#8722). Contributed by @Yoric.

@Yoric Yoric requested a review from a team as a code owner May 31, 2022 09:14
@Yoric
Copy link
Contributor Author

Yoric commented May 31, 2022

Unfortunately, I have no idea how to write a test for such a feature.

@Yoric Yoric added the T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements label May 31, 2022
@Yoric Yoric marked this pull request as draft May 31, 2022 09:18
@Yoric Yoric force-pushed the yoric/msc3823 branch 2 times, most recently from 988688f to cd2e636 Compare May 31, 2022 09:28
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
@Yoric Yoric marked this pull request as ready for review May 31, 2022 10:59
@Yoric
Copy link
Contributor Author

Yoric commented May 31, 2022

The test failure seems to be a timeout in unrelated code.

Copy link
Member

@turt2live turt2live left a 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.

@turt2live
Copy link
Member

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.

@Yoric
Copy link
Contributor Author

Yoric commented Jun 2, 2022

Matching screenshot:
Screenshot from 2022-06-02 07-53-31

@Yoric Yoric requested a review from turt2live June 2, 2022 07:17
@Yoric
Copy link
Contributor Author

Yoric commented Jun 2, 2022

Also, test added.

@t3chguy
Copy link
Member

t3chguy commented Jun 2, 2022

@Yoric that screenshot looks rather broken

image

It is likely even worse with different scaling/font settings.

@Yoric
Copy link
Contributor Author

Yoric commented Jun 2, 2022

@Yoric that screenshot looks rather broken

image

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.

Here's a screenshot with a more reasonable 1280x1024:
Screenshot from 2022-06-02 09-58-40

@Yoric
Copy link
Contributor Author

Yoric commented Jun 2, 2022

The cypress test passes locally but fails with the following error message in CI:

Error: Can't use 'tar -xzf' extract archive file: /home/runner/work/_actions/_temp_00e45d6c-6a29-4cbf-a707-3052823681c4/7b22363b-0b56-4817-8fec-0cd31a12eaad.tar.gz. return code: 2.

I don't have the authorization to relaunch tests.

Copy link
Member

@turt2live turt2live left a 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";
Copy link
Member

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?

Copy link
Contributor Author

@Yoric Yoric Jun 3, 2022

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?

Copy link
Member

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 => {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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...

Copy link
Contributor Author

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:

  1. Write a MSC (done).
  2. Write a prototype as a spam-check module for Synapse (WIP, close to done).
  3. Write a front-end (this).
  4. Test it (blocked by 2 & 3).
  5. Once we're satisfied that it works, port the prototype to Synapse proper.

Copy link
Member

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.

Copy link
Contributor Author

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:

  1. throw away several weeks worth of work by three people;
  2. 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?

Copy link
Member

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.

Copy link
Contributor Author

@Yoric Yoric Jun 15, 2022

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?

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.

@Yoric Yoric requested a review from turt2live June 3, 2022 08:46
@turt2live turt2live removed their request for review June 3, 2022 15:34
@t3chguy
Copy link
Member

t3chguy commented Jun 6, 2022

Here's a screenshot with a more reasonable 1280x1024:

Until you open the right panel, surely?

@Yoric
Copy link
Contributor Author

Yoric commented Jun 6, 2022

Here's a screenshot with a more reasonable 1280x1024:

Until you open the right panel, surely?

You are right.

Note that the problem already shows up prior to this patch, though.

Screenshot from 2022-06-06 09-47-17

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.

@Yoric
Copy link
Contributor Author

Yoric commented Jun 6, 2022

Note: Latest cypress error seems to be a timeout in unrelated code.

@Yoric Yoric requested a review from turt2live June 7, 2022 06:02
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);
Copy link
Member

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:

Suggested change
cy.wait(1_000);
cy.wait(1000);

Copy link
Contributor Author

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.

Copy link
Member

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 => {
Copy link
Member

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).

Copy link
Contributor Author

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?

  1. Land it with the intercept.
  2. Perform the tests that we cannot perform until this feature has landed.
  3. Design an admin API.
  4. Spend a few weeks (or however long is required) bikeshedding, implementing and landing the admin API(s) with back-end.
  5. Once we have an admin API, add a second test (or replace the existing test with a new one) that uses the admin API?

Copy link
Member

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.

Comment on lines +3094 to +3095
"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.",
Copy link
Member

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:

  1. Wait for someone on the web team to get to it in the backlog (slow, and likely way too slow for your timelines).
  2. Get your hands dirty and learn some CSS 😇
  3. 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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Comment on lines +3094 to +3095
"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.",
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Who exactly?

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Search the corp space :)

@andybalaam
Copy link
Member

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.

@andybalaam andybalaam closed this Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Enhancement New features, changes in functionality, performance boosts, user-facing improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants