Merge pull request #2082 from thelounge/xpaw/rm-isRegistered

Remove isRegistered
This commit is contained in:
Jérémie Astori 2018-02-22 00:45:22 -05:00 committed by GitHub
commit f8c894d7e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 25 deletions

View file

@ -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);

View file

@ -407,8 +407,9 @@ function initializeClient(socket, client, token, lastMessage) {
} }
}); });
if (!Helper.config.public) {
socket.on("push:register", (subscription) => { socket.on("push:register", (subscription) => {
if (!client.isRegistered() || !client.config.sessions.hasOwnProperty(token)) { if (!client.config.sessions.hasOwnProperty(token)) {
return; return;
} }
@ -424,14 +425,9 @@ function initializeClient(socket, client, token, lastMessage) {
} }
}); });
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) => ({
current: sessionToken === token, current: sessionToken === token,