 (use-logging)
 
 (defn _id-to-id [mongo-object]
-  (if (nil? mongo-object)
-    nil
+  (when mongo-object
     (let [id (str (:_id mongo-object))]
       (-> mongo-object (dissoc :_id) (assoc :id id)))))
 
 (defn id-to-sid [mongo-object]
-  (if (nil? mongo-object)
-    nil
+  (when mongo-object
     (-> mongo-object (assoc :sid (:id mongo-object)))))
 
 (defn own? [user dbo]


(defn list-by [user params]
  (let [page (parse-int (params :page "1"))
        rules (merge (filter/make-query-from params) {:draft false})
        sort-order (filter/sort-results-by params)]
    (list-result user page rules sort-order)))

(defn list-drafts [user params]
  (let [page (parse-int (params :page "1"))
        rules {:user user :draft true}
        sort-order (filter/sort-results-by params)]
    (list-result user page rules sort-order)))
      (error "Db object deleted or not own. Refusing to update: " user params id))))

(defn generate-publication-date [blog]
  (when blog
    (assoc blog :published (local/local-now))))

(defn publish [user params]
  (let [id (:id params)
