1
0
Fork 0

- added a configuraction directive to filter boost based on a regular expression matching the username.

This commit is contained in:
cage 2022-11-18 18:01:19 +01:00
parent 8206500f7a
commit 4f24a67344
5 changed files with 33 additions and 1 deletions

View File

@ -752,6 +752,16 @@
(return-from user-ignored-p t))) (return-from user-ignored-p t)))
nil))) nil)))
(defun boost-ignored-p (account-id)
"Returns non nil if this boost must be ignored"
(when-let ((ignore-regexps (swconf:ignore-users-boost-regexps))
(username (db:user-id->username account-id)))
(misc:dbg "ignore ~a" ignore-regexps)
(loop for ignore-re in ignore-regexps do
(when (cl-ppcre:scan ignore-re username)
(return-from boost-ignored-p t)))
nil))
(defun acct->user (acct) (defun acct->user (acct)
"Convert `acct' (acct is synonyym for username in mastodon account) "Convert `acct' (acct is synonyym for username in mastodon account)
to the corresponding row in table +table-account+" to the corresponding row in table +table-account+"

View File

@ -860,6 +860,7 @@
:delete-by-id :delete-by-id
:account-ignored-p :account-ignored-p
:user-ignored-p :user-ignored-p
:boost-ignored-p
:acct->user :acct->user
:acct->id :acct->id
:username->id :username->id
@ -1239,6 +1240,7 @@
:gempub-library-directory :gempub-library-directory
:color-regexps :color-regexps
:ignore-users-regexps :ignore-users-regexps
:ignore-users-boost-regexps
:win-bg :win-bg
:win-fg :win-fg
:win-height :win-height

View File

@ -387,6 +387,7 @@
(let ((account-id (tooter:id (tooter:account status))) (let ((account-id (tooter:id (tooter:account status)))
(status-id (tooter:id status)) (status-id (tooter:id status))
(language (tooter:language status)) (language (tooter:language status))
(rebloggedp (tooter:parent status))
(skip-this-status nil)) (skip-this-status nil))
(when force-saving-of-ignored-status-p (when force-saving-of-ignored-status-p
(db:remove-from-status-ignored status-id folder timeline-type)) (db:remove-from-status-ignored status-id folder timeline-type))
@ -395,6 +396,8 @@
(and language (and language
(cl-ppcre:scan (swconf:config-post-allowed-language) (cl-ppcre:scan (swconf:config-post-allowed-language)
language)) language))
(and rebloggedp
(db:boost-ignored-p account-id))
(hooks:run-hook-until-success 'hooks:*skip-message-hook* (hooks:run-hook-until-success 'hooks:*skip-message-hook*
status status
timeline-type timeline-type

View File

@ -21,6 +21,7 @@
;; ENTRIES := COMMENT* ;; ENTRIES := COMMENT*
;; (USE-FILE ;; (USE-FILE
;; | IGNORE-USER-RE-ASSIGN ;; | IGNORE-USER-RE-ASSIGN
;; | IGNORE-USER-BOOST-RE-ASSIGN
;; | COLOR-RE-ASSIGN ;; | COLOR-RE-ASSIGN
;; | SERVER-ASSIGN ;; | SERVER-ASSIGN
;; | USERNAME-ASSIGN ;; | USERNAME-ASSIGN
@ -39,6 +40,7 @@
;; generic-value) ; the order in this list *is* important ;; generic-value) ; the order in this list *is* important
;; blanks) ;; blanks)
;; IGNORE-USER-RE-ASSIGN := IGNORE-USER-RE-KEY ASSIGN REGEXP ;; IGNORE-USER-RE-ASSIGN := IGNORE-USER-RE-KEY ASSIGN REGEXP
;; IGNORE-USER-BOOST-RE-ASSIGN := IGNORE-USER-RE-KEY ASSIGN REGEXP
;; COLOR-RE-ASSIGN := COLOR-RE-KEY ASSIGN REGEXP FG-COLOR (? ATTRIBUTE-VALUE) ;; COLOR-RE-ASSIGN := COLOR-RE-KEY ASSIGN REGEXP FG-COLOR (? ATTRIBUTE-VALUE)
;; USE-FILE := (AND USE BLANKS FILEPATH BLANKS) ;; USE-FILE := (AND USE BLANKS FILEPATH BLANKS)
;; POST-ALLOWED-LANGUAGE := "post-allowed-language" BLANKS ASSIGN REGEXP ;; POST-ALLOWED-LANGUAGE := "post-allowed-language" BLANKS ASSIGN REGEXP
@ -267,11 +269,19 @@
(defrule ignore-user-re-key "ignore-user-regexp" (defrule ignore-user-re-key "ignore-user-regexp"
(:constant :ignore-user-re)) (:constant :ignore-user-re))
(defrule ignore-user-boost-re-key "ignore-user-boost-regexp"
(:constant :ignore-user-boost-re))
(defrule ignore-user-re-assign (defrule ignore-user-re-assign
(and ignore-user-re-key blanks (and ignore-user-re-key blanks
assign blanks regexp blanks) assign blanks regexp blanks)
(:function (lambda (a) (list (first a) (fifth a))))) (:function (lambda (a) (list (first a) (fifth a)))))
(defrule ignore-user-boost-re-assign
(and ignore-user-boost-re-key blanks
assign blanks regexp blanks)
(:function (lambda (a) (list (first a) (fifth a)))))
(defrule server-key "server" (defrule server-key "server"
(:constant :server)) (:constant :server))
@ -428,6 +438,7 @@
(or use-file (or use-file
color-re-assign color-re-assign
ignore-user-re-assign ignore-user-re-assign
ignore-user-boost-re-assign
server-assign server-assign
username-assign username-assign
open-link-helper open-link-helper
@ -608,6 +619,7 @@
password-echo-character password-echo-character
color-re color-re
ignore-user-re ignore-user-re
ignore-user-boost-re
post-allowed-language post-allowed-language
purge-history-days-offset purge-history-days-offset
purge-cache-days-offset) purge-cache-days-offset)
@ -628,6 +640,7 @@
(cond (cond
((or (eq +key-color-re+ key) ((or (eq +key-color-re+ key)
(eq +key-ignore-user-re+ key) (eq +key-ignore-user-re+ key)
(eq +key-ignore-user-boost-re+ key)
(eq +key-open-link-helper+ key) (eq +key-open-link-helper+ key)
(eq +key-post-allowed-language+ key)) (eq +key-post-allowed-language+ key))
(setf (access:accesses *software-configuration* key) (setf (access:accesses *software-configuration* key)
@ -947,6 +960,10 @@
(access:accesses *software-configuration* (access:accesses *software-configuration*
+key-ignore-user-re+)) +key-ignore-user-re+))
(defun ignore-users-boost-regexps ()
(access:accesses *software-configuration*
+key-ignore-user-boost-re+))
(defmacro gen-win-key-access (fn-suffix key) (defmacro gen-win-key-access (fn-suffix key)
`(defun ,(misc:format-fn-symbol t "win-~a" fn-suffix) (win-key) `(defun ,(misc:format-fn-symbol t "win-~a" fn-suffix) (win-key)
(access:accesses *software-configuration* (access:accesses *software-configuration*

View File

@ -836,7 +836,7 @@ db:renumber-timeline-message-index."
(defun reblogged-data (reblogger-status) (defun reblogged-data (reblogger-status)
(a:when-let* ((reblogged-id (db:row-message-reblog-id reblogger-status)) (a:when-let* ((reblogged-id (db:row-message-reblog-id reblogger-status))
(reblogged-status (db:find-status-id reblogged-id))) (reblogged-status (db:find-status-id reblogged-id)))
(let ((body (db:row-message-rendered-text reblogged-status)) (let ((body (db:row-message-rendered-text reblogged-status))
(attachments (status-attachments->text reblogged-id))) (attachments (status-attachments->text reblogged-id)))
(values body attachments)))) (values body attachments))))