diff options
-rw-r--r-- | README.org | 2 | ||||
-rw-r--r-- | lisp/mastodon-inspect.el | 26 | ||||
-rw-r--r-- | lisp/mastodon-notifications.el | 16 | ||||
-rw-r--r-- | lisp/mastodon-profile.el | 34 | ||||
-rw-r--r-- | lisp/mastodon-search.el | 7 | ||||
-rw-r--r-- | lisp/mastodon-tl.el | 138 | ||||
-rw-r--r-- | lisp/mastodon-toot.el | 58 | ||||
-rw-r--r-- | lisp/mastodon-views.el | 22 | ||||
-rw-r--r-- | mastodon.info | 24 | ||||
-rw-r--r-- | mastodon.texi | 4 | ||||
-rw-r--r-- | test/mastodon-profile-tests.el | 4 | ||||
-rw-r--r-- | test/mastodon-tl-tests.el | 66 | ||||
-rw-r--r-- | test/mastodon-toot-tests.el | 10 |
13 files changed, 208 insertions, 203 deletions
@@ -390,7 +390,7 @@ to your translator function as its text argument. Here's what "Translate text of toot at point. Uses `lingva.el'." (interactive) - (let* ((toot (mastodon-tl--property 'toot-json))) + (let* ((toot (mastodon-tl--property 'item-json))) (if toot (lingva-translate nil (mastodon-tl--content toot)) (message "No toot to translate?")))) diff --git a/lisp/mastodon-inspect.el b/lisp/mastodon-inspect.el index c332dde..0a278ab 100644 --- a/lisp/mastodon-inspect.el +++ b/lisp/mastodon-inspect.el @@ -62,21 +62,21 @@ (interactive) (mastodon-inspect--dump-json-in-buffer (concat "*mastodon-inspect-toot-" - (mastodon-tl--as-string (mastodon-tl--property 'toot-id)) + (mastodon-tl--as-string (mastodon-tl--property 'item-id)) "*") - (mastodon-tl--property 'toot-json))) + (mastodon-tl--property 'item-json))) -(defun mastodon-inspect--download-single-toot (toot-id) - "Download the toot/status represented by TOOT-ID." +(defun mastodon-inspect--download-single-toot (item-id) + "Download the toot/status represented by ITEM-ID." (mastodon-http--get-json - (mastodon-http--api (concat "statuses/" toot-id)))) + (mastodon-http--api (concat "statuses/" item-id)))) -(defun mastodon-inspect--view-single-toot (toot-id) - "View the toot/status represented by TOOT-ID." +(defun mastodon-inspect--view-single-toot (item-id) + "View the toot/status represented by ITEM-ID." (interactive "s Toot ID: ") - (let ((buffer (get-buffer-create (concat "*mastodon-status-" toot-id "*")))) + (let ((buffer (get-buffer-create (concat "*mastodon-status-" item-id "*")))) (with-current-buffer buffer - (let ((toot (mastodon-inspect--download-single-toot toot-id ))) + (let ((toot (mastodon-inspect--download-single-toot item-id ))) (mastodon-tl--toot toot) (goto-char (point-min)) (while (search-forward "\n\n\n | " nil t) @@ -85,12 +85,12 @@ (switch-to-buffer-other-window buffer) (mastodon-mode))) -(defun mastodon-inspect--view-single-toot-source (toot-id) - "View the ess source of a toot/status represented by TOOT-ID." +(defun mastodon-inspect--view-single-toot-source (item-id) + "View the ess source of a toot/status represented by ITEM-ID." (interactive "s Toot ID: ") (mastodon-inspect--dump-json-in-buffer - (concat "*mastodon-status-raw-" toot-id "*") - (mastodon-inspect--download-single-toot toot-id))) + (concat "*mastodon-status-raw-" item-id "*") + (mastodon-inspect--download-single-toot item-id))) (defvar mastodon-inspect--search-query-accounts-result) diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 5f6d1ba..cce5810 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -50,7 +50,7 @@ (autoload 'mastodon-tl--property "mastodon-tl") (autoload 'mastodon-tl--reload-timeline-or-profile "mastodon-tl") (autoload 'mastodon-tl--spoiler "mastodon-tl") -(autoload 'mastodon-tl--toot-id "mastodon-tl") +(autoload 'mastodon-tl--item-id "mastodon-tl") (autoload 'mastodon-tl--update "mastodon-tl") (autoload 'mastodon-views--view-follow-requests "mastodon-views") @@ -98,17 +98,17 @@ With no argument, the request is accepted. Argument REJECT means reject the request. Can be called in notifications view or in follow-requests view." - (if (not (mastodon-tl--find-property-range 'toot-json (point))) + (if (not (mastodon-tl--find-property-range 'item-json (point))) (message "No follow request at point?") - (let* ((toot-json (mastodon-tl--property 'toot-json)) + (let* ((item-json (mastodon-tl--property 'item-json)) (f-reqs-view-p (string= "follow_requests" (plist-get mastodon-tl--buffer-spec 'endpoint))) - (f-req-p (or (string= "follow_request" (alist-get 'type toot-json)) ;notifs + (f-req-p (or (string= "follow_request" (alist-get 'type item-json)) ;notifs f-reqs-view-p))) (if (not f-req-p) (message "No follow request at point?") - (let-alist (or (alist-get 'account toot-json) ;notifs - toot-json) ;f-reqs + (let-alist (or (alist-get 'account item-json) ;notifs + item-json) ;f-reqs (if .id (let ((response (mastodon-http--post @@ -319,9 +319,9 @@ Status notifications are created when you call (defun mastodon-notifications--clear-current () "Dismiss the notification at point." (interactive) - (let* ((id (or (mastodon-tl--property 'toot-id) + (let* ((id (or (mastodon-tl--property 'item-id) (mastodon-tl--field 'id - (mastodon-tl--property 'toot-json)))) + (mastodon-tl--property 'item-json)))) (response (mastodon-http--post (mastodon-http--api (format "notifications/%s/dismiss" id))))) diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 365e352..9850b81 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -74,7 +74,7 @@ (autoload 'mastodon-tl--symbol "mastodon-tl") (autoload 'mastodon-tl--timeline "mastodon-tl.el") (autoload 'mastodon-tl--toot "mastodon-tl") -(autoload 'mastodon-tl--toot-id "mastodon-tl") +(autoload 'mastodon-tl--item-id "mastodon-tl") (autoload 'mastodon-toot--count-toot-chars "mastodon-toot") (autoload 'mastodon-toot--get-max-toot-chars "mastodon-toot") (autoload 'mastodon-views--add-account-to-list "mastodon-views") @@ -136,10 +136,10 @@ contains") :keymap mastodon-profile-update-mode-map :global nil) -(defun mastodon-profile--toot-json () - "Get the next toot-json." +(defun mastodon-profile--item-json () + "Get the next item-json." (interactive) - (mastodon-tl--property 'toot-json)) + (mastodon-tl--property 'item-json)) (defun mastodon-profile--make-author-buffer (account &optional no-reblogs) "Take an ACCOUNT json and insert a user account into a new buffer. @@ -679,7 +679,7 @@ the format \"2000-01-31T00:00:00.000Z\"." If toot is a boost, opens the profile of the booster." (interactive) (mastodon-profile--make-author-buffer - (alist-get 'account (mastodon-profile--toot-json)))) + (alist-get 'account (mastodon-profile--item-json)))) (defun mastodon-profile--image-from-account (account img-type) "Return a avatar image from ACCOUNT. @@ -693,21 +693,21 @@ IMG-TYPE is the JSON key from the account data." (interactive (list (if (and (not (mastodon-tl--profile-buffer-p)) - (not (mastodon-tl--property 'toot-json :no-move))) + (not (mastodon-tl--property 'item-json :no-move))) (message "Looks like there's no toot or user at point?") (let ((user-handles (mastodon-profile--extract-users-handles - (mastodon-profile--toot-json)))) + (mastodon-profile--item-json)))) (completing-read "View profile of user [choose or enter any handle]: " user-handles nil ; predicate 'confirm))))) - (if (not (or ; own profile has no need for toot-json test: + (if (not (or ; own profile has no need for item-json test: (equal user-handle (mastodon-auth--get-account-name)) (mastodon-tl--profile-buffer-p) - (mastodon-tl--property 'toot-json :no-move))) + (mastodon-tl--property 'item-json :no-move))) (message "Looks like there's no toot or user at point?") (let ((account (mastodon-profile--lookup-account-in-status - user-handle (mastodon-profile--toot-json)))) + user-handle (mastodon-profile--item-json)))) (if account (progn (message "Loading profile of user %s..." user-handle) @@ -733,14 +733,14 @@ Used to view a user's followers and those they're following." (propertize (mastodon-tl--byline-author `((account . ,toot)) :avatar) 'byline 't - 'toot-id (alist-get 'id toot) - 'base-toot-id (mastodon-tl--toot-id toot) - 'toot-json toot)) + 'item-id (alist-get 'id toot) + 'base-item-id (mastodon-tl--item-id toot) + 'item-json toot)) (mastodon-media--inline-images start-pos (point)) (insert "\n" (propertize (mastodon-tl--render-text (alist-get 'note toot) nil) - 'toot-json toot) + 'item-json toot) "\n"))) tootv)))) @@ -805,7 +805,7 @@ These include the author, author of reblogged entries and any user mentioned." "Remove a user from your followers. Optionally provide the ID of the account to remove." (interactive) - (let* ((account (unless id (mastodon-tl--property 'toot-json :no-move))) + (let* ((account (unless id (mastodon-tl--property 'item-json :no-move))) (id (or id (alist-get 'id account))) (handle (if account (alist-get 'acct account) @@ -823,10 +823,10 @@ Optionally provide the ID of the account to remove." "Prompt for a user in the item at point and remove from followers." (interactive) (let* ((handles (mastodon-profile--extract-users-handles - (mastodon-profile--toot-json))) + (mastodon-profile--item-json))) (handle (completing-read "Remove from followers: " handles nil)) (account (mastodon-profile--lookup-account-in-status - handle (mastodon-profile--toot-json))) + handle (mastodon-profile--item-json))) (id (alist-get 'id account))) (mastodon-profile--remove-user-from-followers id))) diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index 9b4bb68..1f39088 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -261,7 +261,8 @@ If NOTE is non-nil, include user's profile note. This is also (propertize (car user) 'face 'mastodon-display-name-face 'byline t - 'toot-id id) ; for prev/next nav + 'item-type 'user + 'item-id id) ; for prev/next nav " : \n : " (propertize (concat "@" (cadr user)) 'face 'mastodon-handle-face @@ -275,7 +276,7 @@ If NOTE is non-nil, include user's profile note. This is also (mastodon-tl--render-text (cadddr user) acct) "") "\n") - 'toot-json acct))) ; for compat w other processing functions + 'item-json acct))) ; for compat w other processing functions (defun mastodon-search--print-tags (tags) "Print TAGS data as returned from a \"hashtags\" search query." @@ -292,6 +293,8 @@ If NOTE is non-nil, include user's profile note. This is also 'mouse-face 'highlight 'mastodon-tag (car el) 'mastodon-tab-stop 'hashtag + 'item-type 'tag ; for next/prev nav + 'byline t ; for next/prev nav 'help-echo (concat "Browse tag #" (car el)) 'keymap mastodon-tl--link-keymap) " : \n\n")) diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b0c121a..1600b49 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -69,7 +69,7 @@ (autoload 'mastodon-profile--open-statuses-no-reblogs "mastodon-profile") (autoload 'mastodon-profile--profile-json "mastodon-profile") (autoload 'mastodon-profile--search-account-by-handle "mastodon-profile") -(autoload 'mastodon-profile--toot-json "mastodon-profile") +(autoload 'mastodon-profile--item-json "mastodon-profile") (autoload 'mastodon-profile--view-author-profile "mastodon-profile") (autoload 'mastodon-profile-mode "mastodon-profile") (autoload 'mastodon-search--get-user-info "mastodon-search") @@ -295,18 +295,19 @@ than `switch-to-buffer'." (switch-to-buffer ,buffer)) ,@body))) -(defmacro mastodon-tl--do-if-toot (&rest body) - "Execute BODY if we have a toot or user at point." +(defmacro mastodon-tl--do-if-item (&rest body) + "Execute BODY if we have an item at point." (declare (debug t)) `(if (and (not (mastodon-tl--profile-buffer-p)) - (not (mastodon-tl--property 'toot-json))) ; includes user listings - (message "Looks like there's no toot or user at point?") + (not (mastodon-tl--property 'item-json))) ; includes users, hashtags + (message "Looks like there's no item at point?") ,@body)) (defmacro mastodon-tl--do-if-toot-strict (&rest body) - "Execute BODY if we have a toot, and only a toot, at point." + "Execute BODY if we have a toot object at point. +Includes boosts, and notifications that display toots." (declare (debug t)) - `(if (not (mastodon-tl--property 'toot-id :no-move)) + `(if (not (equal 'toot (mastodon-tl--property 'item-type :no-move))) (message "Looks like there's no toot at point?") ,@body)) @@ -354,24 +355,21 @@ text, i.e. hidden spoiler text." (interactive) (mastodon-tl--next-tab-item :previous)) -(defun mastodon-tl--goto-toot-pos (find-pos refresh &optional pos) - "Search for toot with FIND-POS. +(defun mastodon-tl--goto-item-pos (find-pos refresh &optional pos) + "Search for item with function FIND-POS. If search returns nil, execute REFRESH function. Optionally start from POS." (let* ((npos (or ; toot/user items have byline: (funcall find-pos (or pos (point)) + ;; 'item-type ; breaks nav to last item in a view? 'byline - (current-buffer)) - ;; some other things don't, so just tab-stop: - (funcall find-pos - (or pos (point)) - 'mastodon-tab-stop (current-buffer))))) (if npos - (if (not (or (get-text-property npos 'toot-id) ; toots, etc. - (get-text-property npos 'mastodon-tab-stop))) ; generic - (mastodon-tl--goto-toot-pos find-pos refresh npos) + (if (not (or + ;; (get-text-property npos 'item-id) ; toots, users, not tags + (get-text-property npos 'item-type))) ; generic + (mastodon-tl--goto-item-pos find-pos refresh npos) (goto-char npos) ;; force display of help-echo on moving to a toot byline: (mastodon-tl--message-help-echo)) @@ -380,13 +378,13 @@ Optionally start from POS." (defun mastodon-tl--goto-next-toot () "Jump to next toot header." (interactive) - (mastodon-tl--goto-toot-pos 'next-single-property-change + (mastodon-tl--goto-item-pos 'next-single-property-change 'mastodon-tl--more)) (defun mastodon-tl--goto-prev-toot () "Jump to last toot header." (interactive) - (mastodon-tl--goto-toot-pos 'previous-single-property-change + (mastodon-tl--goto-item-pos 'previous-single-property-change 'mastodon-tl--update)) (defun mastodon-tl--goto-first-item () @@ -401,13 +399,13 @@ Used on initializing a timeline or thread." (defun mastodon-tl--goto-next-item () "Jump to next item, e.g. filter or follow request." (interactive) - (mastodon-tl--goto-toot-pos 'next-single-property-change + (mastodon-tl--goto-item-pos 'next-single-property-change 'next-line)) (defun mastodon-tl--goto-prev-item () "Jump to previous item, e.g. filter or follow request." (interactive) - (mastodon-tl--goto-toot-pos 'previous-single-property-change + (mastodon-tl--goto-item-pos 'previous-single-property-change 'previous-line)) @@ -490,7 +488,7 @@ With a double PREFIX arg, limit results to your own instance." "Call message on `help-echo' property at point. Do so if type of status at poins is not follow_request/follow." (let ((type (alist-get 'type - (mastodon-tl--property 'toot-json :no-move))) + (mastodon-tl--property 'item-json :no-move))) (echo (mastodon-tl--property 'help-echo :no-move))) (when echo ; not for followers/following in profile (unless (or (string= type "follow_request") @@ -970,9 +968,9 @@ content should be hidden." "Toggle the visibility of the spoiler text in the current toot." (interactive) (let* ((toot-range (or (mastodon-tl--find-property-range - 'toot-json (point)) + 'item-json (point)) (mastodon-tl--find-property-range - 'toot-json (point) t))) + 'item-json (point) t))) (spoiler-range (when toot-range (mastodon-tl--find-property-range 'mastodon-content-warning-body @@ -1196,7 +1194,7 @@ displayed when the duration is smaller than a minute)." (defun mastodon-tl--read-poll-option () "Read a poll option to vote on a poll." - (let* ((toot (mastodon-tl--property 'toot-json)) + (let* ((toot (mastodon-tl--property 'item-json)) (poll (mastodon-tl--field 'poll toot)) (options (mastodon-tl--field 'options poll)) (options-titles (mastodon-tl--map-alist 'title options)) @@ -1221,9 +1219,9 @@ displayed when the duration is smaller than a minute)." (defun mastodon-tl--poll-vote (option) "If there is a poll at point, prompt user for OPTION to vote on it." (interactive (mastodon-tl--read-poll-option)) - (if (null (mastodon-tl--field 'poll (mastodon-tl--property 'toot-json))) + (if (null (mastodon-tl--field 'poll (mastodon-tl--property 'item-json))) (message "No poll here.") - (let* ((toot (mastodon-tl--property 'toot-json)) + (let* ((toot (mastodon-tl--property 'item-json)) (poll (mastodon-tl--field 'poll toot)) (poll-id (alist-get 'id poll)) (url (mastodon-http--api (format "polls/%s/votes" poll-id))) @@ -1304,16 +1302,16 @@ Runs `mastodon-tl--render-text' and fetches poll or media." (mastodon-tl--get-poll toot)) (mastodon-tl--media toot)))) -(defun mastodon-tl--prev-toot-id () +(defun mastodon-tl--prev-item-id () "Return the id of the last toot inserted into the buffer." (let ((prev-pos (1- (save-excursion - (previous-single-property-change (point) 'base-toot-id))))) - (get-text-property prev-pos 'base-toot-id))) + (previous-single-property-change (point) 'base-item-id))))) + (get-text-property prev-pos 'base-item-id))) (defun mastodon-tl--after-reply-status (reply-to-id) "T if REPLY-TO-ID is equal to that of the last toot inserted in the bufer." - (let ((prev-id (mastodon-tl--prev-toot-id))) + (let ((prev-id (mastodon-tl--prev-item-id))) (string= reply-to-id prev-id))) (defun mastodon-tl--insert-status (toot body author-byline action-byline @@ -1328,7 +1326,7 @@ such as boosting favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'. ID is that of the status if it is a notification, which is -attached as a `toot-id' property if provided. If the +attached as a `item-id' property if provided. If the status is a favourite or boost notification, BASE-TOOT is the JSON of the toot responded to. DETAILED-P means display more detailed info. For now @@ -1355,14 +1353,15 @@ THREAD means the status will be displayed in a thread view." body) " \n" (mastodon-tl--byline toot author-byline action-byline detailed-p)) - 'toot-id (or id ; notification's own id + 'item-type 'toot + 'item-id (or id ; notification's own id (alist-get 'id toot)) ; toot id - 'base-toot-id (mastodon-tl--toot-id + 'base-item-id (mastodon-tl--item-id ;; if status is a notif, get id from base-toot - ;; (-tl--toot-id toot) will not work here: + ;; (-tl--item-id toot) will not work here: (or base-toot toot)) ; else normal toot with reblog check - 'toot-json toot + 'item-json toot 'base-toot base-toot 'cursor-face 'mastodon-cursor-highlight-face) "\n") @@ -1373,7 +1372,7 @@ THREAD means the status will be displayed in a thread view." (defun mastodon-tl--toot-for-stats (&optional toot) "Return the TOOT on which we want to extract stats. If no TOOT is given, the one at point is considered." - (let* ((original-toot (or toot (get-text-property (point) 'toot-json))) + (let* ((original-toot (or toot (get-text-property (point) 'item-json))) (toot (or (alist-get 'status original-toot) (when (alist-get 'type original-toot) original-toot) @@ -1710,16 +1709,16 @@ BACKWARD means move backward (up) the timeline." (get-text-property (point) prop))))) (defun mastodon-tl--newest-id () - "Return toot-id from the top of the buffer." + "Return item-id from the top of the buffer." (save-excursion (goto-char (point-min)) - (mastodon-tl--property 'toot-id))) + (mastodon-tl--property 'item-id))) (defun mastodon-tl--oldest-id () - "Return toot-id from the bottom of the buffer." + "Return item-id from the bottom of the buffer." (save-excursion (goto-char (point-max)) - (mastodon-tl--property 'toot-id nil :backward))) + (mastodon-tl--property 'item-id nil :backward))) (defun mastodon-tl--as-string (numeric) "Convert NUMERIC to string." @@ -1729,7 +1728,7 @@ BACKWARD means move backward (up) the timeline." (t (error "Numeric:%s must be either a string or a number" numeric)))) -(defun mastodon-tl--toot-id (json) +(defun mastodon-tl--item-id (json) "Find approproiate toot id in JSON. If the toot has been boosted use the id found in the reblog portion of the toot. Otherwise, use the body of @@ -1775,14 +1774,14 @@ view all branches of a thread." (if (not (eq (mastodon-tl--get-buffer-type) 'thread)) (user-error "You need to be viewing a thread to call this") (goto-char (point-min)) - (let ((id (mastodon-tl--property 'base-toot-id))) + (let ((id (mastodon-tl--property 'base-item-id))) (mastodon-tl--thread id)))) (defun mastodon-tl--thread (&optional id) "Open thread buffer for toot at point or with ID." (interactive) - (let* ((id (or id (mastodon-tl--property 'base-toot-id :no-move))) - (type (mastodon-tl--field 'type (mastodon-tl--property 'toot-json :no-move)))) + (let* ((id (or id (mastodon-tl--property 'base-item-id :no-move))) + (type (mastodon-tl--field 'type (mastodon-tl--property 'item-json :no-move)))) (if (or (string= type "follow_request") (string= type "follow")) ; no can thread these (user-error "No thread") @@ -1839,7 +1838,7 @@ If UNMUTE, unmute it." (mastodon-tl--buffer-type-eq 'notifications)) (let* ((id (if (mastodon-tl--buffer-type-eq 'notifications) - (get-text-property (point) 'base-toot-id) + (get-text-property (point) 'base-item-id) (save-match-data (string-match "statuses/\\(?2:[[:digit:]]+\\)/context" endpoint) @@ -1887,7 +1886,7 @@ Can be called to toggle NOTIFY on users already being followed. LANGS is an array parameters alist of languages to filer user's posts by." (interactive (list (mastodon-tl--user-handles-get "follow"))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-tl--do-user-action-and-response user-handle "follow" nil notify langs))) @@ -1895,7 +1894,7 @@ LANGS is an array parameters alist of languages to filer user's posts by." "Query for USER-HANDLE and enable notifications when they post." (interactive (list (mastodon-tl--user-handles-get "enable"))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-tl--follow-user user-handle "true"))) (defun mastodon-tl--disable-notify-user-posts (user-handle) @@ -1911,7 +1910,7 @@ the instance API." (interactive (list (mastodon-tl--user-handles-get "filter by language"))) (let ((langs (mastodon-tl--read-filter-langs))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-tl--follow-user user-handle nil langs)))) (defun mastodon-tl--read-filter-langs (&optional langs) @@ -1933,14 +1932,14 @@ LANGS is the accumulated array param alist if we re-run recursively." "Query for USER-HANDLE from current status and unfollow that user." (interactive (list (mastodon-tl--user-handles-get "unfollow"))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-tl--do-user-action-and-response user-handle "unfollow" t))) (defun mastodon-tl--block-user (user-handle) "Query for USER-HANDLE from current status and block that user." (interactive (list (mastodon-tl--user-handles-get "block"))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-tl--do-user-action-and-response user-handle "block"))) (defun mastodon-tl--unblock-user (user-handle) @@ -1955,7 +1954,7 @@ LANGS is the accumulated array param alist if we re-run recursively." "Query for USER-HANDLE from current status and mute that user." (interactive (list (mastodon-tl--user-handles-get "mute"))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-tl--do-user-action-and-response user-handle "mute"))) (defun mastodon-tl--unmute-user (user-handle) @@ -1970,14 +1969,14 @@ LANGS is the accumulated array param alist if we re-run recursively." "Query for USER-HANDLE from current status and compose a message to that user." (interactive (list (mastodon-tl--user-handles-get "message"))) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (mastodon-toot--compose-buffer (concat "@" user-handle)) (setq mastodon-toot--visibility "direct") (mastodon-toot--update-status-fields))) (defun mastodon-tl--user-handles-get (action) "Get the list of user-handles for ACTION from the current toot." - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (let ((user-handles (cond ((or ; follow suggests / search / foll requests compat: (mastodon-tl--buffer-type-eq 'follow-suggestions) @@ -1986,9 +1985,9 @@ LANGS is the accumulated array param alist if we re-run recursively." ;; profile follows/followers but not statuses: (mastodon-tl--buffer-type-eq 'profile-followers) (mastodon-tl--buffer-type-eq 'profile-following)) - ;; fetch 'toot-json: + ;; fetch 'item-json: (list (alist-get 'acct - (mastodon-tl--property 'toot-json :no-move)))) + (mastodon-tl--property 'item-json :no-move)))) ;; profile view, point in profile details, poss no toots ;; needed for e.g. gup.pe groups which show no toots publically: ((and (mastodon-tl--profile-buffer-p) @@ -1997,7 +1996,7 @@ LANGS is the accumulated array param alist if we re-run recursively." (mastodon-profile--profile-json)))) (t (mastodon-profile--extract-users-handles - (mastodon-profile--toot-json)))))) + (mastodon-profile--item-json)))))) ;; return immediately if only 1 handle: (if (eq 1 (length user-handles)) (car user-handles) @@ -2040,7 +2039,7 @@ LANGS is an array parameters alist of languages to filer user's posts by." user-handle (mastodon-profile--profile-json)) ;; muting/blocking, select from handles in current status (mastodon-profile--lookup-account-in-status - user-handle (mastodon-profile--toot-json))))) + user-handle (mastodon-profile--item-json))))) (user-id (alist-get 'id account)) (name (if (string-empty-p (alist-get 'display_name account)) (alist-get 'username account) @@ -2087,7 +2086,7 @@ ARGS is an alist of any parameters to send with the request." (defun mastodon-tl--get-tags-list () "Return the list of tags of the toot at point." (let* ((toot (or (mastodon-tl--property 'base-toot :no-move) ; fave/boost notifs - (mastodon-tl--property 'toot-json :no-move))) + (mastodon-tl--property 'item-json :no-move))) (tags (mastodon-tl--field 'tags toot))) (mapcar (lambda (x) (alist-get 'name x)) @@ -2173,25 +2172,25 @@ PREFIX is for `mastodon-tl--show-tag-timeline', which see." ACCOUNT and TOOT are the data to use." (let* ((account-id (alist-get 'id account)) (comment (read-string "Add comment [optional]: ")) - (toot-id (when (y-or-n-p "Also report status at point? ") - (mastodon-tl--toot-id toot))) ; base toot if poss + (item-id (when (y-or-n-p "Also report status at point? ") + (mastodon-tl--item-id toot))) ; base toot if poss (forward-p (when (y-or-n-p "Forward to remote admin? ") "true")) (rules (when (y-or-n-p "Cite a rule broken? ") (mastodon-tl--read-rules-ids))) (cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other")))) - (mastodon-tl--report-build-params account-id comment toot-id + (mastodon-tl--report-build-params account-id comment item-id forward-p cat rules))) (defun mastodon-tl--report-build-params - (account-id comment toot-id forward-p cat &optional rules) + (account-id comment item-id forward-p cat &optional rules) "Build the parameters alist based on user responses. -ACCOUNT-ID, COMMENT, TOOT-ID, FORWARD-P, CAT, and RULES are all from +ACCOUNT-ID, COMMENT, ITEM-ID, FORWARD-P, CAT, and RULES are all from `mastodon-tl--report-params', which see." (let ((params `(("account_id" . ,account-id) ,(when comment `("comment" . ,comment)) - ,(when toot-id - `("status_ids[]" . ,toot-id)) + ,(when item-id + `("status_ids[]" . ,item-id)) ,(when forward-p `("forward" . ,forward-p)) ,(when cat @@ -2212,11 +2211,11 @@ Optionally report the toot at point, add a comment, cite rules that have been broken, forward the report to the remove admin, report the account for spam." (interactive) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (when (y-or-n-p "Report author of toot at point?") (let* ((url (mastodon-http--api "reports")) (toot (mastodon-tl--toot-or-base - (mastodon-tl--property 'toot-json :no-move))) + (mastodon-tl--property 'item-json :no-move))) (account (alist-get 'account toot)) (handle (alist-get 'acct account)) (params (mastodon-tl--report-params account toot)) @@ -2599,6 +2598,7 @@ This location is defined by a non-nil value of (interactive) (if (or (mastodon-tl--buffer-type-eq 'trending-statuses) (mastodon-tl--buffer-type-eq 'trending-tags) + (mastodon-tl--buffer-type-eq 'follow-suggestions) (mastodon-tl--search-buffer-p)) (message "update not available in this view.") ;; FIXME: handle update for search and trending buffers @@ -2606,7 +2606,7 @@ This location is defined by a non-nil value of (update-function (mastodon-tl--update-function))) ;; update a thread, without calling `mastodon-tl--updated-json': (if (mastodon-tl--buffer-type-eq 'thread) - (let ((thread-id (mastodon-tl--property 'toot-id))) + (let ((thread-id (mastodon-tl--property 'item-id))) (funcall update-function thread-id)) ;; update other timelines: (let* ((id (mastodon-tl--newest-id)) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 51e0458..e9b98dd 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -75,7 +75,7 @@ (autoload 'mastodon-tl--as-string "mastodon-tl") (autoload 'mastodon-tl--buffer-type-eq "mastodon-tl") (autoload 'mastodon-tl--clean-tabs-and-nl "mastodon-tl") -(autoload 'mastodon-tl--do-if-toot-strict "mastodon-tl") +(autoload 'mastodon-tl--do-if-item-strict "mastodon-tl") (autoload 'mastodon-tl--field "mastodon-tl") (autoload 'mastodon-tl--find-property-range "mastodon-tl") (autoload 'mastodon-tl--find-property-range "mastodon-tl") @@ -86,7 +86,7 @@ (autoload 'mastodon-tl--render-text "mastodon-tl") (autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") (autoload 'mastodon-tl--symbol "mastodon-tl") -(autoload 'mastodon-tl--toot-id "mastodon-tl") +(autoload 'mastodon-tl--item-id "mastodon-tl") (autoload 'mastodon-toot "mastodon") (autoload 'mastodon-views--cancel-scheduled-toot "mastodon-views") (autoload 'mastodon-views--view-scheduled-toots "mastodon-views") @@ -203,7 +203,7 @@ Should be at least 5 minutes into the future.") (defvar-local mastodon-toot--reply-to-id nil "Buffer-local variable to hold the id of the toot being replied to.") -(defvar-local mastodon-toot--edit-toot-id nil +(defvar-local mastodon-toot--edit-item-id nil "The id of the toot being edited.") (defvar-local mastodon-toot-previous-window-config nil @@ -335,7 +335,7 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." "Take ACTION on toot at point, then execute CALLBACK. Makes a POST request to the server. Used for favouriting, boosting, or bookmarking toots." - (let* ((id (mastodon-tl--property 'base-toot-id)) + (let* ((id (mastodon-tl--property 'base-item-id)) (url (mastodon-http--api (concat "statuses/" (mastodon-tl--as-string id) "/" action))) (response (mastodon-http--post url))) @@ -344,13 +344,13 @@ boosting, or bookmarking toots." (defun mastodon-toot--toggle-boost-or-favourite (type) "Toggle boost or favourite of toot at `point'. TYPE is a symbol, either `favourite' or `boost.'" - (mastodon-tl--do-if-toot-strict + (mastodon-tl--do-if-item-strict (let* ((boost-p (equal type 'boost)) - ;; (has-id (mastodon-tl--property 'base-toot-id)) + ;; (has-id (mastodon-tl--property 'base-item-id)) (byline-region ;(when has-id (mastodon-tl--find-property-range 'byline (point))) (id (when byline-region - (mastodon-tl--as-string (mastodon-tl--property 'base-toot-id)))) + (mastodon-tl--as-string (mastodon-tl--property 'base-item-id)))) (boosted (when byline-region (get-text-property (car byline-region) 'boosted-p))) (faved (when byline-region @@ -361,16 +361,16 @@ TYPE is a symbol, either `favourite' or `boost.'" (msg (if boosted "unboosted" "boosted")) (action-string (if boost-p "boost" "favourite")) (remove (if boost-p (when boosted t) (when faved t))) - (toot-json (mastodon-tl--property 'toot-json)) - (toot-type (alist-get 'type toot-json)) - (visibility (mastodon-tl--field 'visibility toot-json))) + (item-json (mastodon-tl--property 'item-json)) + (toot-type (alist-get 'type item-json)) + (visibility (mastodon-tl--field 'visibility item-json))) (if byline-region (if (and (or (equal visibility "direct") (equal visibility "private")) boost-p) (message "You cant boost posts with visibility: %s" visibility) (cond ;; actually there's nothing wrong with faving/boosting own toots! - ;;((mastodon-toot--own-toot-p (mastodon-tl--property 'toot-json)) + ;;((mastodon-toot--own-toot-p (mastodon-tl--property 'item-json)) ;;(error "You can't %s your own toots" action-string)) ;; & nothing wrong with faving/boosting own toots from notifs: ;; this boosts/faves the base toot, not the notif status @@ -443,8 +443,8 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement." (defun mastodon-toot--toggle-bookmark () "Bookmark or unbookmark toot at point." (interactive) - (mastodon-tl--do-if-toot-strict - (let* ((id (mastodon-tl--property 'base-toot-id)) + (mastodon-tl--do-if-item-strict + (let* ((id (mastodon-tl--property 'base-item-id)) (bookmarked-p (mastodon-tl--property 'bookmarked-p)) (prompt (if bookmarked-p (format "Toot already bookmarked. Remove? ") @@ -484,8 +484,8 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement." (defun mastodon-toot--list-toot-boosters-or-favers (&optional favourite) "List the favouriters or boosters of toot at point. With FAVOURITE, list favouriters, else list boosters." - (mastodon-tl--do-if-toot-strict - (let* ((base-toot (mastodon-tl--property 'base-toot-id)) + (mastodon-tl--do-if-item-strict + (let* ((base-toot (mastodon-tl--property 'base-item-id)) (endpoint (if favourite "favourited_by" "reblogged_by")) (url (mastodon-http--api (format "statuses/%s/%s" base-toot endpoint))) (params '(("limit" . "80"))) @@ -515,7 +515,7 @@ base toot." (defun mastodon-toot--toot-url () "Return the URL of the base toot at point." (let* ((toot (or (mastodon-tl--property 'base-toot) - (mastodon-tl--property 'toot-json)))) + (mastodon-tl--property 'item-json)))) (if (mastodon-tl--field 'reblog toot) (alist-get 'url (alist-get 'reblog toot)) (alist-get 'url toot)))) @@ -526,7 +526,7 @@ If the toot is a fave/boost notification, copy the text of the base toot." (interactive) (let* ((toot (or (mastodon-tl--property 'base-toot) - (mastodon-tl--property 'toot-json)))) + (mastodon-tl--property 'item-json)))) (kill-new (mastodon-tl--content toot)) (message "Toot content copied to the clipboard."))) @@ -537,7 +537,7 @@ Uses `lingva.el'." (if (not (require 'lingva nil :no-error)) (message "Looks like you need to install lingva.el first.") (if mastodon-tl--buffer-spec - (if-let ((toot (mastodon-tl--property 'toot-json))) + (if-let ((toot (mastodon-tl--property 'item-json))) (lingva-translate nil (mastodon-tl--content toot) (when mastodon-tl--enable-proportional-fonts @@ -555,7 +555,7 @@ Uses `lingva.el'." "Pin or unpin user's toot at point." (interactive) (let* ((toot (or (mastodon-tl--property 'base-toot) ;fave/boost notifs - (mastodon-tl--property 'toot-json))) + (mastodon-tl--property 'item-json))) (pinnable-p (mastodon-toot--own-toot-p toot)) (pinned-p (equal (alist-get 'pinned toot) t)) (action (if pinned-p "unpin" "pin")) @@ -584,8 +584,8 @@ Uses `lingva.el'." NO-REDRAFT means delete toot only." (interactive) (let* ((toot (or (mastodon-tl--property 'base-toot) ;fave/boost notifs - (mastodon-tl--property 'toot-json))) - (id (mastodon-tl--as-string (mastodon-tl--toot-id toot))) + (mastodon-tl--property 'item-json))) + (id (mastodon-tl--as-string (mastodon-tl--item-id toot))) (url (mastodon-http--api (format "statuses/%s" id))) (toot-cw (alist-get 'spoiler_text toot)) (toot-visibility (alist-get 'visibility toot)) @@ -806,13 +806,13 @@ to `emojify-user-emojis', and the emoji data is updated." "POST contents of new-toot buffer to Mastodon instance and kill buffer. If media items have been attached and uploaded with `mastodon-toot--attach-media', they are attached to the toot. -If `mastodon-toot--edit-toot-id' is non-nil, PUT contents to +If `mastodon-toot--edit-item-id' is non-nil, PUT contents to instance to edit a toot." (interactive) (let* ((toot (mastodon-toot--remove-docs)) (scheduled mastodon-toot--scheduled-for) (scheduled-id mastodon-toot--scheduled-id) - (edit-id mastodon-toot--edit-toot-id) + (edit-id mastodon-toot--edit-item-id) (endpoint (if edit-id ; we are sending an edit: (mastodon-http--api (format "statuses/%s" edit-id)) (mastodon-http--api "statuses"))) @@ -879,10 +879,10 @@ instance to edit a toot." "Edit the user's toot at point." (interactive) (let ((toot (or (mastodon-tl--property 'base-toot) ; fave/boost notifs - (mastodon-tl--property 'toot-json)))) + (mastodon-tl--property 'item-json)))) (if (not (mastodon-toot--own-toot-p toot)) (message "You can only edit your own toots.") - (let* ((id (mastodon-tl--as-string (mastodon-tl--toot-id toot))) + (let* ((id (mastodon-tl--as-string (mastodon-tl--item-id toot))) (source (mastodon-toot--get-toot-source id)) (content (alist-get 'text source)) (source-cw (alist-get 'spoiler_text source)) @@ -896,7 +896,7 @@ instance to edit a toot." (mastodon-toot--set-toot-properties reply-id toot-visibility source-cw toot-language) (mastodon-toot--update-status-fields) - (setq mastodon-toot--edit-toot-id id)))))) + (setq mastodon-toot--edit-item-id id)))))) (defun mastodon-toot--get-toot-source (id) "Fetch the source JSON of toot with ID." @@ -911,7 +911,7 @@ instance to edit a toot." (defun mastodon-toot--view-toot-edits () "View editing history of the toot at point in a popup buffer." (interactive) - (let ((id (mastodon-tl--property 'base-toot-id)) + (let ((id (mastodon-tl--property 'base-item-id)) (history (mastodon-tl--property 'edit-history)) (buf "*mastodon-toot-edits*")) (with-mastodon-buffer buf #'special-mode :other-window @@ -1070,8 +1070,8 @@ If TAGS, we search for tags, else we search for handles." Customize `mastodon-toot-display-orig-in-reply-buffer' to display text of the toot being replied to in the compose buffer." (interactive) - (mastodon-tl--do-if-toot-strict - (let* ((toot (mastodon-tl--property 'toot-json)) + (mastodon-tl--do-if-item-strict + (let* ((toot (mastodon-tl--property 'item-json)) ;; no-move arg for base toot: don't try next toot (base-toot (mastodon-tl--property 'base-toot :no-move)) ; for new notifs handling (id (mastodon-tl--as-string (mastodon-tl--field 'id (or base-toot toot)))) diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el index 7a65b30..8571e15 100644 --- a/lisp/mastodon-views.el +++ b/lisp/mastodon-views.el @@ -55,7 +55,7 @@ (autoload 'mastodon-tl--goto-prev-toot "mastodon-tl") (autoload 'mastodon-tl--goto-next-item "mastodon-tl") (autoload 'mastodon-tl--goto-first-item "mastodon-tl") -(autoload 'mastodon-tl--do-if-toot "mastodon-tl") +(autoload 'mastodon-tl--do-if-item "mastodon-tl") (autoload 'mastodon-tl--set-buffer-spec "mastodon-tl") (autoload 'mastodon-tl--render-text "mastodon-tl") (autoload 'mastodon-notifications--follow-request-accept "mastodon-notifications") @@ -179,7 +179,8 @@ provides the JSON data." (format "Looks like you have no %s for now." view-name) 'face 'font-lock-comment-face 'byline t - 'toot-id "0")) ; so point can move here when no item + 'item-type 'no-item ; for nav + 'item-id "0")) ; so point can move here when no item (funcall insert-fun data) (goto-char (point-min))) ;; (when data @@ -226,7 +227,8 @@ provides the JSON data." (insert (propertize list-name 'byline t ; so we nav here - 'toot-id "0" ; so we nav here + 'item-id "0" ; so we nav here + 'item-type 'user 'help-echo "RET: view list timeline, d: delete this list, \ a: add account to this list, r: remove account from this list" 'list t @@ -402,7 +404,7 @@ If ACCOUNT-ID and HANDLE are provided use them rather than prompting." (defun mastodon-views--add-toot-account-at-point-to-list () "Prompt for a list, and add the account of the toot at point to it." (interactive) - (let* ((toot (mastodon-tl--property 'toot-json)) + (let* ((toot (mastodon-tl--property 'item-json)) (account (mastodon-tl--field 'account toot)) (account-id (mastodon-tl--field 'id account)) (handle (mastodon-tl--field 'acct account))) @@ -509,7 +511,7 @@ JSON is the data returned by the server." " | " (mastodon-toot--iso-to-human .scheduled_at)) 'byline t ; so we nav here - 'toot-id "0" ; so we nav here + 'item-id "0" ; so we nav here 'face 'font-lock-comment-face 'keymap mastodon-views--scheduled-map 'scheduled-json toot @@ -614,7 +616,7 @@ JSON is the filters data." (mapconcat #'identity contexts ", ")))) (insert (propertize filter-string - 'toot-id id ;for goto-next-filter compat + 'item-id id ;for goto-next-filter compat 'phrase phrase 'byline t) ;for goto-next-filter compat "\n\n"))) @@ -653,7 +655,7 @@ Prompt for a context, must be a list containting at least one of \"home\", (defun mastodon-views--delete-filter () "Delete filter at point." (interactive) - (let* ((filter-id (mastodon-tl--property 'toot-id :no-move)) + (let* ((filter-id (mastodon-tl--property 'item-id :no-move)) (phrase (mastodon-tl--property 'phrase :no-move)) (url (mastodon-http--api (format "filters/%s" filter-id)))) (if (null phrase) @@ -745,14 +747,14 @@ MISSKEY means the instance is a Misskey or derived server." (let ((response (mastodon-http--get-json (mastodon-http--api "instance") nil nil :vector))) (mastodon-views--instance-response-fun response brief instance)) - (mastodon-tl--do-if-toot + (mastodon-tl--do-if-item (let* ((toot (if (mastodon-tl--profile-buffer-p) ;; we may be on profile description itself: (or (mastodon-tl--property 'profile-json) ;; or on profile account listings, or just toots: - (mastodon-tl--property 'toot-json)) + (mastodon-tl--property 'item-json)) ;; normal timeline/account listing: - (mastodon-tl--property 'toot-json))) + (mastodon-tl--property 'item-json))) (reblog (alist-get 'reblog toot)) (account (or (alist-get 'account reblog) (alist-get 'account toot) diff --git a/mastodon.info b/mastodon.info index 7b77261..47c9b9a 100644 --- a/mastodon.info +++ b/mastodon.info @@ -1,4 +1,4 @@ -This is mastodon.info, produced by makeinfo version 6.7 from +This is mastodon.info, produced by makeinfo version 6.8 from mastodon.texi. INFO-DIR-SECTION Emacs @@ -537,7 +537,7 @@ looks like: "Translate text of toot at point. Uses `lingva.el'." (interactive) - (let* ((toot (mastodon-tl--property 'toot-json))) + (let* ((toot (mastodon-tl--property 'item-json))) (if toot (lingva-translate nil (mastodon-tl--content toot)) (message "No toot to translate?")))) @@ -585,10 +585,10 @@ Mastodon API. • Gotosocial (gotosocial.org (https://gotosocial.org/)) It does not support the non-Mastodon API servers Misskey (misskey.io -(https://misskey.io/)) and Firefish (joinfirefish.org -(https://joinfirefish.org/), formerly Calkey), but it should fully -support displaying and interacting with posts and users on those -platforms. +(https://misskey.io/)), Firefish (joinfirefish.org +(https://joinfirefish.org/), formerly Calkey) and Friendica, but it +should fully support displaying and interacting with posts and users on +those platforms. If you attempt to use ‘mastodon.el’ with a server and run into problems, feel free to open an issue. @@ -714,12 +714,12 @@ Node: Translating toots18911 Node: Bookmarks and mastodonel20093 Node: Dependencies20565 Node: Network compatibility21175 -Node: Contributing22046 -Node: Bug reports22335 -Node: Fixes and features23241 -Node: Coding style23724 -Node: Supporting mastodonel24348 -Node: Contributors24915 +Node: Contributing22057 +Node: Bug reports22346 +Node: Fixes and features23252 +Node: Coding style23735 +Node: Supporting mastodonel24359 +Node: Contributors24926 End Tag Table diff --git a/mastodon.texi b/mastodon.texi index c1b48b3..872fb81 100644 --- a/mastodon.texi +++ b/mastodon.texi @@ -658,7 +658,7 @@ to your translator function as its text argument. Here's what "Translate text of toot at point. Uses `lingva.el'." (interactive) - (let* ((toot (mastodon-tl--property 'toot-json))) + (let* ((toot (mastodon-tl--property 'item-json))) (if toot (lingva-translate nil (mastodon-tl--content toot)) (message "No toot to translate?")))) @@ -707,7 +707,7 @@ Akkoma (@uref{https://akkoma.social/, akkoma.social}) Gotosocial (@uref{https://gotosocial.org/, gotosocial.org}) @end itemize -It does not support the non-Mastodon API servers Misskey (@uref{https://misskey.io/, misskey.io}) and Firefish (@uref{https://joinfirefish.org/, joinfirefish.org}, formerly Calkey), but it should fully support displaying and interacting with posts and users on those platforms. +It does not support the non-Mastodon API servers Misskey (@uref{https://misskey.io/, misskey.io}), Firefish (@uref{https://joinfirefish.org/, joinfirefish.org}, formerly Calkey) and Friendica, but it should fully support displaying and interacting with posts and users on those platforms. If you attempt to use @samp{mastodon.el} with a server and run into problems, feel free to open an issue. diff --git a/test/mastodon-profile-tests.el b/test/mastodon-profile-tests.el index 1936b99..d187e2d 100644 --- a/test/mastodon-profile-tests.el +++ b/test/mastodon-profile-tests.el @@ -158,11 +158,11 @@ When formatting Gargon's state we want to see t)) (should (equal - (get-text-property 4 'toot-id) + (get-text-property 4 'item-id) (alist-get 'id gargron-profile-json))) (should (equal - (get-text-property 4 'toot-json) + (get-text-property 4 'item-json) gargron-profile-json))))) (ert-deftest mastodon-profile--search-account-by-handle--removes-at () diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index 899960e..be72f66 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -168,16 +168,16 @@ Strict-Transport-Security: max-age=31536000 (let ((input "foobar</p>")) (should (string= (mastodon-tl--remove-html input) "foobar\n\n")))) -(ert-deftest mastodon-tl--toot-id-boosted () +(ert-deftest mastodon-tl--item-id-boosted () "If a toot is boostedm, return the reblog id." (should (string= (mastodon-tl--as-string - (mastodon-tl--toot-id mastodon-tl-test-base-boosted-toot)) + (mastodon-tl--item-id mastodon-tl-test-base-boosted-toot)) "4543919"))) -(ert-deftest mastodon-tl--toot-id () +(ert-deftest mastodon-tl--item-id () "If a toot is boostedm, return the reblog id." (should (string= (mastodon-tl--as-string - (mastodon-tl--toot-id mastodon-tl-test-base-toot)) + (mastodon-tl--item-id mastodon-tl-test-base-toot)) "61208"))) (ert-deftest mastodon-tl--as-string-1 () @@ -926,19 +926,19 @@ constant." (insert "some text before\n") (setq toot-start (point)) (with-mock - (mock (mastodon-profile--get-preferences-pref - 'reading:expand:spoilers) - => :json-false) - (stub create-image => '(image "fake data")) - (stub shr-render-region => nil) ;; Travis's Emacs doesn't have libxml - (insert - (mastodon-tl--spoiler normal-toot-with-spoiler))) + (mock (mastodon-profile--get-preferences-pref + 'reading:expand:spoilers) + => :json-false) + (stub create-image => '(image "fake data")) + (stub shr-render-region => nil) ;; Travis's Emacs doesn't have libxml + (insert + (mastodon-tl--spoiler normal-toot-with-spoiler))) (setq toot-end (point)) (insert "\nsome more text.") (add-text-properties toot-start toot-end - (list 'toot-json normal-toot-with-spoiler - 'toot-id (cdr (assoc 'id normal-toot-with-spoiler)))) + (list 'item-json normal-toot-with-spoiler + 'item-id (cdr (assoc 'id normal-toot-with-spoiler)))) (goto-char toot-start) ;; (should (eq t (looking-at "This is the spoiler warning text"))) @@ -1147,28 +1147,28 @@ correct value for following, as well as notifications enabled or disabled." (let* ((toot mastodon-tl-test-base-toot) (account (alist-get 'account toot))) (with-mock - ;; no longer needed after our refactor - ;; (mock (mastodon-http--api "reports") => "https://instance.url/api/v1/reports") - ;; (mock (mastodon-tl--toot-or-base - ;; (mastodon-tl--property 'toot-json :no-move)) - ;; => mastodon-tl-test-base-toot) - (mock (read-string "Add comment [optional]: ") => "Dummy complaint") - (stub y-or-n-p => nil) ; no to all + ;; no longer needed after our refactor + ;; (mock (mastodon-http--api "reports") => "https://instance.url/api/v1/reports") + ;; (mock (mastodon-tl--toot-or-base + ;; (mastodon-tl--property 'item-json :no-move)) + ;; => mastodon-tl-test-base-toot) + (mock (read-string "Add comment [optional]: ") => "Dummy complaint") + (stub y-or-n-p => nil) ; no to all + (should (equal (mastodon-tl--report-params account toot) + '(("account_id" . 42) + ("comment" . "Dummy complaint") + ("category" . "other")))) + (with-mock + (stub y-or-n-p => t) ; yes to all + (mock (mastodon-tl--read-rules-ids) => '(1 2 3)) (should (equal (mastodon-tl--report-params account toot) - '(("account_id" . 42) + '(("rule_ids[]" . 3) + ("rule_ids[]" . 2) + ("rule_ids[]" . 1) + ("account_id" . 42) ("comment" . "Dummy complaint") - ("category" . "other")))) - (with-mock - (stub y-or-n-p => t) ; yes to all - (mock (mastodon-tl--read-rules-ids) => '(1 2 3)) - (should (equal (mastodon-tl--report-params account toot) - '(("rule_ids[]" . 3) - ("rule_ids[]" . 2) - ("rule_ids[]" . 1) - ("account_id" . 42) - ("comment" . "Dummy complaint") - ("status_ids[]" . 61208) - ("forward" . "true"))))))))) + ("status_ids[]" . 61208) + ("forward" . "true"))))))))) (ert-deftest mastodon-tl--report-build-params () "" diff --git a/test/mastodon-toot-tests.el b/test/mastodon-toot-tests.el index 69333c0..5efe2e1 100644 --- a/test/mastodon-toot-tests.el +++ b/test/mastodon-toot-tests.el @@ -40,7 +40,7 @@ Transfer-Encoding: chunked") (defconst mastodon-toot--mock-toot (propertize "here is a mock toot text." - 'toot-json mastodon-toot-test-base-toot)) + 'item-json mastodon-toot-test-base-toot)) (defconst mastodon-toot--multi-mention '((mentions . @@ -143,7 +143,7 @@ mention string." (with-mock (mock (mastodon-auth--user-acct) => "joebogus") ;; (mock (mastodon-toot--own-toot-p toot) => nil) - (mock (mastodon-tl--property 'toot-json) => mastodon-toot-test-base-toot) + (mock (mastodon-tl--property 'item-json) => mastodon-toot-test-base-toot) (mock (mastodon-tl--property 'base-toot) => toot) (should (equal (mastodon-toot--delete-toot) "You can only delete (and redraft) your own toots."))))) @@ -155,7 +155,7 @@ mention string." (let ((delete-response (current-buffer)) (toot mastodon-toot-test-base-toot)) (with-mock - (mock (mastodon-tl--property 'toot-json) => toot) + (mock (mastodon-tl--property 'item-json) => toot) (mock (mastodon-tl--property 'base-toot) => toot) ;; (mock (mastodon-toot--own-toot-p toot) => t) (mock (mastodon-auth--user-acct) => "acct42@example.space") @@ -175,7 +175,7 @@ mention string." (toot mastodon-toot-test-base-toot) (id 61208)) (with-mock - (mock (mastodon-tl--property 'base-toot-id) => id) + (mock (mastodon-tl--property 'base-item-id) => id) (mock (mastodon-http--api "statuses/61208/pin") => "https://example.space/statuses/61208/pin") (mock (mastodon-http--post "https://example.space/statuses/61208/pin") @@ -190,7 +190,7 @@ mention string." (let ((pin-response (current-buffer)) (toot mastodon-toot-test-base-toot)) (with-mock - (mock (mastodon-tl--property 'toot-json) => toot) + (mock (mastodon-tl--property 'item-json) => toot) (mock (mastodon-tl--property 'base-toot) => toot) (mock (mastodon-auth--user-acct) => "joebogus@example.space") (should (equal (mastodon-toot--pin-toot-toggle) |