aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/mastodon-http.el2
-rw-r--r--lisp/mastodon-notifications.el6
-rw-r--r--lisp/mastodon-profile.el10
-rw-r--r--lisp/mastodon-tl.el60
-rw-r--r--lisp/mastodon-toot.el12
-rw-r--r--lisp/mastodon-views.el10
-rw-r--r--test/mastodon-http-tests.el6
-rw-r--r--test/mastodon-tl-tests.el102
-rw-r--r--test/mastodon-toot-tests.el2
9 files changed, 115 insertions, 95 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 3d26dc5..1edc8b5 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -91,7 +91,7 @@ RESPONSE if unsuccessful."
(let ((status (with-current-buffer response
(mastodon-http--status))))
(if (string-prefix-p "2" status)
- (funcall success)
+ (funcall success response)
(if (string-prefix-p "404" status)
(message "Error %s: page not found" status)
(let ((json-response (with-current-buffer response
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index cce5810..a1aea31 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -116,7 +116,7 @@ follow-requests view."
(mastodon-http--api "follow_requests")
(format "/%s/%s" .id (if reject "reject" "authorize"))))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(if f-reqs-view-p
(mastodon-views--view-follow-requests)
(mastodon-tl--reload-timeline-or-profile))
@@ -311,7 +311,7 @@ Status notifications are created when you call
(let ((response
(mastodon-http--post (mastodon-http--api "notifications/clear"))))
(mastodon-http--triage
- response (lambda ()
+ response (lambda (_)
(when mastodon-tl--buffer-spec
(mastodon-tl--reload-timeline-or-profile))
(message "All notifications cleared!"))))))
@@ -326,7 +326,7 @@ Status notifications are created when you call
(mastodon-http--post (mastodon-http--api
(format "notifications/%s/dismiss" id)))))
(mastodon-http--triage
- response (lambda ()
+ response (lambda (_)
(when mastodon-tl--buffer-spec
(mastodon-tl--reload-timeline-or-profile))
(message "Notification dismissed!")))))
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 9850b81..1003853 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -319,7 +319,7 @@ Ask for confirmation if length > 500 characters."
"Send PATCH request with the updated profile NOTE to URL."
(let ((response (mastodon-http--patch url `(("note" . ,note)))))
(mastodon-http--triage response
- (lambda () (message "Profile note updated!")))))
+ (lambda (_) (message "Profile note updated!")))))
(defun mastodon-profile--update-preference (pref val &optional source)
"Update account PREF erence to setting VAL.
@@ -329,7 +329,7 @@ SOURCE means that the preference is in the `source' part of the account JSON."
(pref-formatted (if source (concat "source[" pref "]") pref))
(response (mastodon-http--patch url `((,pref-formatted . ,val)))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(mastodon-profile--fetch-server-account-settings)
(message "Account setting %s updated to %s!" pref val)))))
@@ -441,7 +441,7 @@ Returns an alist."
(params (mastodon-profile--make-meta-fields-params fields-updated))
(response (mastodon-http--patch url params)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(mastodon-profile--fetch-server-account-settings)
(message "Metadata fields updated to %s!"
fields-updated)))))
@@ -816,7 +816,7 @@ Optionally provide the ID of the account to remove."
(when (y-or-n-p (format "Remove follower %s? " handle))
(let ((response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "Follower %s removed!" handle)))))))
(defun mastodon-profile--remove-from-followers-at-point ()
@@ -862,7 +862,7 @@ NOTE-OLD is the text of any existing note."
(url (mastodon-http--api (format "accounts/%s/note" id)))
(response (mastodon-http--post url params)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "Private note on %s added!" handle)))))
(defun mastodon-profile--view-account-private-note ()
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 7859413..135c7f5 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1229,7 +1229,7 @@ displayed when the duration is smaller than a minute)."
(arg `(("choices[]" . ,option-as-arg)))
(response (mastodon-http--post url arg)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "You voted for option %s: %s!"
(car option) (cdr option)))))))
@@ -1852,7 +1852,7 @@ If UNMUTE, unmute it."
(when (y-or-n-p (format "%s this thread? " (capitalize mute-str)))
(let ((response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(if unmute
(message "Thread unmuted!")
(message "Thread muted!")))))))))))
@@ -2086,27 +2086,35 @@ ARGS is an alist of any parameters to send with the request."
(let ((response (mastodon-http--post url args)))
(mastodon-http--triage
response
- (lambda ()
- (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))
- ((string-equal reblogs "true")
- (message "Receiving boosts by user %s (@%s)!"
- name user-handle))
- ((string-equal reblogs "false")
- (message "Not receiving boosts by user %s (@%s)!"
- name user-handle))
- ((or (string-equal action "mute")
- (string-equal action "unmute"))
- (message "User %s (@%s) %sd!" name user-handle action))
- ((assoc "languages[]" args #'equal)
- (message "User %s filtered by language(s): %s" name
- (mapconcat #'cdr args " ")))
- ((eq notify nil)
- (message "User %s (@%s) %sed!" name user-handle action)))))))
+ (lambda (response)
+ (let ((json (with-current-buffer response
+ (mastodon-http--process-json))))
+ ;; TODO: when > if, with failure msg
+ (cond ((string-equal notify "true")
+ (when (equal 't (alist-get 'notifying json))
+ (message "Receiving notifications for user %s (@%s)!"
+ name user-handle)))
+ ((string-equal notify "false")
+ (when (equal :json-false (alist-get 'notifying json))
+ (message "Not receiving notifications for user %s (@%s)!"
+ name user-handle)))
+ ((string-equal reblogs "true")
+ (when (equal 't (alist-get 'showing_reblogs json))
+ (message "Receiving boosts by user %s (@%s)!"
+ name user-handle)))
+ ((string-equal reblogs "false")
+ (when (equal :json-false (alist-get 'showing_reblogs json))
+ (message "Not receiving boosts by user %s (@%s)!"
+ name user-handle)))
+ ((or (string-equal action "mute")
+ (string-equal action "unmute"))
+ (message "User %s (@%s) %sd!" name user-handle action))
+ ((assoc "languages[]" args #'equal)
+ (message "User %s filtered by language(s): %s" name
+ (mapconcat #'cdr args " ")))
+ ((and (eq notify nil)
+ (eq reblogs nil))
+ (message "User %s (@%s) %sed!" name user-handle action))))))))
;; FOLLOW TAGS
@@ -2135,7 +2143,7 @@ If TAG provided, follow it."
(url (mastodon-http--api (format "tags/%s/follow" tag)))
(response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "tag #%s followed!" tag)))))
(defun mastodon-tl--followed-tags ()
@@ -2153,7 +2161,7 @@ If TAG is provided, unfollow it."
(url (mastodon-http--api (format "tags/%s/unfollow" tag)))
(response (mastodon-http--post url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "tag #%s unfollowed!" tag)))))
(defun mastodon-tl--list-followed-tags (&optional prefix)
@@ -2251,7 +2259,7 @@ report the account for spam."
(params (mastodon-tl--report-params account toot))
(response (mastodon-http--post url params)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "User %s reported!" handle)))))))
(defvar crm-separator)
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 682f6ca..e10e7e8 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -386,7 +386,7 @@ TYPE is a symbol, either `favourite' or `boost.'"
(t
(mastodon-toot--action
action
- (lambda ()
+ (lambda (_)
(let ((inhibit-read-only t))
(add-text-properties (car byline-region)
(cdr byline-region)
@@ -457,7 +457,7 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(if byline-region
(mastodon-toot--action
action
- (lambda ()
+ (lambda (_)
(let ((inhibit-read-only t))
(add-text-properties (car byline-region)
(cdr byline-region)
@@ -563,7 +563,7 @@ Uses `lingva.el'."
(message "You can only pin your own toots.")
(when (y-or-n-p (format "%s this toot? " msg-y-or-n))
(mastodon-toot--action action
- (lambda ()
+ (lambda (_)
(when mastodon-tl--buffer-spec
(mastodon-tl--reload-timeline-or-profile))
(message "Toot %s!" msg)))))))
@@ -597,7 +597,7 @@ NO-REDRAFT means delete toot only."
(let* ((response (mastodon-http--delete url)))
(mastodon-http--triage
response
- (lambda ()
+ (lambda (_)
(if no-redraft
(progn
(when mastodon-tl--buffer-spec
@@ -856,7 +856,7 @@ instance to edit a toot."
(mastodon-http--post endpoint args))))
(mastodon-http--triage
response
- (lambda ()
+ (lambda (_)
(mastodon-toot--kill)
(if scheduled
(message "Toot scheduled!")
@@ -1343,7 +1343,7 @@ With RESCHEDULE, reschedule the scheduled toot at point without editing."
(url (mastodon-http--api (format "scheduled_statuses/%s" id)))
(response (mastodon-http--put url args)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
;; reschedule means we are in scheduled toots view:
(mastodon-views--view-scheduled-toots)
(message
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index dafa359..b1ff70d 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -302,7 +302,7 @@ If ID is provided, use that list."
("replies_policy" . ,replies-policy)
("exclusive" . ,exclusive)))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(with-current-buffer response
(let* ((json (mastodon-http--process-json))
(name-new (alist-get 'title json)))
@@ -442,7 +442,7 @@ If ID is provided, use that list."
(defun mastodon-views--list-action-triage (response &rest args)
"Call `mastodon-http--triage' on RESPONSE and call message on ARGS."
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(when (mastodon-tl--buffer-type-eq 'lists)
(mastodon-views--view-lists))
(apply #'message args))))
@@ -559,7 +559,7 @@ NO-CONFIRM means there is no ask or message, there is only do."
(let* ((url (mastodon-http--api (format "scheduled_statuses/%s" id)))
(response (mastodon-http--delete url)))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(mastodon-views--view-scheduled-toots)
(unless no-confirm
(message "Toot cancelled!")))))))))
@@ -650,7 +650,7 @@ Prompt for a context, must be a list containting at least one of \"home\",
`("phrase" . ,word)
contexts-processed))))
(mastodon-http--triage response
- (lambda ()
+ (lambda (_)
(message "Filter created for %s!" word)
(when (mastodon-tl--buffer-type-eq 'filters)
(mastodon-views--view-filters))))))
@@ -666,7 +666,7 @@ Prompt for a context, must be a list containting at least one of \"home\",
(when (y-or-n-p (format "Delete filter %s? " phrase))
(let ((response (mastodon-http--delete url)))
(mastodon-http--triage
- response (lambda ()
+ response (lambda (_)
(mastodon-views--view-filters)
(message "Filter for \"%s\" deleted!" phrase))))))))
diff --git a/test/mastodon-http-tests.el b/test/mastodon-http-tests.el
index b3a02bc..96f9304 100644
--- a/test/mastodon-http-tests.el
+++ b/test/mastodon-http-tests.el
@@ -62,11 +62,11 @@ Strict-Transport-Security: max-age=31536000
(let ((response-buffer
(get-buffer-create "mastodon-http--triage-buffer")))
(with-current-buffer response-buffer
- (erase-buffer)
+ (erase-buffer)
(insert mastodon-http--example-200))
(should (equal (mastodon-http--triage
response-buffer
- (lambda ()
+ (lambda (_)
(message "success call")))
"success call"))))
@@ -80,7 +80,7 @@ Strict-Transport-Security: max-age=31536000
(insert mastodon-http--example-400))
(should (equal (mastodon-http--triage
response-buffer
- (lambda ()
+ (lambda (_)
(message "success call")))
"Error 444: some unhappy complaint"))))
diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el
index be72f66..2aa0505 100644
--- a/test/mastodon-tl-tests.el
+++ b/test/mastodon-tl-tests.el
@@ -1090,56 +1090,68 @@ correct value for following, as well as notifications enabled or disabled."
(let ((response-buffer-true (current-buffer)))
(insert mastodon-tl--follow-notify-true-response)
(with-mock
- (mock (mastodon-http--post url-follow-only nil)
- => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-follow-only
- user-name
- user-handle
- "follow")
- "User some-user (@some-user@instance.url) followed!"))
- (mock (mastodon-http--post url-mute nil)
- => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-mute
- user-name
- user-handle
- "mute")
- "User some-user (@some-user@instance.url) muted!"))
- (mock (mastodon-http--post url-block nil)
- => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-block
- user-name
- user-handle
- "block")
- "User some-user (@some-user@instance.url) blocked!")))
+ (mock (mastodon-http--post url-follow-only nil)
+ => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-follow-only
+ user-name
+ user-handle
+ "follow")
+ "User some-user (@some-user@instance.url) followed!")))))
+ (with-temp-buffer
+ (let ((response-buffer-true (current-buffer)))
+ (insert mastodon-tl--follow-notify-true-response)
+ (with-mock
+ (mock (mastodon-http--post url-mute nil)
+ => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-mute
+ user-name
+ user-handle
+ "mute")
+ "User some-user (@some-user@instance.url) muted!")))))
+ (with-temp-buffer
+ (let ((response-buffer-true (current-buffer)))
+ (insert mastodon-tl--follow-notify-true-response)
+ (with-mock
+ (mock (mastodon-http--post url-block nil)
+ => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-block
+ user-name
+ user-handle
+ "block")
+ "User some-user (@some-user@instance.url) blocked!")))))
+ (with-temp-buffer
+ (let ((response-buffer-true (current-buffer)))
+ (insert mastodon-tl--follow-notify-true-response)
(with-mock
- (mock (mastodon-http--post url-true nil) => response-buffer-true)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-true
- user-name
- user-handle
- "follow"
- "true")
- "Receiving notifications for user some-user (@some-user@instance.url)!")))))
+ (with-mock
+ (mock (mastodon-http--post url-true nil) => response-buffer-true)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-true
+ user-name
+ user-handle
+ "follow"
+ "true")
+ "Receiving notifications for user some-user (@some-user@instance.url)!"))))))
(with-temp-buffer
(let ((response-buffer-false (current-buffer)))
(insert mastodon-tl--follow-notify-false-response)
(with-mock
- (mock (mastodon-http--post url-false nil) => response-buffer-false)
- (should
- (equal
- (mastodon-tl--do-user-action-function url-false
- user-name
- user-handle
- "follow"
- "false")
- "Not receiving notifications for user some-user (@some-user@instance.url)!")))))))
+ (mock (mastodon-http--post url-false nil) => response-buffer-false)
+ (should
+ (equal
+ (mastodon-tl--do-user-action-function url-false
+ user-name
+ user-handle
+ "follow"
+ "false")
+ "Not receiving notifications for user some-user (@some-user@instance.url)!")))))))
(ert-deftest mastodon-tl--report-to-mods-params-alist ()
""
diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el
index 5efe2e1..6133453 100644
--- a/test/mastodon-toot-tests.el
+++ b/test/mastodon-toot-tests.el
@@ -180,7 +180,7 @@ mention string."
=> "https://example.space/statuses/61208/pin")
(mock (mastodon-http--post "https://example.space/statuses/61208/pin")
=> pin-response)
- (should (equal (mastodon-toot--action "pin" (lambda ()
+ (should (equal (mastodon-toot--action "pin" (lambda (_)
(message "Toot pinned!")))
"Toot pinned!"))))))