Db fixes
This commit is contained in:
parent
fcf28eda57
commit
8be6a9312c
@ -31,7 +31,7 @@
|
||||
|
||||
(defun replace-in-string (what with str)
|
||||
"Replace WHAT WITH in STR."
|
||||
(replace-regexp-in-string (regexp-quote what) with str nil 'literal))
|
||||
(replace-regexp-in-string (regexp-quote what) with str nil 'literal))
|
||||
|
||||
(defun base64-to-base64url (str)
|
||||
"Make url safe base64 string STR."
|
||||
@ -153,20 +153,30 @@
|
||||
|
||||
(defun get-answers-hash (id msg-hash)
|
||||
"Make answers hashtable from ID and MSG-HASH."
|
||||
(let (answer-hash)
|
||||
(setq answer-hash (make-hash-table :test 'equal))
|
||||
(puthash "id" id answer-hash)
|
||||
(puthash "echo" (get-message-field (gethash "content" msg-hash) "echo") answer-hash)
|
||||
(puthash "author" (get-message-field (gethash "content" msg-hash) "author") answer-hash)
|
||||
(puthash "time" (get-message-field (gethash "content" msg-hash) "time") answer-hash)
|
||||
(if (gethash "content" msg-hash)
|
||||
(let (answer-hash)
|
||||
(setq answer-hash (make-hash-table :test 'equal))
|
||||
(puthash "id" id answer-hash)
|
||||
(puthash "echo" (get-message-field (gethash "content" msg-hash) "echo") answer-hash)
|
||||
(puthash "author" (get-message-field (gethash "content" msg-hash) "author") answer-hash)
|
||||
(puthash "time" (get-message-field (gethash "content" msg-hash) "time") answer-hash)
|
||||
|
||||
(setq subj (get-message-field (gethash "content" msg-hash) "subj"))
|
||||
(setq subj (get-message-field (gethash "content" msg-hash) "subj"))
|
||||
|
||||
;; Make `Re:' in subj if it not present.
|
||||
(if (not (string-match "Re:" subj))
|
||||
(puthash "subj" (concat "Re: " subj) answer-hash)
|
||||
(puthash "subj" subj answer-hash))
|
||||
answer-hash))
|
||||
;; Make `Re:' in subj if it not present.
|
||||
(if (not (string-match "Re:" subj))
|
||||
(puthash "subj" (concat "Re: " subj) answer-hash)
|
||||
(puthash "subj" subj answer-hash))
|
||||
answer-hash)
|
||||
(let (subj)
|
||||
(setq subj (gethash "subj" msg-hash))
|
||||
|
||||
;; Make `Re:' in subj if it not present.
|
||||
(if (not subj)
|
||||
(puthash "subj" (concat "Re: " "") msg-hash)
|
||||
(if (not (string-match "Re:" subj))
|
||||
(puthash "subj" (concat "Re: " subj) msg-hash)))
|
||||
msg-hash)))
|
||||
|
||||
(defun make-answer-header (id msg-hash)
|
||||
"Make header with reto to ID from MSG-HASH."
|
||||
@ -184,6 +194,7 @@
|
||||
|
||||
(defun edit-answer-without-quote (id msg-hash)
|
||||
"Answer to message with ID MSG-HASH."
|
||||
msg-hash
|
||||
(let (answer-hash p)
|
||||
(setq answer-hash (get-answers-hash id msg-hash))
|
||||
(switch-to-buffer (get-buffer-create (concat "*IDEC: answer to " id "*")))
|
||||
@ -198,7 +209,7 @@
|
||||
'action (lambda (x) (send-reply-message (button-get x 'msg)))
|
||||
'msg answer-hash)
|
||||
(goto-char p)
|
||||
(org-idec)))
|
||||
(org-idec)))
|
||||
|
||||
;; END OF ANSWERS
|
||||
|
||||
|
24
idec-db.el
24
idec-db.el
@ -83,6 +83,7 @@
|
||||
([(id :primary-key)
|
||||
tags
|
||||
author
|
||||
address
|
||||
recipient
|
||||
repto
|
||||
echo
|
||||
@ -121,10 +122,11 @@ unread by default, but you can MARK-READ it."
|
||||
|
||||
(if (not (emacsql (open-echo-db (get-message-field msg "echo"))
|
||||
[:insert :into messages
|
||||
:values ([$s1 $s2 $s3 $s4 $s5 $s6 $s7 $s8 $s9 $s10])]
|
||||
:values ([$s1 $s2 $s3 $s4 $s5 $s6 $s7 $s8 $s9 $s10 $s11])]
|
||||
id
|
||||
(get-message-field msg "tags")
|
||||
(get-message-field msg "author")
|
||||
(get-message-field msg "address")
|
||||
(get-message-field msg "recipient")
|
||||
repto
|
||||
(get-message-field msg "echo")
|
||||
@ -153,13 +155,14 @@ unread by default, but you can MARK-READ it."
|
||||
(puthash "id" (nth 0 msg-list) msg-hash)
|
||||
(puthash "tags" (nth 1 msg-list) msg-hash)
|
||||
(puthash "author" (nth 2 msg-list) msg-hash)
|
||||
(puthash "recipient" (nth 3 msg-list) msg-hash)
|
||||
(puthash "repto" (nth 4 msg-list) msg-hash)
|
||||
(puthash "echo" (nth 5 msg-list) msg-hash)
|
||||
(puthash "subj" (nth 6 msg-list) msg-hash)
|
||||
(puthash "body" (nth 7 msg-list) msg-hash)
|
||||
(puthash "time" (nth 8 msg-list) msg-hash)
|
||||
(puthash "unread" (nth 9 msg-list) msg-hash)))
|
||||
(puthash "address" (nth 3 msg-list) msg-hash)
|
||||
(puthash "recipient" (nth 4 msg-list) msg-hash)
|
||||
(puthash "repto" (nth 5 msg-list) msg-hash)
|
||||
(puthash "echo" (nth 6 msg-list) msg-hash)
|
||||
(puthash "subj" (nth 7 msg-list) msg-hash)
|
||||
(puthash "body" (nth 8 msg-list) msg-hash)
|
||||
(puthash "time" (nth 9 msg-list) msg-hash)
|
||||
(puthash "unread" (nth 10 msg-list) msg-hash)))
|
||||
msg-hash))
|
||||
|
||||
(defun get-echo-messages (echo)
|
||||
@ -167,10 +170,9 @@ unread by default, but you can MARK-READ it."
|
||||
(let (msgs)
|
||||
(setq msgs (make-list 0 (make-hash-table :test 'equal)))
|
||||
(dolist (l (emacsql (open-echo-db echo)
|
||||
[:select [id, tags, author, recipient, repto, echo, subj, body, time, unread]
|
||||
[:select [id, tags, author, address, recipient, repto, echo, subj, body, time, unread]
|
||||
:from messages
|
||||
:order-by time
|
||||
:desc]))
|
||||
:order-by time]))
|
||||
(if (> (length l) 0)
|
||||
(setq msgs (append msgs (make-list 1 (make-hash-from-msg-list l))))))
|
||||
msgs))
|
||||
|
10
idec-mode.el
10
idec-mode.el
@ -277,13 +277,13 @@ optionaly return cursor to CHECKPOINT."
|
||||
(setq counter 0)
|
||||
(dolist (msg (get-echo-messages echo))
|
||||
(insert-button (concat (gethash "subj" msg))
|
||||
'action (lambda (x) (display-message-hash (button-get x 'msg)))
|
||||
'action (lambda (x) (display-message-hash (button-get x 'msg-hash)))
|
||||
'subj (gethash "subj" msg)
|
||||
'help-echo (concat "Read message *" (gethash "subj" msg) "*")
|
||||
'msg msg)
|
||||
(princ (concat "\t" (gethash "time" msg) "\n"))
|
||||
))
|
||||
(idec-mode)))
|
||||
'msg-hash msg)
|
||||
(princ (concat "\t" (gethash "time" msg)))
|
||||
(princ (concat "\t" (gethash "author" msg) "\n")))
|
||||
(idec-mode))))
|
||||
|
||||
|
||||
;; NAVIGATION FUNCTIONS
|
||||
|
Loading…
Reference in New Issue
Block a user