From d37e1d4d606a1f796e278e3c8839f1defcab9f83 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 20 Jan 2017 17:38:05 +0900 Subject: [PATCH] [API] Fix bugs --- src/api/endpoints/app/create.js | 4 +--- src/api/endpoints/auth/session/generate.js | 4 +--- src/api/endpoints/drive/folders/create.js | 4 +--- src/api/endpoints/messaging/messages/create.js | 4 +--- src/api/endpoints/posts/favorites/create.js | 4 +--- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/api/endpoints/app/create.js b/src/api/endpoints/app/create.js index 9ce98b197..1febd9b56 100644 --- a/src/api/endpoints/app/create.js +++ b/src/api/endpoints/app/create.js @@ -109,7 +109,7 @@ module.exports = async (params, user) => const secret = rndstr('a-zA-Z0-9', 32); // Create account - const inserted = await App.insert({ + const app = await App.insert({ created_at: new Date(), user_id: user._id, name: name, @@ -121,8 +121,6 @@ module.exports = async (params, user) => secret: secret }); - const app = inserted.ops[0]; - // Response res(await serialize(app)); }); diff --git a/src/api/endpoints/auth/session/generate.js b/src/api/endpoints/auth/session/generate.js index f67209eee..6cc124f9e 100644 --- a/src/api/endpoints/auth/session/generate.js +++ b/src/api/endpoints/auth/session/generate.js @@ -66,14 +66,12 @@ module.exports = (params) => const token = uuid.v4(); // Create session token document - const inserted = await AuthSess.insert({ + const doc = await AuthSess.insert({ created_at: new Date(), app_id: app._id, token: token }); - const doc = inserted.ops[0]; - // Response res({ token: doc.token, diff --git a/src/api/endpoints/drive/folders/create.js b/src/api/endpoints/drive/folders/create.js index ba40d1763..a9c0968aa 100644 --- a/src/api/endpoints/drive/folders/create.js +++ b/src/api/endpoints/drive/folders/create.js @@ -59,15 +59,13 @@ module.exports = (params, user) => } // Create folder - const inserted = await DriveFolder.insert({ + const folder = await DriveFolder.insert({ created_at: new Date(), name: name, parent_id: parent !== null ? parent._id : null, user_id: user._id }); - const folder = inserted.ops[0]; - // Serialize const folderObj = await serialize(folder); diff --git a/src/api/endpoints/messaging/messages/create.js b/src/api/endpoints/messaging/messages/create.js index 1cd02cfc5..021ec98e0 100644 --- a/src/api/endpoints/messaging/messages/create.js +++ b/src/api/endpoints/messaging/messages/create.js @@ -77,7 +77,7 @@ module.exports = (params, user) => } // メッセージを作成 - const inserted = await Message.insert({ + const message = await Message.insert({ created_at: new Date(), file_id: file ? file._id : undefined, recipient_id: recipient._id, @@ -86,8 +86,6 @@ module.exports = (params, user) => is_read: false }); - const message = inserted.ops[0]; - // Serialize const messageObj = await serialize(message); diff --git a/src/api/endpoints/posts/favorites/create.js b/src/api/endpoints/posts/favorites/create.js index d20a523d5..f2e29bbc3 100644 --- a/src/api/endpoints/posts/favorites/create.js +++ b/src/api/endpoints/posts/favorites/create.js @@ -43,14 +43,12 @@ module.exports = (params, user) => } // Create favorite - const inserted = await Favorite.insert({ + await Favorite.insert({ created_at: new Date(), post_id: post._id, user_id: user._id }); - const favorite = inserted.ops[0]; - // Send response res(); });