0
0

Fix indantations

This commit is contained in:
syuilo 2017-03-20 19:10:13 +09:00
parent 1e2320a6e6
commit 29dd593fbe
2 changed files with 35 additions and 35 deletions

View File

@ -36,10 +36,10 @@ export default function homeStream(request: websocket.request, connection: webso
switch (msg.type) { switch (msg.type) {
case 'capture': case 'capture':
if (!msg.id) return; if (!msg.id) return;
const postId = msg.id; const postId = msg.id;
log(`CAPTURE: ${postId} by @${user.username}`); log(`CAPTURE: ${postId} by @${user.username}`);
subscriber.subscribe(`misskey:post-stream:${postId}`); subscriber.subscribe(`misskey:post-stream:${postId}`);
break; break;
} }
}); });

View File

@ -18,42 +18,42 @@ export default function messagingStream(request: websocket.request, connection:
switch (msg.type) { switch (msg.type) {
case 'read': case 'read':
if (!msg.id) { if (!msg.id) {
return; return;
}
const id = new mongodb.ObjectID(msg.id);
// Fetch message
// SELECT _id, user_id, is_read
const message = await Message.findOne({
_id: id,
recipient_id: user._id
}, {
fields: {
_id: true,
user_id: true,
is_read: true
} }
});
const id = new mongodb.ObjectID(msg.id); if (message == null) {
return;
}
// Fetch message if (message.is_read) {
// SELECT _id, user_id, is_read return;
const message = await Message.findOne({ }
_id: id,
recipient_id: user._id
}, {
fields: {
_id: true,
user_id: true,
is_read: true
}
});
if (message == null) { // Update documents
return; await Message.update({
} _id: id
}, {
$set: { is_read: true }
});
if (message.is_read) { // Publish event
return; publishMessagingStream(message.user_id, user._id, 'read', id.toString());
}
// Update documents
await Message.update({
_id: id
}, {
$set: { is_read: true }
});
// Publish event
publishMessagingStream(message.user_id, user._id, 'read', id.toString());
break; break;
} }
}); });