From a561798a7ff183867a06f1be326a3228f7b3e844 Mon Sep 17 00:00:00 2001 From: Anthony Castelli Date: Thu, 26 Apr 2018 10:05:28 -0700 Subject: [PATCH] message: Fix up an issue with JSONEncoder and the HTTPBody --- Package.resolved | 71 ++++++++++++++++++++++++++------------ Sources/APNS/Message.swift | 4 +-- 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/Package.resolved b/Package.resolved index 7c11dec..2b87005 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/vapor/console.git", "state": { "branch": null, - "revision": "038e30ec9004fb1915d14d964a3facc1ec5c80f4", - "version": "3.0.0" + "revision": "30f102dcf4d18862a14df9f65c4b91d117005926", + "version": "3.0.1" } }, { @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/vapor/core.git", "state": { "branch": null, - "revision": "5383e40f19d71da99e496afa9972c085abc2379d", - "version": "3.0.2" + "revision": "71722db60bcd94532d5ff5894b85d697e6e27db8", + "version": "3.1.3" } }, { @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/vapor/crypto.git", "state": { "branch": null, - "revision": "e77aa181580b466fb26865918b62973d9fbfaed6", - "version": "3.0.0" + "revision": "346ae2b2ea65a4b6f4985a8e8cb25cf61da549d8", + "version": "3.1.1" } }, { @@ -33,17 +33,17 @@ "repositoryURL": "https://github.com/vapor/database-kit.git", "state": { "branch": null, - "revision": "e594e658cc001e04b8d4ad13881d8714c510f94f", - "version": "1.0.0-rc.2.2.2" + "revision": "c4e4f08b83a2407989332f970d6447de07ee7b91", + "version": "1.0.0" } }, { - "package": "Engine", - "repositoryURL": "https://github.com/vapor/engine.git", + "package": "HTTP", + "repositoryURL": "https://github.com/vapor/http.git", "state": { "branch": null, - "revision": "4846ea9abeb04863f82f618ee8cb22650a82ae3c", - "version": "3.0.0-rc.2.1.1" + "revision": "f934c1391c370fbf529bd461b40aa75ce40ce1e5", + "version": "3.0.2" } }, { @@ -55,13 +55,22 @@ "version": "3.0.0-rc.2.1.1" } }, + { + "package": "Multipart", + "repositoryURL": "https://github.com/vapor/multipart.git", + "state": { + "branch": null, + "revision": "7778dcb62f3efa845e8e2808937bb347575ba7ce", + "version": "3.0.1" + } + }, { "package": "Routing", "repositoryURL": "https://github.com/vapor/routing.git", "state": { "branch": null, - "revision": "2fc1d4de22a54848b35ad17b3e7f7816f19ebf90", - "version": "3.0.0-rc.2" + "revision": "3219e328491b0853b8554c5a694add344d2c6cfb", + "version": "3.0.1" } }, { @@ -78,8 +87,8 @@ "repositoryURL": "https://github.com/apple/swift-nio.git", "state": { "branch": null, - "revision": "a0b7f646fba61402da384b3202f54c27debb5e13", - "version": "1.3.1" + "revision": "902b18df16897da644724bd4b85b4bbe952ac9c6", + "version": "1.5.1" } }, { @@ -114,8 +123,17 @@ "repositoryURL": "https://github.com/vapor/template-kit.git", "state": { "branch": null, - "revision": "61ed3d3b0df4c181d6b88e06b418f425978ac2af", - "version": "1.0.0-rc.2.0.3" + "revision": "43b57b5861d5181b906ac6411d28645e980bb638", + "version": "1.0.1" + } + }, + { + "package": "URLEncodedForm", + "repositoryURL": "https://github.com/vapor/url-encoded-form.git", + "state": { + "branch": null, + "revision": "8448fa943057c01220f6a940d3b1b8e9fd92a96e", + "version": "1.0.2" } }, { @@ -123,8 +141,8 @@ "repositoryURL": "https://github.com/vapor/validation.git", "state": { "branch": null, - "revision": "1ce87fc2d18a8f15a491805825063c8db493a51e", - "version": "2.0.0-rc.2.1.1" + "revision": "ab6c5a352d97c8687b91ed4963aef8e7cfe0795b", + "version": "2.0.0" } }, { @@ -132,8 +150,17 @@ "repositoryURL": "https://github.com/vapor/vapor.git", "state": { "branch": null, - "revision": "c045b8d02e6a135f055e879a9fa789026a0b4e9d", - "version": "3.0.0-rc.2.2.4" + "revision": "c834f9495ff5ab9768b74f5822ff23d795e36922", + "version": "3.0.0-rc.2.8.1" + } + }, + { + "package": "WebSocket", + "repositoryURL": "https://github.com/vapor/websocket.git", + "state": { + "branch": null, + "revision": "23acd21aa37a200faa2f5d5525c974efa6b5676c", + "version": "1.0.0" } } ] diff --git a/Sources/APNS/Message.swift b/Sources/APNS/Message.swift index 269efc6..5666682 100644 --- a/Sources/APNS/Message.swift +++ b/Sources/APNS/Message.swift @@ -56,7 +56,7 @@ public struct Message { /// Use the development or production servers public let development: Bool - + /// Creates a new message public init(priority: Priority = .immediately, profile: Profile, deviceToken: String, payload: Payload, on container: Container, development: Bool = false) throws { self.profile = profile self.priority = priority @@ -89,7 +89,7 @@ public struct Message { } let encoder = JSONEncoder() - request.http.body = try encoder.encodeBody(from: PayloadContent(payload: self.payload)) + request.http.body = try HTTPBody(data: encoder.encode(PayloadContent(payload: self.payload))) if self.development { guard let url = URL(string: "https://api.development.push.apple.com/3/device/\(self.deviceToken)") else {