From e22a6f2913a51f93ce4681f12407070de40f1797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Sat, 9 Sep 2017 04:39:23 +0900 Subject: [PATCH 01/18] Update user.ts --- src/api/serializers/user.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/api/serializers/user.ts b/src/api/serializers/user.ts index 57599fe85c..23a176096a 100644 --- a/src/api/serializers/user.ts +++ b/src/api/serializers/user.ts @@ -37,7 +37,9 @@ export default ( data: false } : { data: false, - profile: false + profile: false, + keywords: false, + domains: false }; // Populate the user if 'user' is ID @@ -119,6 +121,7 @@ export default ( if (opts.detail) { if (_user.pinned_post_id) { + // Populate pinned post _user.pinned_post = await serializePost(_user.pinned_post_id, meId, { detail: true }); From b89b950ec3b7d00340b6d336d22bc9f5a6f07563 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 8 Sep 2017 21:38:17 +0000 Subject: [PATCH 02/18] chore(package): update @types/mocha to version 2.2.43 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0dbfa1a10c..a3f048d27f 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@types/is-root": "1.0.0", "@types/is-url": "1.2.28", "@types/js-yaml": "3.9.0", - "@types/mocha": "2.2.42", + "@types/mocha": "2.2.43", "@types/mongodb": "2.2.11", "@types/monk": "1.0.6", "@types/morgan": "1.7.32", From 44b405a8a30c53a3f9d27574233babaad0bd47e1 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 8 Sep 2017 21:51:57 +0000 Subject: [PATCH 03/18] chore(package): update @types/node to version 8.0.28 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0dbfa1a10c..036edc41a0 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@types/morgan": "1.7.32", "@types/ms": "0.7.30", "@types/multer": "1.3.2", - "@types/node": "8.0.27", + "@types/node": "8.0.28", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.3", From 462e6c6d1cf6a6138d1e75f4a3193d33291e49e2 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 9 Sep 2017 04:26:19 +0000 Subject: [PATCH 04/18] fix(package): update body-parser to version 1.18.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c2bad0d687..900307cb7b 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "animejs": "2.0.2", "autwh": "0.0.1", "bcryptjs": "2.4.3", - "body-parser": "1.17.2", + "body-parser": "1.18.0", "cafy": "2.4.0", "chalk": "2.1.0", "compression": "1.7.0", From dfa0dcd7a54833804635e24a816ba38bba89b171 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 10 Sep 2017 23:46:16 +0000 Subject: [PATCH 05/18] chore(package): update mocha to version 3.5.2 Closes #777 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 900307cb7b..78dc1ed04e 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "gulp-typescript": "3.2.2", "gulp-uglify": "3.0.0", "gulp-util": "3.0.8", - "mocha": "3.5.0", + "mocha": "3.5.2", "riot-tag-loader": "1.0.0", "string-replace-webpack-plugin": "0.1.3", "style-loader": "0.18.2", From 45382dac27f40ae769df8d3cab04c54d66d9b021 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 11 Sep 2017 08:24:10 +0000 Subject: [PATCH 06/18] fix(package): update js-yaml to version 3.10.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 900307cb7b..cdf69a9071 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "inquirer": "3.2.3", "is-root": "1.0.0", "is-url": "1.2.2", - "js-yaml": "3.9.1", + "js-yaml": "3.10.0", "mecab-async": "^0.1.0", "moji": "^0.5.1", "mongodb": "2.2.31", From d3d9b260ba1684f2820ab1ff079eda32f52d2479 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 11 Sep 2017 10:45:20 +0000 Subject: [PATCH 07/18] fix(package): update monk to version 6.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 900307cb7b..fc98a7245c 100644 --- a/package.json +++ b/package.json @@ -123,7 +123,7 @@ "mecab-async": "^0.1.0", "moji": "^0.5.1", "mongodb": "2.2.31", - "monk": "6.0.3", + "monk": "6.0.4", "morgan": "1.8.2", "ms": "2.0.0", "multer": "1.3.0", From ea98c8fce0c7595dc6af2e5ccde63945688d2430 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 11 Sep 2017 17:03:57 +0000 Subject: [PATCH 08/18] fix(package): update rimraf to version 2.6.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d346a2b87..2fb7da68dd 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "reconnecting-websocket": "3.2.1", "redis": "2.8.0", "request": "2.81.0", - "rimraf": "2.6.1", + "rimraf": "2.6.2", "riot": "3.7.0", "rndstr": "1.0.0", "s-age": "1.1.0", From 4ad141cfbaf21148d697786929da8718f4e85468 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 11 Sep 2017 22:19:29 +0000 Subject: [PATCH 09/18] chore(package): update mocha to version 3.5.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb7da68dd..258521ff0c 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "gulp-typescript": "3.2.2", "gulp-uglify": "3.0.0", "gulp-util": "3.0.8", - "mocha": "3.5.2", + "mocha": "3.5.3", "riot-tag-loader": "1.0.0", "string-replace-webpack-plugin": "0.1.3", "style-loader": "0.18.2", From 579d0bf4723064538d8d1b9eb043f471531fc1fc Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 12 Sep 2017 04:09:21 +0000 Subject: [PATCH 10/18] fix(package): update serve-favicon to version 2.4.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb7da68dd..e81832f47a 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "riot": "3.7.0", "rndstr": "1.0.0", "s-age": "1.1.0", - "serve-favicon": "2.4.3", + "serve-favicon": "2.4.4", "summaly": "2.0.3", "syuilo-password-strength": "0.0.1", "tcp-port-used": "0.1.2", From ceb446765d8524f15bccfe07f656a58ec6577d55 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 12 Sep 2017 16:10:28 +0000 Subject: [PATCH 11/18] fix(package): update body-parser to version 1.18.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb7da68dd..f3e85788c9 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "animejs": "2.0.2", "autwh": "0.0.1", "bcryptjs": "2.4.3", - "body-parser": "1.18.0", + "body-parser": "1.18.1", "cafy": "2.4.0", "chalk": "2.1.0", "compression": "1.7.0", From dd1379e2316be64a957df7fba97f1a3aadaa1c8c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 13 Sep 2017 20:56:46 +0000 Subject: [PATCH 12/18] fix(package): update riot to version 3.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb7da68dd..a0f8f44308 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "redis": "2.8.0", "request": "2.81.0", "rimraf": "2.6.2", - "riot": "3.7.0", + "riot": "3.7.1", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.3", From 7462daa12691ddbc8f04704058f2d1210f0427ef Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 15 Sep 2017 09:15:33 +0000 Subject: [PATCH 13/18] chore(package): update webpack to version 3.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b1ab86d0df..76642c0b42 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "uglify-es": "3.0.27", "uglify-es-webpack-plugin": "0.10.0", "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony", - "webpack": "3.5.6" + "webpack": "3.6.0" }, "dependencies": { "accesses": "2.5.0", From 86858586cf0ff993735dc289836e896f14456982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Sat, 16 Sep 2017 10:19:07 +0900 Subject: [PATCH 14/18] fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76642c0b42..d72a10ee92 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "redis": "2.8.0", "request": "2.81.0", "rimraf": "2.6.2", - "riot": "3.7.1", + "riot": "3.7.0", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.4", From bbfac657fb95536f2e942fbd02343bb1185fc68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Sat, 16 Sep 2017 14:30:44 +0900 Subject: [PATCH 15/18] Refactoring --- src/api/authenticate.ts | 18 +++++++++++++----- src/api/streaming.ts | 22 ++++++++++------------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts index d4cc3fc41f..e044d4ae8b 100644 --- a/src/api/authenticate.ts +++ b/src/api/authenticate.ts @@ -1,6 +1,6 @@ import * as express from 'express'; import App from './models/app'; -import User from './models/user'; +import{ default as User, IUser } from './models/user'; import AccessToken from './models/access-token'; import isNativeToken from './common/is-native-token'; @@ -13,7 +13,7 @@ export interface IAuthContext { /** * Authenticated user */ - user: any; + user: IUser; /** * Weather if the request is via the User-Native Token or not @@ -25,11 +25,15 @@ export default (req: express.Request) => new Promise(async (resolv const token = req.body['i'] as string; if (token == null) { - return resolve({ app: null, user: null, isSecure: false }); + return resolve({ + app: null, + user: null, + isSecure: false + }); } if (isNativeToken(token)) { - const user = await User + const user: IUser = await User .findOne({ token: token }); if (user === null) { @@ -56,6 +60,10 @@ export default (req: express.Request) => new Promise(async (resolv const user = await User .findOne({ _id: accessToken.user_id }); - return resolve({ app: app, user: user, isSecure: false }); + return resolve({ + app: app, + user: user, + isSecure: false + }); } }); diff --git a/src/api/streaming.ts b/src/api/streaming.ts index c71132100c..db600013b9 100644 --- a/src/api/streaming.ts +++ b/src/api/streaming.ts @@ -2,7 +2,7 @@ import * as http from 'http'; import * as websocket from 'websocket'; import * as redis from 'redis'; import config from '../conf'; -import User from './models/user'; +import { default as User, IUser } from './models/user'; import AccessToken from './models/access-token'; import isNativeToken from './common/is-native-token'; @@ -26,7 +26,7 @@ module.exports = (server: http.Server) => { return; } - const user = await authenticate(connection, request.resourceURL.query.i); + const user = await authenticate(request.resourceURL.query.i); if (user == null) { connection.send('authentication-failed'); @@ -56,7 +56,11 @@ module.exports = (server: http.Server) => { }); }; -function authenticate(connection: websocket.connection, token: string): Promise { +/** + * 接続してきたユーザーを取得します + * @param token 送信されてきたトークン + */ +function authenticate(token: string): Promise { if (token == null) { return Promise.resolve(null); } @@ -64,8 +68,7 @@ function authenticate(connection: websocket.connection, token: string): Promise< return new Promise(async (resolve, reject) => { if (isNativeToken(token)) { // Fetch user - // SELECT _id - const user = await User + const user: IUser = await User .findOne({ token: token }); @@ -81,13 +84,8 @@ function authenticate(connection: websocket.connection, token: string): Promise< } // Fetch user - // SELECT _id - const user = await User - .findOne({ _id: accessToken.user_id }, { - fields: { - _id: true - } - }); + const user: IUser = await User + .findOne({ _id: accessToken.user_id }); resolve(user); } From b2e28869cc9410070b689517993f6cdbfd73e0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Sat, 16 Sep 2017 14:31:24 +0900 Subject: [PATCH 16/18] oops --- src/api/authenticate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts index e044d4ae8b..6de91c16e8 100644 --- a/src/api/authenticate.ts +++ b/src/api/authenticate.ts @@ -1,6 +1,6 @@ import * as express from 'express'; import App from './models/app'; -import{ default as User, IUser } from './models/user'; +import { default as User, IUser } from './models/user'; import AccessToken from './models/access-token'; import isNativeToken from './common/is-native-token'; From 0b3cee9057ec4c0e9e640c72103d9dd229f0bd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Sat, 16 Sep 2017 14:38:33 +0900 Subject: [PATCH 17/18] Refactor: Better English --- src/api/authenticate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts index 6de91c16e8..48de748e90 100644 --- a/src/api/authenticate.ts +++ b/src/api/authenticate.ts @@ -16,7 +16,7 @@ export interface IAuthContext { user: IUser; /** - * Weather if the request is via the User-Native Token or not + * Weather requested with a User-Native Token */ isSecure: boolean; } From 76c0f67def857cabfcc70c01be28318e3175de97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Sat, 16 Sep 2017 14:38:58 +0900 Subject: [PATCH 18/18] typo --- src/api/authenticate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts index 48de748e90..b289959ac1 100644 --- a/src/api/authenticate.ts +++ b/src/api/authenticate.ts @@ -16,7 +16,7 @@ export interface IAuthContext { user: IUser; /** - * Weather requested with a User-Native Token + * Whether requested with a User-Native Token */ isSecure: boolean; }