From 29dd593fbe581d873c1fdb4302cb3bc2c1f859a7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 20 Mar 2017 19:10:13 +0900 Subject: [PATCH] Fix indantations --- src/api/stream/home.ts | 8 ++--- src/api/stream/messaging.ts | 62 ++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts index 80bced8ac..2ab8d3025 100644 --- a/src/api/stream/home.ts +++ b/src/api/stream/home.ts @@ -36,10 +36,10 @@ export default function homeStream(request: websocket.request, connection: webso switch (msg.type) { case 'capture': - if (!msg.id) return; - const postId = msg.id; - log(`CAPTURE: ${postId} by @${user.username}`); - subscriber.subscribe(`misskey:post-stream:${postId}`); + if (!msg.id) return; + const postId = msg.id; + log(`CAPTURE: ${postId} by @${user.username}`); + subscriber.subscribe(`misskey:post-stream:${postId}`); break; } }); diff --git a/src/api/stream/messaging.ts b/src/api/stream/messaging.ts index 4ec139b82..71bf7a34c 100644 --- a/src/api/stream/messaging.ts +++ b/src/api/stream/messaging.ts @@ -18,42 +18,42 @@ export default function messagingStream(request: websocket.request, connection: switch (msg.type) { case 'read': - if (!msg.id) { - return; + if (!msg.id) { + 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 - // 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 - } - }); + if (message.is_read) { + return; + } - if (message == null) { - return; - } + // Update documents + await Message.update({ + _id: id + }, { + $set: { is_read: true } + }); - if (message.is_read) { - return; - } - - // Update documents - await Message.update({ - _id: id - }, { - $set: { is_read: true } - }); - - // Publish event - publishMessagingStream(message.user_id, user._id, 'read', id.toString()); + // Publish event + publishMessagingStream(message.user_id, user._id, 'read', id.toString()); break; } });