diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c7d205..d3b515e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 5.2.0 + +- [CHANGED] Remove old notification references. It's no longer being used + ## 5.1.3 [FIXED] Parsing of the extraTokens in webhook's isValid method diff --git a/lib/notification_client.js b/lib/notification_client.js deleted file mode 100644 index f28a759..0000000 --- a/lib/notification_client.js +++ /dev/null @@ -1,25 +0,0 @@ -const requests = require("./requests") -const NotificationConfig = require("./notification_config") - -function NotificationClient(options) { - this.config = new NotificationConfig(options) -} - -NotificationClient.prototype.notify = function (interests, notification) { - if (!Array.isArray(interests)) { - throw new Error("Interests must be an array") - } - - if (interests.length == 0) { - throw new Error("Interests array must not be empty") - } - - const body = Object.assign({ interests: interests }, notification) - return requests.send(this.config, { - method: "POST", - body: body, - path: "/notifications", - }) -} - -module.exports = NotificationClient diff --git a/lib/notification_config.js b/lib/notification_config.js deleted file mode 100644 index 9a254f6..0000000 --- a/lib/notification_config.js +++ /dev/null @@ -1,18 +0,0 @@ -const Config = require("./config") - -const DEFAULT_HOST = "nativepush-cluster1.pusher.com" -const API_PREFIX = "server_api" -const API_VERSION = "v1" - -function NotificationConfig(options) { - Config.call(this, options) - this.host = options.host || DEFAULT_HOST -} - -Object.assign(NotificationConfig.prototype, Config.prototype) - -NotificationConfig.prototype.prefixPath = function (subPath) { - return "/" + API_PREFIX + "/" + API_VERSION + "/apps/" + this.appId + subPath -} - -module.exports = NotificationConfig diff --git a/lib/pusher.js b/lib/pusher.js index 3b25cf9..013a3ce 100644 --- a/lib/pusher.js +++ b/lib/pusher.js @@ -9,7 +9,6 @@ const requests = require("./requests") const PusherConfig = require("./pusher_config") const Token = require("./token") const WebHook = require("./webhook") -const NotificationClient = require("./notification_client") const validateChannel = function (channel) { if ( @@ -52,10 +51,8 @@ const validateUserData = function (userData) { * @constructor * @param {Object} options * @param {String} [options.host="api.pusherapp.com"] API hostname - * @param {String} [options.notification_host="api.pusherapp.com"] Notification API hostname * @param {Boolean} [options.useTLS=false] whether to use TLS * @param {Boolean} [options.encrypted=false] deprecated; renamed to `useTLS` - * @param {Boolean} [options.notification_encrypted=false] whether to use TLS for notifications * @param {Integer} [options.port] port, default depends on the scheme * @param {Integer} options.appId application ID * @param {String} options.key application key @@ -65,11 +62,6 @@ const validateUserData = function (userData) { */ function Pusher(options) { this.config = new PusherConfig(options) - const notificationOptions = Object.assign({}, options, { - host: options.notificationHost, - encrypted: options.notificationEncrypted, - }) - this.notificationClient = new NotificationClient(notificationOptions) } /** Create a Pusher instance using a URL. @@ -237,10 +229,6 @@ Pusher.prototype.triggerBatch = function (batch) { return events.triggerBatch(this, batch) } -Pusher.prototype.notify = function () { - this.notificationClient.notify.apply(this.notificationClient, arguments) -} - /** Makes a POST request to Pusher, handles the authentication. * * Returns a promise resolving to a response, or rejecting to a RequestError. diff --git a/package.json b/package.json index c42f9ca..e006458 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pusher", "description": "Node.js client to interact with the Pusher Channels REST API", - "version": "5.1.3", + "version": "5.2.0", "author": "Pusher ", "contributors": [ { diff --git a/tests/integration/pusher/notification_client.js b/tests/integration/pusher/notification_client.js deleted file mode 100644 index 378ebdc..0000000 --- a/tests/integration/pusher/notification_client.js +++ /dev/null @@ -1,49 +0,0 @@ -const expect = require("expect.js") -const NotificationClient = require("../../../lib/notification_client") -const nock = require("nock") - -describe("NativeNotificationClient", function () { - let client - - beforeEach(function () { - client = new NotificationClient({ - appId: 1234, - key: "f00d", - secret: "tofu", - }) - nock.cleanAll() - nock.disableNetConnect() - }) - - afterEach(function () { - nock.cleanAll() - nock.enableNetConnect() - }) - - xit("should send in the success case", function (done) { - const mock = nock("nativepush-cluster1.pusher.com:80") - client.notify( - ["yolo"], - { - apns: { - aps: { - alert: { - title: "yolo", - body: "woot", - }, - }, - }, - gcm: { - notification: { - title: "huzzah", - icon: "woot", - }, - }, - }, - function () { - expect(mock.isDone()).to.be(true) - done() - } - ) - }) -})