-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add: (ement-room-kick-user, ement-room-ban-user, ement-room-unban-user) New commands #297
base: master
Are you sure you want to change the base?
Conversation
a753291
to
430d9ef
Compare
a78ad48
to
87e2652
Compare
All done for now. Tested, and looking good, I think (for an initial version, at least). |
Some comments of note from the testing:
|
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.
Thanks very much for working on this!
I see it's possible for the prompt to come up as "Ban user nil <@spammer123:matrix.org> ...?", so I should account for them not having a display name. |
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.
Thanks again for working on this.
We should probably just add a convenience function to format users for display in these cases, e.g. (cl-defun ement--format-user-id (user &key with-id-p (room ement-room))
"Return string describing USER.
If ROOM, return the user's displayname in that room, when set;
otherwise, the user's global displayname. If WITH-ID-P, quote
the displayname and include the user's MXID, like an email
address."
(let ((displayname (if room
;; FIXME: If a membership state event has not yet been received, this
;; sets the display name in the room to the user ID, and that prevents
;; the display name from being used if the state event arrives later.
(ement--user-displayname-in room user)
(or (ement-user-displayname user)
(ement-user-username user)))))
(if with-id-p
(if (equal displayname (ement-user-id user))
;; User has no displayname: just return the ID.
(format "<%s>" displayname)
(format "%S <%s>" displayname (ement-user-id user)))
displayname))) |
Cross-referencing with #300 |
By the way, I think we should add support for reporting messages to the homeserver admin. In Element, when I'm deleting spam, my procedure is usually: 1. Report to homeserver admin; 2. Ban user, 3. delete events. |
I didn't know that was a thing. https://spec.matrix.org/latest/client-server-api/#reporting-content |
684d865
to
f803b99
Compare
Any thoughts on the "score" value when reporting? A score ranges from -100 (worst/offensive) to zero (best/inoffensive), but I was finding this slightly awkward/ambiguous for UI purposes. I decided to see what kind of UI Element presented for it, and... it doesn't. There's no score option at all. I used it to send a retrospective report for the last spam event, and the HTTP request contained a score of -100 in the JSON. In the absence of any universally-agreed scale/mapping for the level of offence any given sort of post should warrant, "everything is -100" is certainly a simple solution. We could provide a handful of pre-determined named values, but would need names like "Most offensive" down to "Inoffensive" rather than names like "Spam", as the latter would just be imposing our definitions of how offensive any given thing was. We could have a very short labelled list like this, and default to... maybe -100, but maybe leaving space for something worse-than-normal?
And even then, the labels on everything but the first and last items are quite subjective. Thoughts? |
I appreciate your thoughtfulness, but I think we should just do what Element does here. If the official client doesn't care about offering a way to set the score parameter, then we probably shouldn't bother with it. (The score parameter was probably one of those things that seemed like a good idea at the time, but as you've aptly shown, doesn't map very well to reality and usability; the same content might be -100 HIGHLY OFFENSIVE to one person and -10 MEH to another and +1,000 WINS THE INTERNET to someone else.) |
I've gone with "mimic Element by default" (sending -100 automatically without asking the user), but I've left the ability to select a score if a prefix argument is used. It's a little bit configurable in case anyone really wants to change the default but, on the basis that probably no one will do that, I left that pretty minimal. |
f42be4b
to
c95c1b6
Compare
2ea60ad
to
6cc93bf
Compare
@phil-s Thanks for your work and your patience. I pushed some "Minor changes" and rebased. Let me know if you agree that this is ready to merge. |
Fair enough ditching the completing-read for score. I knew that seemed slightly mad by default, but I'd kept it so that users could change the list of options to a short list and then select from a handful of choices. I'm not fussed about losing that, though. The refactor has lost the support for reporting without a score, though. Having I think we need to revert to reading a string in order to support this. |
I feel like that's a case of "YAGNI." :)
I checked the API, and it doesn't list the score as an optional field, so unless I'm missing something, I think we shouldn't submit it without one. |
I'd figured everything not labelled Required was optional? |
Well, I guess you're right. :) Would you mind testing to see what happens if we send a request without the reason and score fields, just to be certain? (I'd suggest sending it in the testing room we have, and then redacting the reported event; I think the matrix.org homeserver admins will forgive us for one unnecessary report since we're developing a client and the docs are a bit ambiguous about it.) |
I reported a test message with no score, and I got a 200 response and the "Content reported." message. I was tracing the plz call and confirmed it only had Edit: Whoops, you asked for no reason either. One moment... |
Heh, ok, need to avoid this:
|
I believe this is good, now. I'm not seeing any errors from plz in any of the test scenarios. In each case I get the following from tracing
Where
|
Untested as yet, but I think we want this as well, so I'll just drop it in here for now. (defun ement-room-report-delete-ban (event room session reason)
"Report the current message, delete it, and ban the sender from the room."
(interactive
(ement-room-with-highlighted-event-at (point)
(let ((event (ewoc-data (ewoc-locate ement-ewoc))))
(unless (ement-event-p event)
(user-error "No event at point"))
(if (yes-or-no-p "Report, Delete, and Ban? ")
(let ((reason (string-trim
(read-string "Reason: "
nil ement-room-report-content-reason-history nil
'inherit-input-method))))
(list event ement-room ement-session reason))
;; Aborted.
(let ((debug-on-quit nil))
(signal 'quit nil))))))
;; Insist on a reason for this particular command.
(when (string-empty-p reason)
(user-error "Must supply a reason."))
;; Do all the things.
(let ((user-id (ement-user-id (ement-event-sender event)))
(room-id (ement-room-id room))
(score ement-room-report-content-score-default))
(ement-room-report-content event room session reason score)
(ement-room-delete-message event room session reason)
(ement-room-ban-user user-id room-id session reason))) |
Thanks, we definitely need some kind of "do all the things" combo command. I think it'd be best to follow Element's lead here, i.e. when banning a user, maybe a prefix argument or two could be used to indicate that we want to also delete the user's recent content. So the workflow might be like: 1) report individual events that need reporting; 2) call the "ban user" command with a prefix argument, which would present a confirmation prompt like, "Ban user and delete user's recent events?". What do you think? In the long run, it'd be nice to have a way to mark multiple events in a room buffer, and then call a command to act on them (e.g. if not all of a user's recent events should be reported). I have some ideas about how to facilitate that in the EWOC-based view. Let me know if you have any thoughts about that. |
I hadn't thought about marking messages, but I had pondered iterating over all of that sender's messages and prompting the user to report/delete them all. What about a search loop, highlighting each message from that sender in the room, and asking I guess we could use |
Yeah, I like that idea. (Not expecting you to code it, necessarily, but feel free to if you are interested.) |
a45b9a8
to
3852201
Compare
Rebased over master, squashing some fixups. |
Co-authored-by: Phil Sainty <[email protected]>
New commands: - ement-room-kick-user - ement-room-ban-user - ement-room-unban-user
e15249e
to
ceb0267
Compare
I've pushed a command You'll note that at present it doesn't issue the actual report/delete/ban requests (which have been pretty well-tested at this point, so ought to work). I've commented those lines out from this new function, and instead it just issues a Please note that all of the other commands in this PR do perform their actions, including the earlier |
Interactively select the messages to report and delete. FIXME: This is a test version, which only issues messages saying what it would have done.
(ement-room-hide-message-content) New command (ement-room-unhide-message-content) New command
f8717b8
to
617860d
Compare
I had an opportunity to use the new command in practice today (after I removed the training wheels, locally), and it worked fine. I'm still interested in feedback on the UI (including whether it should even be a separate command in the menu, or just rolled into the "ban a user" command). |
New admin commands for a room's power users.