Skip to content

Commit

Permalink
Merge pull request #8 from ryfow/merge-meta-with-payload
Browse files Browse the repository at this point in the history
merge payload into message to preserve message metadata
  • Loading branch information
niclasmeier committed Feb 23, 2014
2 parents 577cc65 + d6cfc4f commit c5f1810
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/herolabs/apns/message.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
(defn with-payload
"Adds additional payload to the message (everything except the :aps key)."
[message payload] (if-not (empty? payload)
(merge (dissoc payload :aps ) message)
(merge message (dissoc payload :aps))
message))

(defn with-alert-body
Expand Down
1 change: 1 addition & 0 deletions test/herolabs_test/apns/message.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
(with-loc-args {} "foo") => (just {:aps (just {:alert (just {:loc-args (just ["foo"])})})})
(with-loc-args {} ["foo" "bar"]) => (just {:aps (just {:alert (just {:loc-args (just ["foo" "bar"])})})})
(with-alert-body {} "TEST") => (just {:aps {:alert {:body "TEST"}}})
(meta (herolabs.apns.message/with-payload (with-meta {:foo :bar} {:a :b}) {:pay :load})) => {:a :b}
)

0 comments on commit c5f1810

Please sign in to comment.