aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-views.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-08-14 13:57:24 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-08-14 13:57:24 +0200
commit5e2e14b1f9aee068d3b59c4d319fa923114b9f71 (patch)
treeaf192787231d1a4db9ff4ced3d8ad76c08998264 /lisp/mastodon-views.el
parentd18f86a0e21b17eb67685c4c0500819e864d4427 (diff)
get filter kw, update filter kw
Diffstat (limited to 'lisp/mastodon-views.el')
-rw-r--r--lisp/mastodon-views.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el
index 0d0277e..8c36f27 100644
--- a/lisp/mastodon-views.el
+++ b/lisp/mastodon-views.el
@@ -700,6 +700,33 @@ Prompt for a context, must be a list containting at least one of \"home\",
(mastodon-views--view-filters)
(message "Filter \"%s\" deleted!" title))))))))
+(defun mastodon-views--get-filter-kw (&optional id)
+ "GET filter with ID."
+ (let* ((id (or id (mastodon-tl--property 'kw-id :no-move)))
+ (url (mastodon-http--api-v2 (format "filters/keywords/%s" id)))
+ (resp (mastodon-http--get-json url)))
+ resp))
+
+(defun mastodon-views--update-filter-kw ()
+ "Update filter keyword at point.
+Prmopt to change the term, and the whole words option.
+When t, whole words means only match whole words."
+ (interactive)
+ (let* ((id (mastodon-tl--property 'kw-id :no-move))
+ (kw (mastodon-views--get-filter-kw id))
+ (keyword (read-string "Keyword: " (alist-get 'keyword kw)))
+ (whole-word (if (y-or-n-p "Match whole words only? ")
+ "true"
+ "false"))
+ (params `(("keyword" . ,keyword)
+ ("whole_word" . ,whole-word)))
+ (url (mastodon-http--api-v2 (format "filters/keywords/%s" id)))
+ (resp (mastodon-http--put url params)))
+ (mastodon-http--triage
+ resp
+ (lambda (resp)
+ (message (format "Keyword %s updated!" keyword))))))
+
;;; FOLLOW SUGGESTIONS
;; No pagination: max 80 results