Remove isRegistered
This commit is contained in:
parent
f8e53d5f72
commit
b10962f13f
@ -102,10 +102,6 @@ function Client(manager, name, config = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client.prototype.isRegistered = function() {
|
|
||||||
return this.name.length > 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Client.prototype.emit = function(event, data) {
|
Client.prototype.emit = function(event, data) {
|
||||||
if (this.sockets !== null) {
|
if (this.sockets !== null) {
|
||||||
this.sockets.in(this.id).emit(event, data);
|
this.sockets.in(this.id).emit(event, data);
|
||||||
|
@ -401,30 +401,26 @@ function initializeClient(socket, client, token, lastMessage) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("push:register", (subscription) => {
|
if (!Helper.config.public) {
|
||||||
if (!client.isRegistered() || !client.config.sessions.hasOwnProperty(token)) {
|
socket.on("push:register", (subscription) => {
|
||||||
return;
|
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) {
|
if (registration) {
|
||||||
client.manager.webPush.pushSingle(client, registration, {
|
client.manager.webPush.pushSingle(client, registration, {
|
||||||
type: "notification",
|
type: "notification",
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
title: "The Lounge",
|
title: "The Lounge",
|
||||||
body: "🚀 Push notifications have been enabled",
|
body: "🚀 Push notifications have been enabled",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("push:unregister", () => {
|
socket.on("push:unregister", () => client.unregisterPushSubscription(token));
|
||||||
if (!client.isRegistered()) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
client.unregisterPushSubscription(token);
|
|
||||||
});
|
|
||||||
|
|
||||||
const sendSessionList = () => {
|
const sendSessionList = () => {
|
||||||
const sessions = _.map(client.config.sessions, (session, sessionToken) => ({
|
const sessions = _.map(client.config.sessions, (session, sessionToken) => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user