refactor: simplify
This commit is contained in:
parent
adba33448b
commit
55f8b77a98
|
@ -8,13 +8,16 @@ export default async (latus, channel, socket) => {
|
|||
if (!isAnonymous && !req.userId) {
|
||||
return;
|
||||
}
|
||||
const [id, username] = isAnonymous
|
||||
? [0, 'anonymous']
|
||||
: [req.user.id, req.user.redditUsername];
|
||||
const users = await channelUsers(req, channel);
|
||||
const rendered = renderChannel(channel);
|
||||
if (-1 === users.indexOf(id)) {
|
||||
socket.to(rendered).send(['Join', {channel, id, username}]);
|
||||
if (!isAnonymous) {
|
||||
const users = await channelUsers(req, channel);
|
||||
if (-1 === users.indexOf(req.user.id)) {
|
||||
socket.to(rendered).send(['Join', {
|
||||
channel,
|
||||
id: req.user.id,
|
||||
username: req.user.redditUsername,
|
||||
}]);
|
||||
}
|
||||
}
|
||||
await socket.join(rendered);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user