diff --git a/src/client.js b/src/client.js index a4d60f61..24a84f4b 100644 --- a/src/client.js +++ b/src/client.js @@ -102,10 +102,6 @@ function Client(manager, name, config = {}) { } } -Client.prototype.isRegistered = function() { - return this.name.length > 0; -}; - Client.prototype.emit = function(event, data) { if (this.sockets !== null) { this.sockets.in(this.id).emit(event, data); diff --git a/src/server.js b/src/server.js index 05b341f8..3fcc4ffa 100644 --- a/src/server.js +++ b/src/server.js @@ -407,30 +407,26 @@ function initializeClient(socket, client, token, lastMessage) { } }); - socket.on("push:register", (subscription) => { - if (!client.isRegistered() || !client.config.sessions.hasOwnProperty(token)) { - return; - } + if (!Helper.config.public) { + socket.on("push:register", (subscription) => { + if (!client.config.sessions.hasOwnProperty(token)) { + return; + } - const registration = client.registerPushSubscription(client.config.sessions[token], subscription); + const registration = client.registerPushSubscription(client.config.sessions[token], subscription); - if (registration) { - client.manager.webPush.pushSingle(client, registration, { - type: "notification", - timestamp: Date.now(), - title: "The Lounge", - body: "🚀 Push notifications have been enabled", - }); - } - }); + if (registration) { + client.manager.webPush.pushSingle(client, registration, { + type: "notification", + timestamp: Date.now(), + title: "The Lounge", + body: "🚀 Push notifications have been enabled", + }); + } + }); - socket.on("push:unregister", () => { - if (!client.isRegistered()) { - return; - } - - client.unregisterPushSubscription(token); - }); + socket.on("push:unregister", () => client.unregisterPushSubscription(token)); + } const sendSessionList = () => { const sessions = _.map(client.config.sessions, (session, sessionToken) => ({