-
Notifications
You must be signed in to change notification settings - Fork 45
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
Optionally remove redacted event content from room buffers #300
Comments
Comparing a The following then works for emptying the content of the redacted event at point and re-displaying it as simply (defun my-ement-room-hide-message-content ()
"Hide the content of the message at point."
(interactive)
(when-let* ((node (ewoc-locate ement-ewoc (point)))
(event (ewoc-data node)))
(setf (ement-event-content event) nil)
(ement-room--replace-event event)
(message "Removed content of event."))) If I try it on a non-redacted message I see: |
It also 'works' in the Notifications buffer, albeit with an error "Wrong type argument: ement-room, nil". |
In case anyone else wants this interim solution: Note that the hidden content is still available by inspecting the event data with We may see some errors about (defun my-ement-room-hide-message-content (&optional event)
"Hide the content of the message at point."
(interactive)
(unless event
(when-let ((node (ewoc-locate ement-ewoc (point))))
(setq event (ewoc-data node))))
(when event
(setf (map-elt (ement-event-local event) 'hidden-content)
(ement-event-content event))
(setf (ement-event-content event) nil)
(ement-room--replace-event event)
(when-let ((buf (get-buffer "*Ement Notifications*")))
(with-current-buffer buf
(ement-room--replace-event event)))
(when-let ((buf (get-buffer "*Ement Mentions*")))
(with-current-buffer buf
(ement-room--replace-event event)))
(message "Removed content of event.")))
(defun my-ement-room-unhide-message-content (&optional event)
"Un-hide the content of the message at point."
(interactive)
(unless event
(when-let ((node (ewoc-locate ement-ewoc (point))))
(setq event (ewoc-data node))))
(when-let ((content (and event (map-elt (ement-event-local event)
'hidden-content))))
(setf (ement-event-content event) content
(map-elt (ement-event-local event) 'hidden-content) nil)
(ement-room--replace-event event)
;; Seems like this doesn't work for Notifications and Mentions,
;; but it does the job in the original Room buffer.
(when-let ((buf (get-buffer "*Ement Notifications*")))
(with-current-buffer buf
(ement-room--replace-event event)))
(when-let ((buf (get-buffer "*Ement Mentions*")))
(with-current-buffer buf
(ement-room--replace-event event)))
(message "Restored content of event.")))
(define-advice ement-room-delete-message
(:after (event _room _session &optional _reason) my-hide-content)
"Hide the content of the message after deleting if a prefix arg was given.
This is :after advice for `ement-room-delete-message'. Remove with:
\(advice-remove \\='ement-room-delete-message
\\='ement-room-delete-message@my-hide-content)"
(when current-prefix-arg
(my-ement-room-hide-message-content event)))
(define-advice ement-room-delete-message
(:before (&rest _args) my-report-and-ban)
"Report and ban the user with a double C-u C-u prefix.
This is :before advice for `ement-room-delete-message'. Remove with:
\(advice-remove \\='ement-room-delete-message
\\='ement-room-delete-message@my-report-and-ban)"
(when (equal current-prefix-arg '(16))
(let ((current-prefix-arg nil))
(call-interactively #'ement-room-report-content)
(call-interactively #'ement-room-ban-user)))) |
Copying comments from chat
P: After deleting a spam message, what would be a way to remove it (or reduce it to the
[redacted]
state) from the Ement room buffer? Those telegram spam messages are so big and attention-grabbing, and I'd love to have them just gone from the buffers once they've been dealt with (without having to disconnect and reconnect).A: Yeah, good point. Well the simplest answer is to
C-x C-q
and then manually remove it from the buffer. :) But feel free to post an issue or a patch on the repo to discuss more permanent solutions. I decided to just mark redacted messages as strikethrough during a session so that you can still see redacted messages (for the cases where you'd be curious what was redacted; even a room admin might want to know if a user was trying to hide his nasty content to avoid a ban), but obviously in case of spam or bad content, one might not even want to see what's already been redacted. We should probably make an option, e.g. maybe set it to remove content of redacted messages unless you are a mod/admin in the room, something like that.P: I think the default behaviour is fine and useful generally, but maybe
C-u C-k
could be a combo to both redact and hide the message -- or just have a separate command to do the hiding.The text was updated successfully, but these errors were encountered: