|
@@ -66,11 +66,11 @@ CacheModule.runJob("SUB", {
|
|
this
|
|
this
|
|
).then(userModel =>
|
|
).then(userModel =>
|
|
userModel.findOne({ _id: session.userId }, (err, user) => {
|
|
userModel.findOne({ _id: session.userId }, (err, user) => {
|
|
- if (user.role === "admin")
|
|
|
|
|
|
+ if (user && user.role === "admin")
|
|
socket.dispatch("event:station.userCount.updated", {
|
|
socket.dispatch("event:station.userCount.updated", {
|
|
data: { stationId, count }
|
|
data: { stationId, count }
|
|
});
|
|
});
|
|
- else if (station.type === "community" && station.owner === session.userId)
|
|
|
|
|
|
+ else if (user && station.type === "community" && station.owner === session.userId)
|
|
socket.dispatch("event:station.userCount.updated", {
|
|
socket.dispatch("event:station.userCount.updated", {
|
|
data: { stationId, count }
|
|
data: { stationId, count }
|
|
});
|
|
});
|
|
@@ -518,9 +518,9 @@ CacheModule.runJob("SUB", {
|
|
}).then(session => {
|
|
}).then(session => {
|
|
if (session) {
|
|
if (session) {
|
|
userModel.findOne({ _id: session.userId }, (err, user) => {
|
|
userModel.findOne({ _id: session.userId }, (err, user) => {
|
|
- if (user.role === "admin")
|
|
|
|
|
|
+ if (user && user.role === "admin")
|
|
socket.dispatch("event:station.created", { data: { station } });
|
|
socket.dispatch("event:station.created", { data: { station } });
|
|
- else if (station.type === "community" && station.owner === session.userId)
|
|
|
|
|
|
+ else if (user && station.type === "community" && station.owner === session.userId)
|
|
socket.dispatch("event:station.created", { data: { station } });
|
|
socket.dispatch("event:station.created", { data: { station } });
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -571,7 +571,8 @@ export default {
|
|
return next(null, { favoriteStations: [] });
|
|
return next(null, { favoriteStations: [] });
|
|
},
|
|
},
|
|
|
|
|
|
- ({ favoriteStations }, next) => {
|
|
|
|
|
|
+ (user, next) => {
|
|
|
|
+ const favoriteStations = (user) ? user.favoriteStations : [];
|
|
CacheModule.runJob("HGETALL", { table: "stations" }, this).then(stations =>
|
|
CacheModule.runJob("HGETALL", { table: "stations" }, this).then(stations =>
|
|
next(null, stations, favoriteStations)
|
|
next(null, stations, favoriteStations)
|
|
);
|
|
);
|