about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/sterni/mblog/default.nix1
-rw-r--r--users/sterni/mblog/note.lisp41
-rw-r--r--users/sterni/mblog/packages.lisp2
3 files changed, 9 insertions, 35 deletions
diff --git a/users/sterni/mblog/default.nix b/users/sterni/mblog/default.nix
index 00e8b39ada0d..607d198930d1 100644
--- a/users/sterni/mblog/default.nix
+++ b/users/sterni/mblog/default.nix
@@ -19,7 +19,6 @@
     }
     depot.lisp.klatre
     depot.third_party.lisp.alexandria
-    depot.third_party.lisp.babel
     depot.third_party.lisp.closure-html
     depot.third_party.lisp.cl-date-time-parser
     depot.third_party.lisp.cl-who
diff --git a/users/sterni/mblog/note.lisp b/users/sterni/mblog/note.lisp
index f953d6b1e662..45be0f4e88a8 100644
--- a/users/sterni/mblog/note.lisp
+++ b/users/sterni/mblog/note.lisp
@@ -19,15 +19,8 @@
   surrounds them with angle brackets for a MIME header"
   (concatenate 'string "<" cid ">"))
 
-;; TODO(sterni): move into mime4cl
-(defun find-mime-message-header (header-name message)
-  (when-let ((header (assoc header-name
-                            (mime:mime-message-headers message)
-                            :test #'string-equal)))
-    (cdr header)))
-
 (defun find-mime-message-date (message)
-  (when-let ((date-string (find-mime-message-header "Date" message)))
+  (when-let ((date-string (car (mime:mime-message-header-values "Date" message))))
     (date-time-parser:parse-date-time date-string)))
 
 ;;; main implementation
@@ -65,24 +58,10 @@
 (defun apple-note-p (msg)
   "Checks X-Uniform-Type-Identifier of a MIME:MIME-MESSAGE
   to determine if a given mime message claims to be an Apple Note."
-  (when-let (uniform-id (assoc "X-Uniform-Type-Identifier"
-                               (mime:mime-message-headers msg)
-                               :test #'string-equal))
-    (string-equal (cdr uniform-id) "com.apple.mail-note")))
-
-(defun decode-RFC2047-to-string (input)
-  (apply
-   #'concatenate
-   (cons 'string
-         (mapcar
-          (lambda (el)
-            (etypecase el
-              (cons (babel:octets-to-string
-                     (car el)
-                     :encoding (babel-encodings:get-character-encoding
-                                (intern (string-upcase (cdr el)) 'keyword))))
-              (string el)))
-          (mime:parse-RFC2047-text input)))))
+  (when-let (uniform-id (car (mime:mime-message-header-values
+                              "X-Uniform-Type-Identifier"
+                              msg)))
+    (string-equal uniform-id "com.apple.mail-note")))
 
 (defun make-apple-note (msg)
   (check-type msg mime-message)
@@ -91,12 +70,10 @@
     (error "Passed message is not an Apple Note according to headers"))
 
   (let ((text-part (mime:find-mime-text-part msg))
-        (subject (when-let ((val (find-mime-message-header "Subject" msg)))
-                   ;; TODO(sterni): mime4cl should do this
-                   (decode-RFC2047-to-string val)))
-        (uuid (when-let ((val (find-mime-message-header
-                               "X-Universally-Unique-Identifier"
-                               msg)))
+        (subject (car (mime:mime-message-header-values "Subject" msg :decode t)))
+        (uuid (when-let ((val (car (mime:mime-message-header-values
+                                    "X-Universally-Unique-Identifier"
+                                    msg))))
                 (string-downcase val)))
         (time (find-mime-message-date msg)))
     ;; The idea here is that we don't need to check a lot manually, instead
diff --git a/users/sterni/mblog/packages.lisp b/users/sterni/mblog/packages.lisp
index 94fce16d40cf..e4fcb4672828 100644
--- a/users/sterni/mblog/packages.lisp
+++ b/users/sterni/mblog/packages.lisp
@@ -8,8 +8,6 @@
 (defpackage :note
   (:use
    :common-lisp
-   :babel
-   :babel-encodings
    :closure-html
    :cl-date-time-parser
    :mime4cl)