   :handle-unprocessable-entity (fn [ctx]
     (api-common/unprocessable-entity-response (map #(schema/check common-res/FollowUp %) (:follow-ups ctx)))))
 
+(defresource inbox-dismiss-all [conn org-slug]
+  (api-common/open-company-authenticated-resource config/passphrase) ; verify validity and presence of required JWToken
+  :allowed-methods [:options :post]
+
+  ;; Authorization
+  :allowed? (by-method {
+    :options true
+    :post (fn [ctx] (access/allow-members conn org-slug (:user ctx)))})
+
+  ;; Media type client accepts
+  :available-media-types (by-method {
+                            :post [mt/entry-media-type]})
+  :handle-not-acceptable (by-method {
+                            :post (api-common/only-accept 406 mt/entry-media-type)})
+
+  ;; Data handling
+  :new? false
+  :respond-with-entity? true
+
+  ;; Validations
+  :processable? (by-method {
+    :options true
+    :post (fn [ctx] (valid-dismiss-all-update? conn ctx org-slug (:user ctx)))})
+
+  ;; Possibly no data to handle
+  :malformed? (by-method {
+    :options false
+    :post (fn [ctx] (api-common/malformed-json? ctx true))}) ; allow nil
+
+  ;; Existentialism
+  :can-post-to-missing? false
+  :exists? (fn [ctx] (if-let* [_slugs? (slugify/valid-slug? org-slug)
+                               org (or (:existing-org ctx)
+                                       (org-res/get-org conn org-slug))
+                               org-uuid (:uuid org)]
+                        {:existing-org (api-common/rep org)}
+                        false))
+
+  ;; Actions
+  :post! (fn [ctx]
+           (inbox-dismiss-all conn ctx org-slug))
+
+  :handle-unprocessable-entity (fn [ctx]
+    (api-common/unprocessable-entity-response (:updated-entries ctx))))
+
+(defresource inbox [conn org-slug board-slug entry-uuid action-type]
+  (api-common/open-company-authenticated-resource config/passphrase) ; verify validity and presence of required JWToken
+  :allowed-methods [:options :post]
+
+  ;; Authorization
+  :allowed? (by-method {
+    :options true
+    :post (fn [ctx] (access/allow-members conn org-slug (:user ctx)))})
+
+  ;; Media type client accepts
+  :available-media-types (by-method {
+                            :post [mt/entry-media-type]})
+  :handle-not-acceptable (by-method {
+                            :post (api-common/only-accept 406 mt/entry-media-type)})
+
+  ;; Data handling
+  :new? false
+  :respond-with-entity? true
+
+  ;; Validations
+  :processable? (by-method {
+    :options true
+    :post (fn [ctx] (valid-entry-new-update? conn ctx org-slug entry-uuid (:user ctx) action-type))})
+
+  ;; Possibly no data to handle
+  :malformed? (by-method {
+    :options false
+    :post (fn [ctx] (api-common/malformed-json? ctx true))}) ; allow nil
+
+  ;; Existentialism
+  :can-post-to-missing? false
+  :exists? (fn [ctx] (if-let* [_slugs? (and (slugify/valid-slug? org-slug)
+                                            (slugify/valid-slug? board-slug))
+                               org (or (:existing-org ctx)
+                                       (org-res/get-org conn org-slug))
+                               org-uuid (:uuid org)
+                               entry (or (:existing-entry ctx)
+                                         (entry-res/get-entry conn entry-uuid))
+                               board (board-res/get-board conn (:board-uuid entry))
+                               comments (or (:existing-comments ctx)
+                                            (entry-res/list-comments-for-entry conn (:uuid entry)))
+                               reactions (or (:existing-reactions ctx)
+                                             (entry-res/list-reactions-for-entry conn (:uuid entry)))]
+                        {:existing-org (api-common/rep org) :existing-board (api-common/rep board)
+                         :existing-entry (api-common/rep entry)
+                         :existing-comments (api-common/rep comments)
+                         :existing-reactions (api-common/rep reactions)}
+                        false))
+
+  ;; Actions
+  :post! (fn [ctx]
+           (update-entry-new conn ctx (s/join " " [org-slug board-slug entry-uuid]) action-type))
+
+  ;; Responses
+  :handle-ok (fn [ctx] (entry-rep/render-entry (:existing-org ctx)
+                                               (:existing-board ctx)
+                                               (:updated-entry ctx)
+                                               (:existing-comments ctx)
+                                               (reaction-res/aggregate-reactions (:existing-reactions ctx))
+                                               (:access-level ctx)
+                                               (-> ctx :user :user-id)))
+  :handle-unprocessable-entity (fn [ctx]
+    (api-common/unprocessable-entity-response (:updated-entry ctx))))
+
 ;; ----- Routes -----
 
 (defn routes [sys]

     :existing-entries (api-common/rep entries)}
    false))

;; ----- Actions -----

(defn- share-entry [conn ctx entry-for]

      (timbre/info "Updated entry for:" entry-for)
      (notification/send-trigger! (notification/->trigger :update org board {:old entry :new final-entry} user nil))
      {:updated-entry (api-common/rep (assoc final-entry :board-name (:name board)))})

    (do (timbre/error "Failed updating entry:" entry-for) false)))

(defn- update-entry-new [conn ctx entry-for action-type]
  (timbre/info "Updating entry for:" entry-for)
  (if-let* [org (:existing-org ctx)
            board (:existing-board ctx)
            user (:user ctx)
            entry (:existing-entry ctx)
            updated-entry (:updated-entry ctx)
            final-entry (entry-res/update-entry! conn (:uuid updated-entry) updated-entry user)
            dismiss-at (:data ctx)]
    (let [notify-map (cond
                      (= action-type :dismiss)
                      {:dismiss-at dismiss-at}
                      (= action-type :follow)
                      {:follow true}
                      (= action-type :unfollow)
                      {:unfollow true})]
      (timbre/info "Updated entry new for:" entry-for "action:" action-type)
      (notification/send-trigger! (notification/->trigger action-type org board {:old entry :new updated-entry :inbox-action notify-map} user nil))
      {:updated-entry (api-common/rep final-entry)})

    (do (timbre/error "Failed updating entry:" entry-for) false)))

(defn- inbox-dismiss-all [conn ctx entry-for]
  (timbre/info "Dismiss all entries for:" entry-for)
  (if-let* [org (:existing-org ctx)
            user (:user ctx)
            existing-entries (:existing-entries ctx)
            final-entries (map
                            #(entry-res/update-entry! conn (:uuid %) % user)
                            existing-entries)
            dismiss-at (:data ctx)]
    (if (every? #(lib-schema/valid? common-res/Entry %) final-entries)
      (do
        (timbre/info "Dismissed all entries for:" entry-for)
        (doseq [entry final-entries]
          (notification/send-trigger! (notification/->trigger :dismiss org nil {:new entry :inbox-action {:dismiss-at dismiss-at}} user nil)))
        {:updated-entries (api-common/rep final-entries)})
      false)

    (do (timbre/error "Failed updating entry:" entry-for) false)))

