Skip to content

Commit

Permalink
Merge: Basic m.video support
Browse files Browse the repository at this point in the history
Thanks to Arto Jantunen (@viiru-).
  • Loading branch information
alphapapa committed Apr 28, 2023
2 parents 11450ed + 243e444 commit 5be1e07
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ Note that, while ~matrix-client~ remains usable, and probably will for some time
+ Option ~ement-room-timestamp-header-align~ controls how timestamp headers are aligned in room buffers.
+ Option ~ement-room-view-hook~ runs functions when ~ement-room-view~ is called. (By default, it refreshes the room list buffer.)
+ In the room list, middle-clicking a room which has a buffer closes its buffer.
+ Basic support for video events. (Thanks to [[https://github.com/viiru-][Arto Jantunen]].)

*Changes*

Expand Down
26 changes: 26 additions & 0 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,7 @@ If FORMATTED-P, return the formatted body content, when available."
((or "m.text" "m.emote" "m.notice") nil)
("m.image" (ement-room--format-m.image event))
("m.file" (ement-room--format-m.file event))
("m.video" (ement-room--format-m.video event))
(_ (if (or local-redacted-by unsigned-redacted-by)
nil
(format "[unsupported msgtype: %s]" msgtype ))))))
Expand Down Expand Up @@ -4136,6 +4137,31 @@ Then invalidate EVENT's node to show the image."
(propertize " "
'display '(space :relative-height 1.5)))))

(defun ement-room--format-m.video (event)
"Return \"m.video\" EVENT formatted as a string."
;; TODO: Insert thumbnail images when enabled.
(pcase-let* (((cl-struct ement-event
(content (map body
('info (map mimetype size w h))
('url mxc-url))))
event)
(url (when mxc-url
(ement--mxc-to-url mxc-url ement-session)))
(human-size (file-size-human-readable size))
(string (format "[video: %s (%s) (%sx%s) (%s)]" body mimetype w h human-size)))
(concat (propertize string
'action #'browse-url
'button t
'button-data url
'category t
'face 'button
'follow-link t
'help-echo url
'keymap button-map
'mouse-face 'highlight)
(propertize " "
'display '(space :relative-height 1.5)))))

;;;;; Org format sending

;; Some of these declarations may need updating as Org changes.
Expand Down

0 comments on commit 5be1e07

Please sign in to comment.