|
@@ -21,13 +21,10 @@ const activities = require("../activities");
|
|
|
cache.runJob("SUB", {
|
|
|
channel: "user.updateUsername",
|
|
|
cb: (user) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: user._id,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("event:user.username.changed", user.username);
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId: user._id }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("event:user.username.changed", user.username);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
@@ -35,13 +32,10 @@ cache.runJob("SUB", {
|
|
|
cache.runJob("SUB", {
|
|
|
channel: "user.removeSessions",
|
|
|
cb: (userId) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER_WITHOUT_CACHE", {
|
|
|
- userId: userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("keep.event:user.session.removed");
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER_WITHOUT_CACHE", { userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("keep.event:user.session.removed");
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
@@ -49,55 +43,43 @@ cache.runJob("SUB", {
|
|
|
cache.runJob("SUB", {
|
|
|
channel: "user.linkPassword",
|
|
|
cb: (userId) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("event:user.linkPassword");
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("event:user.linkPassword");
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
|
|
|
|
cache.runJob("SUB", {
|
|
|
- channel: "user.linkGitHub",
|
|
|
- cb: (userId) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("event:user.linkGitHub");
|
|
|
- });
|
|
|
- },
|
|
|
+ channel: "user.unlinkPassword",
|
|
|
+ cb: userId => {
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("event:user.unlinkPassword");
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
|
|
|
|
cache.runJob("SUB", {
|
|
|
- channel: "user.unlinkPassword",
|
|
|
+ channel: "user.linkGithub",
|
|
|
cb: (userId) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("event:user.unlinkPassword");
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("event:user.linkGithub");
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
|
|
|
|
cache.runJob("SUB", {
|
|
|
- channel: "user.unlinkGitHub",
|
|
|
- cb: (userId) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("event:user.unlinkGitHub");
|
|
|
- });
|
|
|
- },
|
|
|
+ channel: "user.unlinkGithub",
|
|
|
+ cb: userId => {
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("event:user.unlinkGithub");
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
@@ -105,14 +87,11 @@ cache.runJob("SUB", {
|
|
|
cache.runJob("SUB", {
|
|
|
channel: "user.ban",
|
|
|
cb: (data) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: data.userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("keep.event:banned", data.punishment);
|
|
|
- socket.disconnect(true);
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("keep.event:banned", data.punishment);
|
|
|
+ socket.disconnect(true);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
@@ -120,13 +99,10 @@ cache.runJob("SUB", {
|
|
|
cache.runJob("SUB", {
|
|
|
channel: "user.favoritedStation",
|
|
|
cb: (data) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: data.userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit("event:user.favoritedStation", data.stationId);
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit("event:user.favoritedStation", data.stationId);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|
|
@@ -134,16 +110,13 @@ cache.runJob("SUB", {
|
|
|
cache.runJob("SUB", {
|
|
|
channel: "user.unfavoritedStation",
|
|
|
cb: (data) => {
|
|
|
- utils.runJob("SOCKETS_FROM_USER", {
|
|
|
- userId: data.userId,
|
|
|
- cb: (response) => {
|
|
|
- response.sockets.forEach((socket) => {
|
|
|
- socket.emit(
|
|
|
- "event:user.unfavoritedStation",
|
|
|
- data.stationId
|
|
|
- );
|
|
|
- });
|
|
|
- },
|
|
|
+ utils.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => {
|
|
|
+ response.sockets.forEach((socket) => {
|
|
|
+ socket.emit(
|
|
|
+ "event:user.unfavoritedStation",
|
|
|
+ data.stationId
|
|
|
+ );
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
});
|