 ; finding data
 
 (defn thread-unseen?
-  "A thread is unseen if it's last-open-at is prior to any of the messages' created-at"
+  "A thread is unseen if it's last-open-at is prior to any of the messages'
+  created-at"
   [thread]
   (let [last-open (to-date-time (thread :last-open-at))]
     (some (fn [{:keys [created-at]}]

  [threads]
  {:html  (inline-css (render-resource "templates/email_digest.html.mustache"
                                       {:threads threads}))
   :text (render-resource "templates/email_digest.txt.mustache" {:threads threads})})

; sending


              (filter (partial last-message-after? cutoff))
              (map
                (fn [t]
                  (let [thread-last-open (to-date-time
                                           (db/thread-last-open-at t user-id))]
                    (update t :messages
                            (partial map
                                     (fn [{sender-id :user-id :as m}]
                                       (-> m
                                           (update :content parse-tags-and-metions)
                                           (assoc :unseen
                                             (if (time/before?
                                                   (to-date-time (m :created-at))
                                                   thread-last-open)
                                               "seen" "unseen"))
                                           (update :created-at pretty-time)
                                           (assoc :sender (id->nick sender-id))
                                           (assoc :sender-avatar
                                                  (id->avatar sender-id))))))))))
            (db/get-open-threads-for-user user-id)))))

(defn daily-update-users
