mirror of https://codeberg.org/cage/tinmop/
Compare commits
3 Commits
5249910397
...
beaf5e27c7
Author | SHA1 | Date |
---|---|---|
cage | beaf5e27c7 | |
cage | 38d222904b | |
cage | 631d731d15 |
39
src/db.lisp
39
src/db.lisp
|
@ -412,7 +412,7 @@
|
||||||
+make-close+)))
|
+make-close+)))
|
||||||
|
|
||||||
(defun make-mention ()
|
(defun make-mention ()
|
||||||
(query-low-level (strcat (prepare-table +table-mention+)
|
(query-low-level (strcat (prepare-table +table-mention+ :integer-id-p t :autoincrementp t)
|
||||||
" username TEXT NOT NULL,"
|
" username TEXT NOT NULL,"
|
||||||
;; this is the actual user identification
|
;; this is the actual user identification
|
||||||
" acct TEXT NOT NULL,"
|
" acct TEXT NOT NULL,"
|
||||||
|
@ -420,7 +420,7 @@
|
||||||
" url TEXT NOT NULL,"
|
" url TEXT NOT NULL,"
|
||||||
;; local value, timestamp
|
;; local value, timestamp
|
||||||
" \"date-added\" TEXT NOT NULL,"
|
" \"date-added\" TEXT NOT NULL,"
|
||||||
" UNIQUE(id) ON CONFLICT FAIL"
|
" \"status-id\" TEXT NOT NULL"
|
||||||
+make-close+)))
|
+make-close+)))
|
||||||
|
|
||||||
(defun make-followed-user ()
|
(defun make-followed-user ()
|
||||||
|
@ -1327,25 +1327,29 @@ than (swconf:config-purge-history-days-offset) days in the past"
|
||||||
+tag-separator+)
|
+tag-separator+)
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
(defmethod update-db ((object tooter:mention) &key &allow-other-keys)
|
(defmethod update-db ((object tooter:mention) &key (status-id nil) &allow-other-keys)
|
||||||
(with-accessors ((id tooter:id)
|
(with-accessors ((id tooter:id)
|
||||||
(username tooter:username)
|
(username tooter:username)
|
||||||
(account-name tooter:account-name)
|
(account-name tooter:account-name)
|
||||||
(url tooter:url)) object
|
(url tooter:url)) object
|
||||||
|
(assert status-id)
|
||||||
(let ((actual-username (clean-chars username))
|
(let ((actual-username (clean-chars username))
|
||||||
(actual-acct (clean-chars account-name))
|
(actual-acct (clean-chars account-name))
|
||||||
(now (prepare-for-db (local-time-obj-now))))
|
(now (prepare-for-db (local-time-obj-now))))
|
||||||
(insert-or-update +table-mention+
|
(when (not (mentioned-username->account actual-username
|
||||||
(:id
|
status-id
|
||||||
:username
|
:add-mention-prefix nil))
|
||||||
:acct
|
(query (make-insert +table-mention+
|
||||||
:url
|
(:username
|
||||||
:date-added)
|
:acct
|
||||||
(id
|
:url
|
||||||
actual-username
|
:date-added
|
||||||
actual-acct
|
:status-id)
|
||||||
url
|
(actual-username
|
||||||
now)))))
|
actual-acct
|
||||||
|
url
|
||||||
|
now
|
||||||
|
status-id)))))))
|
||||||
|
|
||||||
(defmethod update-db ((object tooter:status)
|
(defmethod update-db ((object tooter:status)
|
||||||
&key
|
&key
|
||||||
|
@ -1378,7 +1382,7 @@ than (swconf:config-purge-history-days-offset) days in the past"
|
||||||
(poll tooter:poll)
|
(poll tooter:poll)
|
||||||
(mentions tooter:mentions)) object
|
(mentions tooter:mentions)) object
|
||||||
(update-db account)
|
(update-db account)
|
||||||
(mapcar #'update-db mentions)
|
(mapcar (lambda (a) (update-db a :status-id id)) mentions)
|
||||||
(let* ((account-id (tooter:id account))
|
(let* ((account-id (tooter:id account))
|
||||||
(actual-created-at (decode-datetime-string created-at))
|
(actual-created-at (decode-datetime-string created-at))
|
||||||
(actual-application (prepare-for-db application))
|
(actual-application (prepare-for-db application))
|
||||||
|
@ -1924,11 +1928,12 @@ the message identified by the tuple."
|
||||||
(cons (msg-utils:add-mention-prefix local-name)
|
(cons (msg-utils:add-mention-prefix local-name)
|
||||||
(msg-utils:add-mention-prefix username))))))
|
(msg-utils:add-mention-prefix username))))))
|
||||||
|
|
||||||
(defun mentioned-username->account (username &key (add-mention-prefix t))
|
(defun mentioned-username->account (username status-id &key (add-mention-prefix t))
|
||||||
"Returns an alist of all known accounts as ('@'local-username . '@'acct)."
|
"Returns an alist of all known accounts as ('@'local-username . '@'acct)."
|
||||||
(let* ((query (select :acct
|
(let* ((query (select :acct
|
||||||
(from +table-mention+)
|
(from +table-mention+)
|
||||||
(where (:= :username username))))
|
(where (:and (:= :username username)
|
||||||
|
(:= :status-id status-id)))))
|
||||||
(acct (second (fetch-single query))))
|
(acct (second (fetch-single query))))
|
||||||
(if add-mention-prefix
|
(if add-mention-prefix
|
||||||
(msg-utils:add-mention-prefix acct)
|
(msg-utils:add-mention-prefix acct)
|
||||||
|
|
|
@ -135,15 +135,19 @@
|
||||||
|
|
||||||
(defun footnote-reference-re (&key (enforce-end-string t))
|
(defun footnote-reference-re (&key (enforce-end-string t))
|
||||||
(format nil
|
(format nil
|
||||||
"~a[~a]+~@[$~]"
|
"(~a[~a]+)?~@[$~]"
|
||||||
#\ZERO_WIDTH_SPACE
|
#\ZERO_WIDTH_SPACE
|
||||||
+digits-superscripts+
|
+digits-superscripts+
|
||||||
enforce-end-string))
|
enforce-end-string))
|
||||||
|
|
||||||
(let ((scanner (cl-ppcre:create-scanner (footnote-reference-re))))
|
(let ((scanner (cl-ppcre:create-scanner (footnote-reference-re))))
|
||||||
(defun strip-footnote-reference (word)
|
(defun strip-footnote-reference-word (word)
|
||||||
(cl-ppcre:regex-replace scanner word "")))
|
(cl-ppcre:regex-replace scanner word "")))
|
||||||
|
|
||||||
|
(let ((scanner (cl-ppcre:create-scanner (footnote-reference-re :enforce-end-string nil))))
|
||||||
|
(defun strip-all-footnote-reference (string)
|
||||||
|
(cl-ppcre:regex-replace-all scanner string "")))
|
||||||
|
|
||||||
(defun block-tag-p (node)
|
(defun block-tag-p (node)
|
||||||
(and (consp node)
|
(and (consp node)
|
||||||
(member node
|
(member node
|
||||||
|
|
|
@ -40,12 +40,13 @@
|
||||||
(let ((words (split-words message-line))
|
(let ((words (split-words message-line))
|
||||||
(mention-prefix-length (length +mention-prefix+)))
|
(mention-prefix-length (length +mention-prefix+)))
|
||||||
(mapcar (lambda (a)
|
(mapcar (lambda (a)
|
||||||
(html-utils:strip-footnote-reference (subseq a mention-prefix-length))) ; remove the @
|
(html-utils:strip-footnote-reference-word (subseq a
|
||||||
|
mention-prefix-length))) ; remove the #\@
|
||||||
(remove-if-not (lambda (word)
|
(remove-if-not (lambda (word)
|
||||||
(cl-ppcre:scan (strcat "^" +mention-prefix+) word))
|
(cl-ppcre:scan (strcat "^" +mention-prefix+) word))
|
||||||
words))))
|
words))))
|
||||||
|
|
||||||
(defun usernames->usernames-table (message)
|
(defun usernames->usernames-table (message status-id)
|
||||||
"Returns a list of pairs ('@'username . '@'acct)."
|
"Returns a list of pairs ('@'username . '@'acct)."
|
||||||
(let ((usernames '()))
|
(let ((usernames '()))
|
||||||
(loop for line in (split-lines message)
|
(loop for line in (split-lines message)
|
||||||
|
@ -57,7 +58,7 @@
|
||||||
usernames-in-line))))
|
usernames-in-line))))
|
||||||
(mapcar (lambda (username)
|
(mapcar (lambda (username)
|
||||||
(cons (add-mention-prefix username)
|
(cons (add-mention-prefix username)
|
||||||
(db:mentioned-username->account username)))
|
(db:mentioned-username->account username status-id)))
|
||||||
usernames)))
|
usernames)))
|
||||||
|
|
||||||
(defun local-mention->acct (text-line usernames-table)
|
(defun local-mention->acct (text-line usernames-table)
|
||||||
|
@ -73,8 +74,8 @@
|
||||||
(strcat " " actual-mention)))))
|
(strcat " " actual-mention)))))
|
||||||
results))
|
results))
|
||||||
|
|
||||||
(defun expand-mention (text)
|
(defun expand-mention (text status-id)
|
||||||
(let ((mentioned-users-table (usernames->usernames-table text)))
|
(let ((mentioned-users-table (usernames->usernames-table text status-id)))
|
||||||
(with-output-to-string (stream)
|
(with-output-to-string (stream)
|
||||||
(loop for line in (text-utils:split-lines text) do
|
(loop for line in (text-utils:split-lines text) do
|
||||||
(let ((line-fixed-mentions (local-mention->acct line mentioned-users-table)))
|
(let ((line-fixed-mentions (local-mention->acct line mentioned-users-table)))
|
||||||
|
|
|
@ -528,7 +528,8 @@
|
||||||
:position-tag
|
:position-tag
|
||||||
:node->link
|
:node->link
|
||||||
:append-footnote-reference
|
:append-footnote-reference
|
||||||
:strip-footnote-reference
|
:strip-footnote-reference-word
|
||||||
|
:strip-all-footnote-reference
|
||||||
:footnote-reference-re
|
:footnote-reference-re
|
||||||
:html->text))
|
:html->text))
|
||||||
|
|
||||||
|
|
|
@ -2103,7 +2103,7 @@
|
||||||
:direction :output
|
:direction :output
|
||||||
:if-exists :supersede
|
:if-exists :supersede
|
||||||
:if-does-not-exist :create)
|
:if-does-not-exist :create)
|
||||||
(let ((mentioned-users-text (msg-utils:expand-mention text)))
|
(let ((mentioned-users-text (msg-utils:expand-mention text status-id)))
|
||||||
(write-sequence mentioned-users-text stream)))
|
(write-sequence mentioned-users-text stream)))
|
||||||
(croatoan:end-screen)
|
(croatoan:end-screen)
|
||||||
(tui:with-notify-errors
|
(tui:with-notify-errors
|
||||||
|
|
|
@ -1383,7 +1383,9 @@ It an existing file path is provided the command will refuse to run."
|
||||||
;; in db (folder, timeline).
|
;; in db (folder, timeline).
|
||||||
(when-let* ((message (db:find-message-id reply-id))
|
(when-let* ((message (db:find-message-id reply-id))
|
||||||
(reply-username (db:row-message-username message))
|
(reply-username (db:row-message-username message))
|
||||||
(rendered-text (db:row-message-rendered-text message))
|
(content (db:row-message-content message))
|
||||||
|
(rendered-text (msg-utils:message-original->text-body content
|
||||||
|
:add-link-footnotes nil))
|
||||||
(lines (split-lines rendered-text))
|
(lines (split-lines rendered-text))
|
||||||
(quote-mark (swconf:quote-char))
|
(quote-mark (swconf:quote-char))
|
||||||
(quoted-text (strcat quote-mark
|
(quoted-text (strcat quote-mark
|
||||||
|
@ -1397,7 +1399,8 @@ It an existing file path is provided the command will refuse to run."
|
||||||
:direction :output
|
:direction :output
|
||||||
:element-type 'character)
|
:element-type 'character)
|
||||||
(format stream "~a~%" (msg-utils:add-mention-prefix reply-username))
|
(format stream "~a~%" (msg-utils:add-mention-prefix reply-username))
|
||||||
(let ((mentioned-users-text (msg-utils:expand-mention quoted-text)))
|
(let ((mentioned-users-text (msg-utils:expand-mention quoted-text
|
||||||
|
reply-id)))
|
||||||
(write-sequence mentioned-users-text stream))))))
|
(write-sequence mentioned-users-text stream))))))
|
||||||
(add-signature (file)
|
(add-signature (file)
|
||||||
(when-let ((signature (message-rendering-utils:signature)))
|
(when-let ((signature (message-rendering-utils:signature)))
|
||||||
|
|
Loading…
Reference in New Issue