   (let [react-url (interaction-url org-uuid board-uuid resource-uuid reaction)]
     (hateoas/link-map "react" hateoas/DELETE react-url {})))
 
-(defn- map-kv
-  "Utility function to do an operation on the value of every key in a map."
-  [f coll]
-  (reduce-kv (fn [m k v] (assoc m k (f v))) (empty coll) coll))
-
 (defn- reaction-and-link
   "Given the parts of a reaction URL, return a map representation of the reaction for use in the API."
   [org-uuid board-uuid resource-uuid reaction user?]

    (assoc :links [(if user?
                    (unreact-link org-uuid board-uuid resource-uuid (:reaction reaction))
                    (react-link org-uuid board-uuid resource-uuid (:reaction reaction)))])))

(defn- reaction-selection-sort
  "
  Sort order to select the most used reactions, with a tie breaker for default reactions in their default reaction
  order.
  "
  [reaction]
  (let [index-of (inc (.indexOf config/default-reactions (first reaction)))] ; order in the defaults
    (if (zero? index-of) ; is it in the defaults, or legacy?
      ;; it's legacy, so by reaction count
      (* (last reaction) -1) ; more reactions gives a lower (negative) #, so it has a higher sort
      ;; it's in the defaults, so by reaction count, but with a little extra for tie breaking with other reactions
      (- (* (last reaction) -1) (- 1 (* index-of 0.25)))))) ; the earlier it is in the defaults the bigger the tie breaker

(defn- reaction-order-sort
  "
  Keep the reaction order stable by sorting on the order they are provided, and if they are legacy
  reactions, by the order of how many reactions they have (which while not definitively stable, will
  effectively be fairly stable for legacy reactions).
  "
  [reaction]
  (let [index-of (.indexOf config/default-reactions (first reaction))] ; order in the defaults
    (if (= index-of -1) ; is it in the defaults, or legacy?
      (* (last reaction) 10) ; it's legacy, so by reaction count
      index-of))) ; by order in the defaults

(defn reactions-and-links
  "

    (map #(reaction-and-link org-uuid board-uuid resource-uuid %
            ; the user left one of these reactions?
            (some (fn [author-id] (= user-id author-id)) (:author-ids %)))
      limited-reactions)))