aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/mastodon-notifications.el26
-rw-r--r--lisp/mastodon-tl.el44
2 files changed, 64 insertions, 6 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 2e9aea3..19b2d3c 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -53,7 +53,8 @@
("follow" . mastodon-notifications--follow)
("favourite" . mastodon-notifications--favourite)
("reblog" . mastodon-notifications--reblog)
- ("follow_request" . mastodon-notifications--follow-request))
+ ("follow_request" . mastodon-notifications--follow-request)
+ ("status" . mastodon-notifications--status))
"Alist of notification types and their corresponding function.")
(defvar mastodon-notifications--response-alist
@@ -61,7 +62,8 @@
("Followed" . "you")
("Favourited" . "your status from")
("Boosted" . "your status from")
- ("Requested to follow" . "you"))
+ ("Requested to follow" . "you")
+ ("Posted" . "a post"))
"Alist of subjects for notification types.")
(defun mastodon-notifications--byline-concat (message)
@@ -204,6 +206,26 @@
"Boosted"))
id)))
+(defun mastodon-notifications--status (note)
+ "Format for a `status' NOTE.
+Status notifications are given when
+`mastodon-tl--notify-user-posts' has been set."
+ (let ((id (cdr (assoc 'id note)))
+ (status (mastodon-tl--field 'status note)))
+ (mastodon-notifications--insert-status
+ status
+ (mastodon-tl--clean-tabs-and-nl
+ (if (mastodon-tl--has-spoiler status)
+ (mastodon-tl--spoiler status)
+ (mastodon-tl--content status)))
+ (lambda (_status)
+ (mastodon-tl--byline-author
+ note))
+ (lambda (_status)
+ (mastodon-notifications--byline-concat
+ "Posted"))
+ id)))
+
(defun mastodon-notifications--insert-status (toot body author-byline action-byline &optional id)
"Display the content and byline of timeline element TOOT.
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 9bbc44f..6cb5ab8 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -945,8 +945,10 @@ webapp"
(cdr (assoc 'descendants context))))))
(message "No Thread!"))))
-(defun mastodon-tl--follow-user (user-handle)
- "Query for USER-HANDLE from current status and follow that user."
+(defun mastodon-tl--follow-user (user-handle &optional notify)
+ "Query for USER-HANDLE from current status and follow that user.
+If NOTIFY is \"true\", enable notifications when that user posts.
+If NOTIFY is \"false\", disable notifications when that user posts."
(interactive
(list
(let ((user-handles (mastodon-profile--extract-users-handles
@@ -959,12 +961,22 @@ webapp"
user-handle (mastodon-profile--toot-json)))
(user-id (mastodon-profile--account-field account 'id))
(name (mastodon-profile--account-field account 'display_name))
- (url (mastodon-http--api (format "accounts/%s/follow" user-id))))
+ (url (mastodon-http--api
+ (if notify
+ (format "accounts/%s/follow?notify=%s" user-id notify)
+ (format "accounts/%s/follow" user-id)))))
(if account
(let ((response (mastodon-http--post url nil nil)))
(mastodon-http--triage response
(lambda ()
- (message "User %s (@%s) followed!" name user-handle))))
+ (cond ((string-equal notify "true")
+ (message "Receiving notifications for user %s (@%s)!"
+ name user-handle))
+ ((string-equal notify "false")
+ (message "Not receiving notifications for user %s (@%s)!"
+ name user-handle))
+ ((eq notify nil)
+ (message "User %s (@%s) followed!" name user-handle))))))
(message "Cannot find a user with handle %S" user-handle))))
(defun mastodon-tl--unfollow-user (user-handle)
@@ -990,6 +1002,30 @@ webapp"
(message "User %s (@%s) unfollowed!" name user-handle)))))
(message "Cannot find a user with handle %S" user-handle))))
+(defun mastodon-tl--notify-user-posts (user-handle)
+ "Query for USER-HANDLE from current status and enable notifications when they post."
+ (interactive
+ (list
+ (let ((user-handles (mastodon-profile--extract-users-handles
+ (mastodon-profile--toot-json))))
+ (completing-read "Receive notifications when user posts: "
+ user-handles
+ nil ; predicate
+ 'confirm))))
+ (mastodon-tl--follow-user user-handle "true"))
+
+(defun mastodon-tl--no-notify-user-posts (user-handle)
+ "Query for USER-HANDLE from current status and disable notifications when they post."
+ (interactive
+ (list
+ (let ((user-handles (mastodon-profile--extract-users-handles
+ (mastodon-profile--toot-json))))
+ (completing-read "Disable notifications when user posts: "
+ user-handles
+ nil ; predicate
+ 'confirm))))
+ (mastodon-tl--follow-user user-handle "false"))
+
(defun mastodon-tl--mute-user (user-handle)
"Query for USER-HANDLE from current status and mute that user."
(interactive