Skip to content
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

User modify command threepid handling fixes #136

Merged
merged 8 commits into from Nov 23, 2023
Merged

User modify command threepid handling fixes #136

merged 8 commits into from Nov 23, 2023

Conversation

JOJ0
Copy link
Owner

@JOJ0 JOJ0 commented Nov 13, 2023

Fixes #135

Improve the --threepidoption of the user modify command.

  • Support removing all threepids by passing --clear-threepids
    Note: If a user has the idea/follows the logic that resetting according to the API docs (https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#create-or-modify-account) should also work by setting it to "empty", ie. --threepid '' '', that will also work, but it is not documented in --help!
  • Extend and clarify --help for this option.
  • Fix an issue where passing multiple --threepid options, sets only the last of the argument pairs the user had provided on the cli (ignoring all others).

@JOJ0 JOJ0 marked this pull request as draft November 13, 2023 16:22
as well as rewriting help of `--threepid` opton.
Actually Click errors out if `--threpid` is passed without arguments _or_ if it
is not exactly two arguments. No need for this empty tuple check. It will never
be true.
to prevent WARNING when user wants to clear by passing `--threepid '' ''`.
@JOJ0
Copy link
Owner Author

JOJ0 commented Nov 13, 2023

One more uglyness remains with this quick and dirty implementation. If the user passes some valid arg-pairs alongside one empty-string-pair, the sanity check still complains:

User account settings to be modified:
threepid: email abc@123.com
threepid: email def@456.com
threepid:
WARNING  is probably not a supported medium type. Threepid medium types according to the current matrix spec are: email, msisdn.
Are you sure you want to modify user? (y/N): y
INFO  Querying put on https://peek-a-boo.at/_synapse/admin/v2/users/%40testuser1%3Apeek-a-boo.at
WARNING Synapse returned status code 400
errcode: M_INVALID_PARAM
error: ''''' is not a valid value for ''medium'''

Is that bad? Or ist that actually good (because bad arguments where passed anyway)?.

@JOJ0 JOJ0 marked this pull request as ready for review November 13, 2023 17:17
@JOJ0
Copy link
Owner Author

JOJ0 commented Nov 13, 2023

@JacksonChen666 I know there is some rather dirty fixes in this PR. Some nitpicking on my help texts appreciated! Or maybe you have some better ideas? Or we decide that it is good enough for now?

@n-peugnet if you have a minute: Can you install from this branch and test it out in terms of "usability"?

value (eg. --threepid email <user@example.org>). This option can also
be stated multiple times, i.e. a user can have multiple threepids
configured.""")
help="""Add a third-party identifier (email address or phone number).
Copy link
Contributor

Choose a reason for hiding this comment

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

So does it add 3pids or replace them in the end?

Copy link
Owner Author

@JOJ0 JOJ0 Nov 14, 2023

Choose a reason for hiding this comment

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

Ah yeah, thanks for that catch! It replaces for existing accounts. That was the reason I was rewriting this help text in the first place. The problem with wording right now is that this user modify command is used to create as well as alter user accounts. Suggestions how to write this concisely?

Maybe start like that:

Set a third party identifier.....

@n-peugnet
Copy link
Contributor

@n-peugnet if you have a minute: Can you install from this branch and test it out in terms of "usability"?

I just tested it. It works as expected, but it is a little bit strange to use. Maybe a --clear-threepids option would be clearer. For now I can live with the --threepid '' '' option.

help="""Add a third-party identifier (email address or phone number).
Threepids are used for several things: For use when logging in, as an
alternative to the user id; in the case of email, as an alternative contact
to help with account recovery; as well as to receive notifications of
Copy link
Owner Author

Choose a reason for hiding this comment

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

should be comma not semicolon!

@JOJ0
Copy link
Owner Author

JOJ0 commented Nov 14, 2023

@n-peugnet if you have a minute: Can you install from this branch and test it out in terms of "usability"?

I just tested it. It works as expected, but it is a little bit strange to use. Maybe a --clear-threepids option would be clearer. For now I can live with the --threepid '' '' option.

Yes I also thought about a separate clear threepid option. The thing with that is that it's a weird option to have when creating an account. Well, actually, it would just be ignored in that case.

All these weirdnesses are some of the reasons for the redesign approaches you already noticed ;-)

- State usage information first thing; Description of what it actually is,
  state last.
- Remove information of clearing in perparation of separate --clear-threepids
  option.
- Explicitely state that existing users will get all threepids replaced!
- Removes all threepids.
- Takes precedence over all passed --threepid options.
- It's not separately catched and warned that it doesn't make sense to provide
  this together with --threepid. Decision made to keep code less populated (it
  _is_ already too much...).
- Since api.user_modify is also already huge, decide to keep "threepid
  clearing" code as-is (passing empty strings in tuple-tuple clear. Period.)
- Fix format of hard to read helper.api.user_modify() statement.
We don't only modify users with this command we also create them - fix all
accourences of "modify" to additionally state "create".
@JOJ0
Copy link
Owner Author

JOJ0 commented Nov 16, 2023

I finally decided to add a separate option --clear-threepids, it doesn't make our code better readable (duh!) but at least it helps users. If you have another few minutes @n-peugnet , some test runs are very much appreciated. Otherwise I'll merge and release this in a couple of days. My test runs so far are fine.

I also gave the help texts another rewrite and reordering. Hope I got everything to be told into it finally.

Also some fixes in wording of the "user interaction" messages. The command always stated that "something is modified" even though it could also be just freshly "created"

Anyway there is room for improvement / redesign in all this. We know...we know...known issue... :-)

@JOJ0 JOJ0 merged commit c6e6706 into master Nov 23, 2023
2 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.

Removing of threepid is not supported
2 participants