From cdee14faa262b284c6d10cb53d6bf4ccaf4da5db Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 21:49:00 +0000 Subject: [PATCH 001/364] chore(package): update @types/bcryptjs to version 2.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 141e95c88b..ff3f6c79fe 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "test": "gulp test" }, "devDependencies": { - "@types/bcryptjs": "2.4.0", + "@types/bcryptjs": "2.4.1", "@types/body-parser": "1.16.4", "@types/chai": "4.0.3", "@types/chai-http": "3.0.2", From a5cdce9e2969174a6dc7b7a7e7a5fb422ad84a39 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:07:14 +0000 Subject: [PATCH 002/364] chore(package): update @types/event-stream to version 3.3.32 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..2aba95b111 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", "@types/elasticsearch": "5.0.14", - "@types/event-stream": "3.3.31", + "@types/event-stream": "3.3.32", "@types/express": "4.0.36", "@types/gm": "1.17.32", "@types/gulp": "4.0.3", From 1842a4ce1103415aa026b80d173cc054a0002ccb Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:15:05 +0000 Subject: [PATCH 003/364] chore(package): update @types/express to version 4.0.37 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..5798983c36 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@types/deep-equal": "1.0.1", "@types/elasticsearch": "5.0.14", "@types/event-stream": "3.3.31", - "@types/express": "4.0.36", + "@types/express": "4.0.37", "@types/gm": "1.17.32", "@types/gulp": "4.0.3", "@types/gulp-htmlmin": "1.3.30", From ee06ab75ba50d0e9f61d0ba28d877d543e6ad635 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:22:31 +0000 Subject: [PATCH 004/364] chore(package): update @types/mocha to version 2.2.42 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..537f6d3c0e 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.41", + "@types/mocha": "2.2.42", "@types/mongodb": "2.2.10", "@types/monk": "1.0.5", "@types/morgan": "1.7.32", From d0c58df5f484142ec4343c2939cd542281a64d05 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:24:16 +0000 Subject: [PATCH 005/364] chore(package): update @types/monk to version 1.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..a49300834c 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@types/js-yaml": "3.9.0", "@types/mocha": "2.2.41", "@types/mongodb": "2.2.10", - "@types/monk": "1.0.5", + "@types/monk": "1.0.6", "@types/morgan": "1.7.32", "@types/ms": "0.7.29", "@types/multer": "1.3.2", From 147367b55b6774a4dda1fecee20fa93ffd06c0fb Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:25:29 +0000 Subject: [PATCH 006/364] chore(package): update @types/ms to version 0.7.30 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..bdcbe8743f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@types/mongodb": "2.2.10", "@types/monk": "1.0.5", "@types/morgan": "1.7.32", - "@types/ms": "0.7.29", + "@types/ms": "0.7.30", "@types/multer": "1.3.2", "@types/node": "8.0.24", "@types/ratelimiter": "2.1.28", From fe3d634d7fe2445b0cf57b2ed0696eaa1615f035 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:27:10 +0000 Subject: [PATCH 007/364] chore(package): update @types/request to version 2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..e9c0700ed0 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/node": "8.0.24", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", - "@types/request": "2.0.1", + "@types/request": "2.0.2", "@types/rimraf": "2.0.0", "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", From 73c85a52be7e06c087237761e887620e5f2f9221 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:28:23 +0000 Subject: [PATCH 008/364] chore(package): update @types/serve-favicon to version 2.2.29 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..639261cb99 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@types/request": "2.0.1", "@types/rimraf": "2.0.0", "@types/riot": "3.6.0", - "@types/serve-favicon": "2.2.28", + "@types/serve-favicon": "2.2.29", "@types/uuid": "3.4.0", "@types/webpack": "3.0.9", "@types/webpack-stream": "3.2.7", From 26e7dbcbed2c3c8b3b8c5f4f74d8b190aa1119a5 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 Aug 2017 23:28:43 +0000 Subject: [PATCH 009/364] chore(package): update @types/uuid to version 3.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 47006ae5dd..4ce09491d4 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@types/rimraf": "2.0.0", "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", - "@types/uuid": "3.4.0", + "@types/uuid": "3.4.1", "@types/webpack": "3.0.9", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", From e3427d93011af09d38ac78a76be118d5babe72f4 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 22 Aug 2017 08:48:33 +0000 Subject: [PATCH 010/364] chore(package): update gulp-typescript to version 3.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..1df56fb853 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "gulp-rename": "1.2.2", "gulp-replace": "0.6.1", "gulp-tslint": "8.1.2", - "gulp-typescript": "3.2.1", + "gulp-typescript": "3.2.2", "gulp-uglify": "3.0.0", "gulp-util": "3.0.8", "mocha": "3.5.0", From a5496e6458343d644329c7f9047b987ec085ce7f Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 22 Aug 2017 15:58:23 +0000 Subject: [PATCH 011/364] chore(package): update @types/webpack to version 3.0.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..13a46cb3a0 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", "@types/uuid": "3.4.1", - "@types/webpack": "3.0.9", + "@types/webpack": "3.0.10", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", "chai": "4.1.1", From 0fe36f8e462b1ea07617b53996b32e356c808867 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 23 Aug 2017 20:04:36 +0000 Subject: [PATCH 012/364] fix(package): update riot to version 3.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..4df4f05726 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "redis": "2.8.0", "request": "2.81.0", "rimraf": "2.6.1", - "riot": "3.6.2", + "riot": "3.6.3", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.3", From b83ec0eb7ac1953fa519997665edf88262995e2d Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 24 Aug 2017 17:42:01 +0000 Subject: [PATCH 013/364] chore(package): update @types/node to version 8.0.25 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..6f8be109fc 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.24", + "@types/node": "8.0.25", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.2", From 099f356f17bfda11f1220b2a084b22e4bc41c802 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 24 Aug 2017 17:51:42 +0000 Subject: [PATCH 014/364] chore(package): update @types/request to version 2.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..0e8fd18d0e 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/node": "8.0.24", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", - "@types/request": "2.0.2", + "@types/request": "2.0.3", "@types/rimraf": "2.0.0", "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", From cbac13e99e71ba1a2159e638d2e4d0e4781a5f78 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 24 Aug 2017 20:26:19 +0000 Subject: [PATCH 015/364] fix(package): update debug to version 3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..103b1708bf 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "cors": "2.8.4", "cropperjs": "1.0.0-rc.3", "crypto": "1.0.1", - "debug": "3.0.0", + "debug": "3.0.1", "deep-equal": "1.0.1", "deepcopy": "0.6.3", "diskusage": "^0.2.2", From 0f33e257e5fa9270470174aa674a68623f6a2dca Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 25 Aug 2017 07:11:44 +0000 Subject: [PATCH 016/364] fix(package): update reconnecting-websocket to version 3.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..00149d17fc 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "pug": "2.0.0-rc.3", "ratelimiter": "3.0.3", "recaptcha-promise": "0.1.3", - "reconnecting-websocket": "3.2.0", + "reconnecting-websocket": "3.2.1", "redis": "2.8.0", "request": "2.81.0", "rimraf": "2.6.1", From 6f294c91e8d1873d71e2a70391a06d122fc2aff9 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 25 Aug 2017 23:38:20 +0000 Subject: [PATCH 017/364] chore(package): update tslint to version 5.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 915a969f46..564b65615c 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "stylus": "0.54.5", "stylus-loader": "3.0.1", "swagger-jsdoc": "1.9.7", - "tslint": "5.6.0", + "tslint": "5.7.0", "uglify-es": "3.0.27", "uglify-es-webpack-plugin": "0.10.0", "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony", From 7172ccd72c2ef40d68a252d7ae5cf45ddc575116 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 27 Aug 2017 16:53:15 +0900 Subject: [PATCH 018/364] Use createIndex() instead of index() to avoid deprecation warnings --- src/api/models/access-token.ts | 4 ++-- src/api/models/app.ts | 6 +++--- src/api/models/drive-file.ts | 2 +- src/api/models/user.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/api/models/access-token.ts b/src/api/models/access-token.ts index 2a8a512ddc..9985be5013 100644 --- a/src/api/models/access-token.ts +++ b/src/api/models/access-token.ts @@ -2,7 +2,7 @@ import db from '../../db/mongodb'; const collection = db.get('access_tokens'); -(collection as any).index('token'); // fuck type definition -(collection as any).index('hash'); // fuck type definition +(collection as any).createIndex('token'); // fuck type definition +(collection as any).createIndex('hash'); // fuck type definition export default collection as any; // fuck type definition diff --git a/src/api/models/app.ts b/src/api/models/app.ts index bf5dc80c2c..68f2f448b0 100644 --- a/src/api/models/app.ts +++ b/src/api/models/app.ts @@ -2,9 +2,9 @@ import db from '../../db/mongodb'; const collection = db.get('apps'); -(collection as any).index('name_id'); // fuck type definition -(collection as any).index('name_id_lower'); // fuck type definition -(collection as any).index('secret'); // fuck type definition +(collection as any).createIndex('name_id'); // fuck type definition +(collection as any).createIndex('name_id_lower'); // fuck type definition +(collection as any).createIndex('secret'); // fuck type definition export default collection as any; // fuck type definition diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts index 4c7204b1f4..8d158cf563 100644 --- a/src/api/models/drive-file.ts +++ b/src/api/models/drive-file.ts @@ -2,7 +2,7 @@ import db from '../../db/mongodb'; const collection = db.get('drive_files'); -(collection as any).index('hash'); // fuck type definition +(collection as any).createIndex('hash'); // fuck type definition export default collection as any; // fuck type definition diff --git a/src/api/models/user.ts b/src/api/models/user.ts index cd16459891..9f8cf0161d 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -2,8 +2,8 @@ import db from '../../db/mongodb'; const collection = db.get('users'); -(collection as any).index('username'); // fuck type definition -(collection as any).index('token'); // fuck type definition +(collection as any).createIndex('username'); // fuck type definition +(collection as any).createIndex('token'); // fuck type definition export default collection as any; // fuck type definition From 1b9ed129a91056ae36b31fcacde39c2fb2c039d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 27 Aug 2017 16:53:52 +0900 Subject: [PATCH 019/364] [Test] Clean up --- test/api.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/api.js b/test/api.js index 9e1d4ff61b..1e731b5549 100644 --- a/test/api.js +++ b/test/api.js @@ -53,8 +53,6 @@ describe('API', () => { db.get('auth_sessions').drop() ])); - afterEach(cb => setTimeout(cb, 100)); - it('greet server', done => { _chai.request(server) .get('/') From 49e1cea200d5cde1b7ad4c6f21017c4d80ec80ff Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 27 Aug 2017 16:59:11 +0900 Subject: [PATCH 020/364] [CI] Update the node.js version to 8.4.0 --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91e1244432..76de4930d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: node_js node_js: - - 7.10.0 + - 8.4.0 env: - CXX=g++-4.8 NODE_ENV=production diff --git a/appveyor.yml b/appveyor.yml index d26cbc27e8..a4aa652cec 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ environment: matrix: - - nodejs_version: 7.10.0 + - nodejs_version: 8.4.0 build: off From 3b77bc8299eee89a7945438863953a5cdd08e934 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 Aug 2017 00:03:57 +0900 Subject: [PATCH 021/364] Implement #734 --- CHANGELOG.md | 4 + locales/en.yml | 4 + locales/ja.yml | 4 + src/api/serializers/post.ts | 93 ++++++++++++++++-------- src/web/app/desktop/tags/pages/post.tag | 34 +++++++-- src/web/app/desktop/tags/post-detail.tag | 76 +++++++------------ 6 files changed, 132 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a584ddb0..95d21ac05f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog ========= 主に notable な changes を書いていきます +unreleased +---------- +* 投稿ページに次の投稿/前の投稿リンクを作成 (#734) + 2380 ---- アプリケーションが作れない問題を修正 diff --git a/locales/en.yml b/locales/en.yml index 55a588f99f..9bf6446641 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -231,6 +231,10 @@ desktop: attaches: "{} media attached" uploading-media: "Uploading {} media" + mk-post-page: + prev: "Previous post" + next: "Next post" + mk-timeline-post: reposted-by: "Reposted by {}" reply: "Reply" diff --git a/locales/ja.yml b/locales/ja.yml index e5b2beaed1..d2b282bff6 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -231,6 +231,10 @@ desktop: attaches: "添付: {}メディア" uploading-media: "{}個のメディアをアップロード中" + mk-post-page: + prev: "前の投稿" + next: "次の投稿" + mk-timeline-post: reposted-by: "{}がRepost" reply: "返信" diff --git a/src/api/serializers/post.ts b/src/api/serializers/post.ts index 3c96884dd1..13773bda9e 100644 --- a/src/api/serializers/post.ts +++ b/src/api/serializers/post.ts @@ -73,44 +73,79 @@ const self = ( )); } - if (_post.reply_to_id && opts.detail) { - // Populate reply to post - _post.reply_to = await self(_post.reply_to_id, me, { - detail: false + // When requested a detailed post data + if (opts.detail) { + // Get previous post info + const prev = await Post.findOne({ + user_id: _post.user_id, + _id: { + $lt: id + } + }, { + fields: { + _id: true + }, + sort: { + _id: -1 + } }); - } + _post.prev = prev ? prev._id : null; - if (_post.repost_id && opts.detail) { - // Populate repost - _post.repost = await self(_post.repost_id, me, { - detail: _post.text == null + // Get next post info + const next = await Post.findOne({ + user_id: _post.user_id, + _id: { + $gt: id + } + }, { + fields: { + _id: true + }, + sort: { + _id: 1 + } }); - } + _post.next = next ? next._id : null; - // Poll - if (me && _post.poll && opts.detail) { - const vote = await Vote - .findOne({ - user_id: me._id, - post_id: id + if (_post.reply_to_id) { + // Populate reply to post + _post.reply_to = await self(_post.reply_to_id, me, { + detail: false }); - - if (vote != null) { - _post.poll.choices.filter(c => c.id == vote.choice)[0].is_voted = true; } - } - // Fetch my reaction - if (me && opts.detail) { - const reaction = await Reaction - .findOne({ - user_id: me._id, - post_id: id, - deleted_at: { $exists: false } + if (_post.repost_id) { + // Populate repost + _post.repost = await self(_post.repost_id, me, { + detail: _post.text == null }); + } - if (reaction) { - _post.my_reaction = reaction.reaction; + // Poll + if (me && _post.poll) { + const vote = await Vote + .findOne({ + user_id: me._id, + post_id: id + }); + + if (vote != null) { + _post.poll.choices.filter(c => c.id == vote.choice)[0].is_voted = true; + } + } + + // Fetch my reaction + if (me) { + const reaction = await Reaction + .findOne({ + user_id: me._id, + post_id: id, + deleted_at: { $exists: false } + }); + + if (reaction) { + _post.my_reaction = reaction.reaction; + } } } diff --git a/src/web/app/desktop/tags/pages/post.tag b/src/web/app/desktop/tags/pages/post.tag index c91e98bbd4..f270b43ac2 100644 --- a/src/web/app/desktop/tags/pages/post.tag +++ b/src/web/app/desktop/tags/pages/post.tag @@ -1,7 +1,9 @@ -
+
+ %i18n:desktop.tags.mk-post-page.next% + %i18n:desktop.tags.mk-post-page.prev%
+ + diff --git a/src/web/app/desktop/tags/index.js b/src/web/app/desktop/tags/index.js index 177ba41293..11243c00a0 100644 --- a/src/web/app/desktop/tags/index.js +++ b/src/web/app/desktop/tags/index.js @@ -91,3 +91,4 @@ require('./user-following-window.tag'); require('./user-followers-window.tag'); require('./list-user.tag'); require('./ui-notification.tag'); +require('./detailed-post-window.tag'); diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag index 150b928dfd..0438b146ca 100644 --- a/src/web/app/desktop/tags/timeline-post.tag +++ b/src/web/app/desktop/tags/timeline-post.tag @@ -1,4 +1,4 @@ - +
@@ -473,6 +473,12 @@ if (shouldBeCancel) e.preventDefault(); }; + this.onDblClick = () => { + riot.mount(document.body.appendChild(document.createElement('mk-detailed-post-window')), { + post: this.p.id + }); + }; + function focus(el, fn) { const target = fn(el); if (target) { From 9f1e63a1908a603b75a31fe7b6a4a83c82e8e2a7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 Aug 2017 10:19:27 +0900 Subject: [PATCH 025/364] [CI] Except the release branch --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 76de4930d0..ed53af9e20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ # travis file # https://docs.travis-ci.com/user/customizing-the-build +branches: + except: + - release + language: node_js node_js: From ac26397777bd318045069ee8880210a2727e9c28 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: Mon, 28 Aug 2017 11:14:25 +0900 Subject: [PATCH 026/364] Re: [CI] Except the release branch --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index a4aa652cec..03a42b9b44 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,10 @@ # appveyor file # http://www.appveyor.com/docs/appveyor-yml +branches: + except: + - release + environment: matrix: - nodejs_version: 8.4.0 From 09e443aeb308912b26fb3c228948a3d7a91827d0 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: Mon, 28 Aug 2017 11:41:51 +0900 Subject: [PATCH 027/364] Re: Re: [CI] Except the release branch --- .travis/.gitignore-release | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis/.gitignore-release b/.travis/.gitignore-release index ad1d3724fc..ae1157b33e 100644 --- a/.travis/.gitignore-release +++ b/.travis/.gitignore-release @@ -6,3 +6,5 @@ !/tools !/elasticsearch !/package.json +!/.travis.yml +!/appveyor.yml From 29ed58e4b349e30e4c389cae1050e1a689a7d466 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 Aug 2017 19:43:24 +0900 Subject: [PATCH 028/364] #163 --- CHANGELOG.md | 1 + locales/en.yml | 16 +++ locales/ja.yml | 16 +++ src/web/app/mobile/router.js | 6 + src/web/app/mobile/tags/index.js | 1 + src/web/app/mobile/tags/page/settings.tag | 74 ++++++++++-- .../app/mobile/tags/page/settings/profile.tag | 106 ++++++++++++++++++ 7 files changed, 213 insertions(+), 7 deletions(-) create mode 100644 src/web/app/mobile/tags/page/settings/profile.tag diff --git a/CHANGELOG.md b/CHANGELOG.md index d850457df3..fb41a5ab7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ChangeLog unreleased ---------- +* New: モバイル版からプロフィールを設定できるように * Improve: 投稿ページに次の投稿/前の投稿リンクを作成 (#734) * Improve: タイムラインの投稿をダブルクリックすることで詳細な情報が見れるように * Fix: モバイル版でおすすめユーザーをフォローしてもタイムラインが更新されない (#736) diff --git a/locales/en.yml b/locales/en.yml index 9bf6446641..6d636a1108 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -336,12 +336,28 @@ mobile: mk-search-page: search: "Search" + mk-settings: + signed-in-as: "Signed in as {}" + mk-settings-page: profile: "Profile" applications: "Applications" twitter-integration: "Twitter integration" signin-history: "Sign in history" + api: "API" settings: "Settings" + signout: "Sign out" + + mk-profile-setting-page: + title: "Profile Settings" + + mk-profile-setting: + name: "Name" + location: "Location" + description: "Description" + birthday: "Birthday" + save: "Save" + saved: "Profile updated successfully" mk-user-followers-page: followers-of: "Followers of {}" diff --git a/locales/ja.yml b/locales/ja.yml index d2b282bff6..75b1fd6275 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -336,12 +336,28 @@ mobile: mk-search-page: search: "検索" + mk-settings: + signed-in-as: "{}としてサインイン中" + mk-settings-page: profile: "プロフィール" applications: "アプリケーション" twitter-integration: "Twitter連携" signin-history: "ログイン履歴" + api: "API" settings: "設定" + signout: "サインアウト" + + mk-profile-setting-page: + title: "プロフィール設定" + + mk-profile-setting: + name: "名前" + location: "場所" + description: "自己紹介" + birthday: "誕生日" + save: "保存" + saved: "プロフィールを保存しました" mk-user-followers-page: followers-of: "{}のフォロワー" diff --git a/src/web/app/mobile/router.js b/src/web/app/mobile/router.js index d0b45d9614..de4108a593 100644 --- a/src/web/app/mobile/router.js +++ b/src/web/app/mobile/router.js @@ -15,6 +15,7 @@ export default me => { route('/i/drive/folder/:folder', drive); route('/i/drive/file/:file', drive); route('/i/settings', settings); + route('/i/settings/profile', settingsProfile); route('/i/settings/signin-history', settingsSignin); route('/i/settings/api', settingsApi); route('/i/settings/twitter', settingsTwitter); @@ -63,6 +64,10 @@ export default me => { mount(document.createElement('mk-settings-page')); } + function settingsProfile() { + mount(document.createElement('mk-profile-setting-page')); + } + function settingsSignin() { mount(document.createElement('mk-signin-history-page')); } @@ -130,6 +135,7 @@ export default me => { }; function mount(content) { + document.documentElement.style.background = '#fff'; if (page) page.unmount(); const body = document.getElementById('app'); page = riot.mount(body.appendChild(content))[0]; diff --git a/src/web/app/mobile/tags/index.js b/src/web/app/mobile/tags/index.js index 02d1541fcd..2e6b478079 100644 --- a/src/web/app/mobile/tags/index.js +++ b/src/web/app/mobile/tags/index.js @@ -14,6 +14,7 @@ require('./page/post.tag'); require('./page/new-post.tag'); require('./page/search.tag'); require('./page/settings.tag'); +require('./page/settings/profile.tag'); require('./page/settings/signin.tag'); require('./page/settings/api.tag'); require('./page/settings/authorized-apps.tag'); diff --git a/src/web/app/mobile/tags/page/settings.tag b/src/web/app/mobile/tags/page/settings.tag index 58094a876a..710591071d 100644 --- a/src/web/app/mobile/tags/page/settings.tag +++ b/src/web/app/mobile/tags/page/settings.tag @@ -1,12 +1,6 @@ - + + + diff --git a/src/web/app/mobile/tags/page/settings/profile.tag b/src/web/app/mobile/tags/page/settings/profile.tag new file mode 100644 index 0000000000..dfe0586c1c --- /dev/null +++ b/src/web/app/mobile/tags/page/settings/profile.tag @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + From 93c8374021dc40806a300820563b8d920252a2fa Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 Aug 2017 19:43:34 +0900 Subject: [PATCH 029/364] :art: --- src/web/app/reset.styl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/web/app/reset.styl b/src/web/app/reset.styl index 940a9ed18e..85bbd11473 100644 --- a/src/web/app/reset.styl +++ b/src/web/app/reset.styl @@ -14,6 +14,7 @@ body input:not([type]) input[type='text'] input[type='password'] +input[type='search'] input[type='email'] textarea button From fda0c9c00113eb1c8a1591e8d1be7f4dc2edaf4a Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 Aug 2017 19:43:47 +0900 Subject: [PATCH 030/364] Fix bug --- src/web/app/mobile/tags/page/settings/api.tag | 2 +- src/web/app/mobile/tags/page/settings/authorized-apps.tag | 2 +- src/web/app/mobile/tags/page/settings/signin.tag | 2 +- src/web/app/mobile/tags/page/settings/twitter.tag | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/web/app/mobile/tags/page/settings/api.tag b/src/web/app/mobile/tags/page/settings/api.tag index cfffeacb5a..46419eb3db 100644 --- a/src/web/app/mobile/tags/page/settings/api.tag +++ b/src/web/app/mobile/tags/page/settings/api.tag @@ -7,7 +7,7 @@ display block - diff --git a/src/web/app/common/tags/index.js b/src/web/app/common/tags/index.js index 5dc4ef4546..1ee8dab42d 100644 --- a/src/web/app/common/tags/index.js +++ b/src/web/app/common/tags/index.js @@ -14,7 +14,6 @@ require('./forkit.tag'); require('./introduction.tag'); require('./copyright.tag'); require('./signin-history.tag'); -require('./api-info.tag'); require('./twitter-setting.tag'); require('./authorized-apps.tag'); require('./poll.tag'); diff --git a/src/web/app/desktop/scripts/password-dialog.js b/src/web/app/desktop/scripts/password-dialog.js new file mode 100644 index 0000000000..2bdc93e421 --- /dev/null +++ b/src/web/app/desktop/scripts/password-dialog.js @@ -0,0 +1,11 @@ +import * as riot from 'riot'; + +export default (title, onOk, onCancel) => { + const dialog = document.body.appendChild(document.createElement('mk-input-dialog')); + return riot.mount(dialog, { + title: title, + type: 'password', + onOk: onOk, + onCancel: onCancel + }); +}; diff --git a/src/web/app/desktop/tags/input-dialog.tag b/src/web/app/desktop/tags/input-dialog.tag index f343c4625a..78fd62ee8b 100644 --- a/src/web/app/desktop/tags/input-dialog.tag +++ b/src/web/app/desktop/tags/input-dialog.tag @@ -5,7 +5,7 @@
- +
@@ -126,6 +126,7 @@ this.placeholder = this.opts.placeholder; this.default = this.opts.default; this.allowEmpty = this.opts.allowEmpty != null ? this.opts.allowEmpty : true; + this.type = this.opts.type ? this.opts.type : 'text'; this.on('mount', () => { this.text = this.refs.window.refs.text; @@ -156,6 +157,10 @@ this.refs.window.close(); }; + this.onInput = () => { + this.update(); + }; + this.onKeydown = e => { if (e.which == 13) { // Enter e.preventDefault(); diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index a89cfda0e4..7fc6acb4a8 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -211,3 +211,33 @@ }; + + +

Token:{ I.token }

+

APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。

+

アカウントを乗っ取られてしまう可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。

+

万が一このトークンが漏れたりその可能性がある場合はトークンを再生成できます。(副作用として、ログインしているすべてのデバイスでログアウトが発生します)

+ + +
diff --git a/src/web/app/mobile/tags/page/settings/api.tag b/src/web/app/mobile/tags/page/settings/api.tag index 46419eb3db..25413e2d80 100644 --- a/src/web/app/mobile/tags/page/settings/api.tag +++ b/src/web/app/mobile/tags/page/settings/api.tag @@ -15,3 +15,22 @@ }); + + +

Token:{ I.token }

+

APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。

+

アカウントを乗っ取られてしまう可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。

+

万が一このトークンが漏れたりその可能性がある場合はデスクトップ版Misskeyから再生成できます。

+ + +
From cdcd8e5c40197c807c69aea19899bc556c8b783b 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: Mon, 28 Aug 2017 23:49:14 +0900 Subject: [PATCH 043/364] Update regenerate_token.ts --- src/api/endpoints/i/regenerate_token.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/endpoints/i/regenerate_token.ts b/src/api/endpoints/i/regenerate_token.ts index ccebbc8101..f96d10ebfc 100644 --- a/src/api/endpoints/i/regenerate_token.ts +++ b/src/api/endpoints/i/regenerate_token.ts @@ -37,6 +37,6 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { res(); - // Publish i updated event + // Publish event event(user._id, 'my_token_regenerated'); }); From 8f0e6a70cf22f1248b99bd3b300feed8b1b1efc8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 00:20:47 +0900 Subject: [PATCH 044/364] #364 --- CHANGELOG.md | 1 + locales/en.yml | 9 ++++++ locales/ja.yml | 9 ++++++ src/api/endpoints.ts | 4 +++ src/api/endpoints/i/change_password.ts | 42 ++++++++++++++++++++++++++ src/web/app/desktop/tags/settings.tag | 38 +++++++++++++++++++++-- 6 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/api/endpoints/i/change_password.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d18b1b7f6..4e49f9ca49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog unlereased ---------- * New: トークンを再生成できるように (#497) +* New: パスワードを変更する機能 (#364) 2461 (2017/08/28) ----------------- diff --git a/locales/en.yml b/locales/en.yml index 950180278d..a24b8725ae 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -208,6 +208,12 @@ desktop: settings: "Settings" signout: "Sign out" + mk-password-setting: + reset: "Change your password" + enter-current-password: "Enter the current password" + enter-new-password: "Enter the new password" + changed: "Password updated successfully" + mk-post-form: post-placeholder: "What's happening?" reply-placeholder: "Reply to this post..." @@ -239,6 +245,9 @@ desktop: prev: "Previous post" next: "Next post" + mk-settings: + password: "Password" + mk-timeline-post: reposted-by: "Reposted by {}" reply: "Reply" diff --git a/locales/ja.yml b/locales/ja.yml index 2655eb4846..88e0b76d82 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -208,6 +208,12 @@ desktop: settings: "設定" signout: "サインアウト" + mk-password-setting: + reset: "パスワードを変更する" + enter-current-password: "現在のパスワードを入力してください" + enter-new-password: "新しいパスワードを入力してください" + changed: "パスワードを変更しました" + mk-post-form: post-placeholder: "いまどうしてる?" reply-placeholder: "この投稿への返信..." @@ -239,6 +245,9 @@ desktop: prev: "前の投稿" next: "次の投稿" + mk-settings: + password: "パスワード" + mk-timeline-post: reposted-by: "{}がRepost" reply: "返信" diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index a658c9a42e..c6661533e8 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -159,6 +159,10 @@ const endpoints: Endpoint[] = [ }, kind: 'account-write' }, + { + name: 'i/change_password', + withCredential: true + }, { name: 'i/regenerate_token', withCredential: true diff --git a/src/api/endpoints/i/change_password.ts b/src/api/endpoints/i/change_password.ts new file mode 100644 index 0000000000..faceded29d --- /dev/null +++ b/src/api/endpoints/i/change_password.ts @@ -0,0 +1,42 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import * as bcrypt from 'bcryptjs'; +import User from '../../models/user'; + +/** + * Change password + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = async (params, user) => new Promise(async (res, rej) => { + // Get 'current_password' parameter + const [currentPassword, currentPasswordErr] = $(params.current_password).string().$; + if (currentPasswordErr) return rej('invalid current_password param'); + + // Get 'new_password' parameter + const [newPassword, newPasswordErr] = $(params.new_password).string().$; + if (newPasswordErr) return rej('invalid new_password param'); + + // Compare password + const same = bcrypt.compareSync(currentPassword, user.password); + + if (!same) { + return rej('incorrect password'); + } + + // Generate hash of password + const salt = bcrypt.genSaltSync(8); + const hash = bcrypt.hashSync(newPassword, salt); + + await User.update(user._id, { + $set: { + password: hash + } + }); + + res(); +}); diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index 7fc6acb4a8..80a42d6652 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -7,7 +7,7 @@

アプリ

Twitter

ログイン履歴

-

パスワード

+

%i18n:desktop.tags.mk-settings.password%

API

@@ -58,6 +58,11 @@ +
+

%i18n:desktop.tags.mk-settings.password%

+ +
+

API

@@ -236,8 +241,37 @@ passwordDialog('%i18n:desktop.tags.mk-api-info.regenerate-token%', password => { this.api('i/regenerate_token', { password: password - }) + }); }); }; + + + + + + From 79ab7560400085fcf428d1f8010772e46e03d6e5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 00:23:12 +0900 Subject: [PATCH 045/364] v2470 --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e49f9ca49..dc0442ba01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ChangeLog ========= 主に notable な changes を書いていきます -unlereased ----------- +2470 (2017/08/29) +----------------- * New: トークンを再生成できるように (#497) * New: パスワードを変更する機能 (#364) diff --git a/package.json b/package.json index beea91ecc5..fab513e253 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2461", + "version": "0.0.2470", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From b577f076be3e0eebac398c5f82d41b05f256768c 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: Tue, 29 Aug 2017 00:28:59 +0900 Subject: [PATCH 046/364] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22451385ce..3020977bfc 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Sponsors & Backers Misskey have no 100+ GitHub stars currently. However, donation are always welcome! If you want to donate to Misskey, please get in touch with [@syuilo][syuilo-link]. -Note: When you donate to Misskey, your name will be displayed in [donors](./DONORS.md). +**Note:** When you donate to Misskey, your name will be displayed in [donors](./DONORS.md). Collaborators ---------------------------------------------------------------- From afc6e07c3f925081d1e0d459f6b4cee210fa77ec 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: Tue, 29 Aug 2017 00:41:30 +0900 Subject: [PATCH 047/364] Update DONORS.md --- DONORS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DONORS.md b/DONORS.md index 9bb85938d5..dc000de26d 100644 --- a/DONORS.md +++ b/DONORS.md @@ -4,3 +4,7 @@ DONORS (no particular order) * スルメ https://surume.tk/ + +--- + +:heart: Thanks for donating, guys! From b5436d780cbb20a5035668e24e87a2d6f36ff1bd 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: Tue, 29 Aug 2017 00:47:20 +0900 Subject: [PATCH 048/364] Update DONORS.md --- DONORS.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DONORS.md b/DONORS.md index dc000de26d..d022c4ef64 100644 --- a/DONORS.md +++ b/DONORS.md @@ -5,6 +5,12 @@ DONORS * スルメ https://surume.tk/ +:heart: Thanks for donating, guys! + --- -:heart: Thanks for donating, guys! +You donated, but you are not listed here? please contact to us! + +If you want to donate to Misskey, please get in touch with [@syuilo][syuilo-link]. + +[syuilo-link]: https://syuilo.com From 01693c8c1607c45ae6367ede10f73e33ac64ef92 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 28 Aug 2017 15:53:51 +0000 Subject: [PATCH 049/364] chore(package): update @types/mongodb to version 2.2.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fab513e253..3fade49978 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@types/is-url": "1.2.28", "@types/js-yaml": "3.9.0", "@types/mocha": "2.2.42", - "@types/mongodb": "2.2.10", + "@types/mongodb": "2.2.11", "@types/monk": "1.0.6", "@types/morgan": "1.7.32", "@types/ms": "0.7.30", From 15d08564c8cb553e48677daee20648d076323424 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 02:46:28 +0900 Subject: [PATCH 050/364] #739 --- CHANGELOG.md | 4 ++++ locales/en.yml | 2 ++ locales/ja.yml | 2 ++ src/web/app/desktop/tags/dialog.tag | 3 +++ src/web/app/desktop/tags/settings.tag | 19 ++++++++++++++----- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0442ba01..8a310513bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog ========= 主に notable な changes を書いていきます +unreleased +---------- +* New: パスワードを変更する際に新しいパスワードを二度入力させる (#739) + 2470 (2017/08/29) ----------------- * New: トークンを再生成できるように (#497) diff --git a/locales/en.yml b/locales/en.yml index a24b8725ae..439b7ef069 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -212,6 +212,8 @@ desktop: reset: "Change your password" enter-current-password: "Enter the current password" enter-new-password: "Enter the new password" + enter-new-password-again: "Enter the new password again" + not-match: "New password not matched" changed: "Password updated successfully" mk-post-form: diff --git a/locales/ja.yml b/locales/ja.yml index 88e0b76d82..258e192394 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -212,6 +212,8 @@ desktop: reset: "パスワードを変更する" enter-current-password: "現在のパスワードを入力してください" enter-new-password: "新しいパスワードを入力してください" + enter-new-password-again: "もう一度新しいパスワードを入力してください" + not-match: "新しいパスワードが一致しません" changed: "パスワードを変更しました" mk-post-form: diff --git a/src/web/app/desktop/tags/dialog.tag b/src/web/app/desktop/tags/dialog.tag index 9905123eeb..743fd63942 100644 --- a/src/web/app/desktop/tags/dialog.tag +++ b/src/web/app/desktop/tags/dialog.tag @@ -44,6 +44,9 @@ // color #43A4EC font-weight bold + &:empty + display none + > i margin-right 0.5em diff --git a/src/web/app/desktop/tags/settings.tag b/src/web/app/desktop/tags/settings.tag index 80a42d6652..eabddfb432 100644 --- a/src/web/app/desktop/tags/settings.tag +++ b/src/web/app/desktop/tags/settings.tag @@ -256,6 +256,7 @@ @@ -37,19 +37,36 @@ display block margin 24px text-align center - color #555 + color #cad2da > ul + $radius = 8px + display block - margin 16px 0 + margin 16px auto padding 0 + max-width 500px + width calc(100% - 32px) list-style none - border-top solid 1px #aaa + background #fff + border solid 1px rgba(0, 0, 0, 0.2) + border-radius $radius > li display block - background #fff - border-bottom solid 1px #aaa + border-bottom solid 1px #ddd + + &:hover + background rgba(0, 0, 0, 0.1) + + &:first-child + border-top-left-radius $radius + border-top-right-radius $radius + + &:last-child + border-bottom-left-radius $radius + border-bottom-right-radius $radius + border-bottom none > a $height = 48px diff --git a/src/web/app/mobile/tags/page/settings/profile.tag b/src/web/app/mobile/tags/page/settings/profile.tag index de365c235e..fb78d2f719 100644 --- a/src/web/app/mobile/tags/page/settings/profile.tag +++ b/src/web/app/mobile/tags/page/settings/profile.tag @@ -12,80 +12,135 @@ this.on('mount', () => { document.title = 'Misskey | %i18n:mobile.tags.mk-profile-setting-page.title%'; ui.trigger('title', '%i18n:mobile.tags.mk-profile-setting-page.title%'); - document.documentElement.style.background = '#eee'; + document.documentElement.style.background = '#313a42'; }); - - - - - - - +
+

%i18n:mobile.tags.mk-profile-setting.will-be-published%

+
+ + + + + + +
+ +
+ + + + + + diff --git a/src/web/app/mobile/tags/post-form.tag b/src/web/app/mobile/tags/post-form.tag index 28c7796840..cf267de94a 100644 --- a/src/web/app/mobile/tags/post-form.tag +++ b/src/web/app/mobile/tags/post-form.tag @@ -1,11 +1,9 @@
+
- -
- { 1000 - refs.text.value.length } - -
+ { 1000 - refs.text.value.length } +
@@ -30,46 +28,47 @@ - diff --git a/src/web/app/mobile/tags/timeline-post.tag b/src/web/app/mobile/tags/timeline-post.tag deleted file mode 100644 index 2395e9fb79..0000000000 --- a/src/web/app/mobile/tags/timeline-post.tag +++ /dev/null @@ -1,414 +0,0 @@ - -
- -
-
-

- - avatar - - {'%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('{'))}{ post.user.name }{'%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr('%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1)} -

- -
-
- - avatar - -
-
- { p.user.name } - bot - @{ p.user.username } - - - -
-
-
- - - -

- RP: -
-
- -
- - via { p.app.name } -
- -
-
-
- - - - -
-
-
- - -
diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index 9e39cf80d7..6895384a56 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -144,3 +144,520 @@ }; + + +
+ +
+
+

+ + avatar + + {'%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('{'))}{ post.user.name }{'%i18n:mobile.tags.mk-timeline-post.reposted-by%'.substr('%i18n:mobile.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1)} +

+ +
+
+ + avatar + +
+
+ { p.user.name } + bot + @{ p.user.username } + + + +
+
+
+ + + +

+ RP: +
+
+ +
+ + via { p.app.name } +
+ +
+
+
+ + + + +
+
+
+ + +
+ + + + + + From 0da4de955a90735089d44b04b4aaf47f3e45f522 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 22:07:51 +0900 Subject: [PATCH 068/364] Refactor --- src/web/app/desktop/tags/index.js | 2 - .../app/desktop/tags/timeline-post-sub.tag | 107 ---- src/web/app/desktop/tags/timeline-post.tag | 493 -------------- src/web/app/desktop/tags/timeline.tag | 602 ++++++++++++++++++ 4 files changed, 602 insertions(+), 602 deletions(-) delete mode 100644 src/web/app/desktop/tags/timeline-post-sub.tag delete mode 100644 src/web/app/desktop/tags/timeline-post.tag diff --git a/src/web/app/desktop/tags/index.js b/src/web/app/desktop/tags/index.js index 11243c00a0..98bfc68804 100644 --- a/src/web/app/desktop/tags/index.js +++ b/src/web/app/desktop/tags/index.js @@ -26,7 +26,6 @@ require('./ui-header-search.tag'); require('./notifications.tag'); require('./post-form-window.tag'); require('./post-form.tag'); -require('./timeline-post.tag'); require('./post-preview.tag'); require('./repost-form-window.tag'); require('./home-widgets/user-recommendation.tag'); @@ -79,7 +78,6 @@ require('./search-posts.tag'); require('./set-avatar-suggestion.tag'); require('./set-banner-suggestion.tag'); require('./repost-form.tag'); -require('./timeline-post-sub.tag'); require('./sub-post-content.tag'); require('./images-viewer.tag'); require('./image-dialog.tag'); diff --git a/src/web/app/desktop/tags/timeline-post-sub.tag b/src/web/app/desktop/tags/timeline-post-sub.tag deleted file mode 100644 index ab1e26721b..0000000000 --- a/src/web/app/desktop/tags/timeline-post-sub.tag +++ /dev/null @@ -1,107 +0,0 @@ - - - - - diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag deleted file mode 100644 index 0438b146ca..0000000000 --- a/src/web/app/desktop/tags/timeline-post.tag +++ /dev/null @@ -1,493 +0,0 @@ - -
- -
-
-

- - avatar - - {'%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('{'))}{ post.user.name }{'%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr('%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1)} -

- -
-
- - avatar - -
-
- { p.user.name } - bot - @{ p.user.username } -
- via { p.app.name } - - - -
-
-
-
- - - -

- RP: -
-
- -
- -
- -
-
-
- - - - - - -
-
-
-
- -
- - -
diff --git a/src/web/app/desktop/tags/timeline.tag b/src/web/app/desktop/tags/timeline.tag index d4cd50455c..91bf7a637a 100644 --- a/src/web/app/desktop/tags/timeline.tag +++ b/src/web/app/desktop/tags/timeline.tag @@ -90,3 +90,605 @@ + + +
+ +
+
+

+ + avatar + + {'%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr(0, '%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('{'))}{ post.user.name }{'%i18n:desktop.tags.mk-timeline-post.reposted-by%'.substr('%i18n:desktop.tags.mk-timeline-post.reposted-by%'.indexOf('}') + 1)} +

+ +
+
+ + avatar + +
+
+ { p.user.name } + bot + @{ p.user.username } +
+ via { p.app.name } + + + +
+
+
+
+ + + +

+ RP: +
+
+ +
+ +
+ +
+
+
+ + + + + + +
+
+
+
+ +
+ + +
+ + + + + + From f6b132a1f50e44df9c66cfce1a7ac6b2a1193118 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 22:13:32 +0900 Subject: [PATCH 069/364] Fix #743 --- CHANGELOG.md | 1 + src/web/app/desktop/tags/timeline.tag | 22 ++++++++++++---------- src/web/app/mobile/tags/timeline.tag | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30ff40a624..06d88d08c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ChangeLog (Release Notes) unreleased ---------- +* Fix: repostのborder-radiusが効いていない (#743) * ユーザビリティの向上 2493-2 (2017/08/29) diff --git a/src/web/app/desktop/tags/timeline.tag b/src/web/app/desktop/tags/timeline.tag index 91bf7a637a..bce27cd7f3 100644 --- a/src/web/app/desktop/tags/timeline.tag +++ b/src/web/app/desktop/tags/timeline.tag @@ -10,16 +10,6 @@ :scope display block - > mk-timeline-post - border-bottom solid 1px #eaeaea - - &:first-child - border-top-left-radius 6px - border-top-right-radius 6px - - &:last-of-type - border-bottom none - > .date display block margin 0 @@ -166,6 +156,18 @@ margin 0 padding 0 background #fff + border-bottom solid 1px #eaeaea + + &:first-child + border-top-left-radius 6px + border-top-right-radius 6px + + > .repost + border-top-left-radius 6px + border-top-right-radius 6px + + &:last-of-type + border-bottom none &:focus z-index 1 diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index 6895384a56..43470d197e 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -46,15 +46,6 @@ font-size 3em color #ccc - > mk-timeline-post - border-bottom solid 1px #eaeaea - - &:first-child - border-radius 8px 8px 0 0 - - &:last-of-type - border-bottom none - > .date display block margin 0 @@ -208,6 +199,16 @@ margin 0 padding 0 font-size 12px + border-bottom solid 1px #eaeaea + + &:first-child + border-radius 8px 8px 0 0 + + > .repost + border-radius 8px 8px 0 0 + + &:last-of-type + border-bottom none @media (min-width 350px) font-size 14px From 36a3bc1fdd47685bd16235cfc11b679e82602f02 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 22:24:28 +0900 Subject: [PATCH 070/364] :art: --- src/web/app/mobile/tags/page/settings/profile.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/app/mobile/tags/page/settings/profile.tag b/src/web/app/mobile/tags/page/settings/profile.tag index 7e1bedbf47..305f16fec5 100644 --- a/src/web/app/mobile/tags/page/settings/profile.tag +++ b/src/web/app/mobile/tags/page/settings/profile.tag @@ -146,7 +146,7 @@ padding 12px font-size 16px color #192427 - border solid 1px #ddd + border solid 2px #ddd border-radius 4px > textarea From 113489800330ec3b765c1733fff1bc2621118068 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 Aug 2017 22:27:42 +0900 Subject: [PATCH 071/364] v2498 --- CHANGELOG.md | 4 +++- package.json | 2 +- src/const.json | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06d88d08c4..c42008de51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,12 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます -unreleased +2498 (2017/08/29) ---------- * Fix: repostのborder-radiusが効いていない (#743) +* テーマカラーを赤に戻してみた * ユーザビリティの向上 +* デザインの調整 2493-2 (2017/08/29) ------------------- diff --git a/package.json b/package.json index dca1bff8ce..fff34b2d4b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2493-2", + "version": "0.0.2498", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", diff --git a/src/const.json b/src/const.json index 1032ed538f..eeb304c9f3 100644 --- a/src/const.json +++ b/src/const.json @@ -1,5 +1,4 @@ { - "themeColor": "#87bb35", - "themeColorForeground": "#fff", - "idea": ["#f13049", "#f43636"] + "themeColor": "#f43636", + "themeColorForeground": "#fff" } From 9f477549ddbf6bf5b892df993fd44f8e1cf0f2bc Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 01:37:33 +0900 Subject: [PATCH 072/364] :v: --- CHANGELOG.md | 6 +- locales/en.yml | 14 ++ locales/ja.yml | 14 ++ src/web/app/mobile/router.js | 2 +- src/web/app/mobile/tags/user.tag | 260 ++++++++++++++++++++++++++++++- 5 files changed, 291 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c42008de51..6b6c80bf7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,12 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます -2498 (2017/08/29) +unreleased ---------- +* New: モバイルのユーザーページを刷新 + +2498 (2017/08/29) +----------------- * Fix: repostのborder-radiusが効いていない (#743) * テーマカラーを赤に戻してみた * ユーザビリティの向上 diff --git a/locales/en.yml b/locales/en.yml index 5e11339db5..231fc640ec 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -472,9 +472,23 @@ mobile: is-followed: "Followed you" following: "Following" followers: "Followers" + overview: "Overview" posts: "Timeline" media: "Media" + mk-user-overview: + recent-posts: "Recent posts" + images: "Images" + activity: "Activity" + + mk-user-overview-posts: + loading: "Loading" + no-posts: "No posts" + + mk-user-overview-photos: + loading: "Loading" + no-photos: "No photos" + mk-users-list: all: "All" known: "You know" diff --git a/locales/ja.yml b/locales/ja.yml index 62ac4cb81f..651f529fb8 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -472,10 +472,24 @@ mobile: is-followed: "フォローされています" following: "フォロー" followers: "フォロワー" + overview: "概要" posts: "タイムライン" posts-count: "ポスト" media: "メディア" + mk-user-overview: + recent-posts: "最近の投稿" + images: "画像" + activity: "アクティビティ" + + mk-user-overview-posts: + loading: "読み込み中" + no-posts: "投稿はありません" + + mk-user-overview-photos: + loading: "読み込み中" + no-photos: "写真はありません" + mk-users-list: all: "すべて" known: "知り合い" diff --git a/src/web/app/mobile/router.js b/src/web/app/mobile/router.js index de4108a593..d59b2ec3a1 100644 --- a/src/web/app/mobile/router.js +++ b/src/web/app/mobile/router.js @@ -23,7 +23,7 @@ export default me => { route('/post/new', newPost); route('/post::post', post); route('/search::query', search); - route('/:user', user.bind(null, 'posts')); + route('/:user', user.bind(null, 'overview')); route('/:user/graphs', user.bind(null, 'graphs')); route('/:user/followers', userFollowers); route('/:user/following', userFollowing); diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index fbf2f690a3..7d88957849 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -37,14 +37,15 @@ %i18n:mobile.tags.mk-user.followers%
-
+
@@ -55,6 +56,8 @@ > .user > header + box-shadow 0 4px 4px rgba(0, 0, 0, 0.3) + > .banner padding-bottom 33.3% background-color #1b1b1b @@ -159,7 +162,6 @@ justify-content center margin 0 auto max-width 600px - border-bottom solid 1px rgba(0, 0, 0, 0.2) > a display block @@ -190,7 +192,7 @@ this.mixin('api'); this.username = this.opts.user; - this.page = this.opts.page ? this.opts.page : 'posts'; + this.page = this.opts.page ? this.opts.page : 'overview'; this.fetching = true; this.on('mount', () => { @@ -211,3 +213,255 @@ }; + + +
+

%i18n:mobile.tags.mk-user-overview.recent-posts%

+
+ +
+
+
+

%i18n:mobile.tags.mk-user-overview.images%

+
+ +
+
+
+

%i18n:mobile.tags.mk-user-overview.activity%

+
+ +
+
+ + +
+ + +

%i18n:mobile.tags.mk-user-overview-posts.loading%

+
0 }> + + + +
+

%i18n:mobile.tags.mk-user-overview-posts.no-posts%

+ + +
+ + + +
+ avatar

{ post.user.name }

+
+
+ { text } +
+ +
+ + +
+ + +

%i18n:mobile.tags.mk-user-overview-photos.loading%

+
0 }> + + + +
+

%i18n:mobile.tags.mk-user-overview-photos.no-photos%

+ + +
From 76f7734b65208082f0ddf62d7d355628b7300de3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 01:41:21 +0900 Subject: [PATCH 073/364] v2501 --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b6c80bf7d..ead734d686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます -unreleased ----------- +2501 (2017/08/30) +----------------- * New: モバイルのユーザーページを刷新 2498 (2017/08/29) diff --git a/package.json b/package.json index fff34b2d4b..8afa4f5819 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2498", + "version": "0.0.2501", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From c15886e0e58af70bb87b357a4d6db24bf5966953 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 01:54:09 +0900 Subject: [PATCH 074/364] v2502 --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/web/app/mobile/tags/user.tag | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ead734d686..09732dd66b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2502 (2017/08/30) +----------------- +* デザインの修正・調整 + 2501 (2017/08/30) ----------------- * New: モバイルのユーザーページを刷新 diff --git a/package.json b/package.json index 8afa4f5819..4139c94c60 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2501", + "version": "0.0.2502", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index 7d88957849..c81eb929a8 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -250,7 +250,7 @@ > h2 margin 0 padding 8px 10px - font-size 16px + font-size 15px font-weight normal color #465258 background #fff @@ -362,7 +362,8 @@ display inline-block overflow hidden width calc(100% - 45px) - margin-left 44px + margin 8px 0 0 44px + line-height 28px white-space nowrap text-overflow ellipsis @@ -380,7 +381,7 @@ left 0 width 100% height 20px - background linear-gradient(to bottom, transparent 0%, #fff 100%) + background linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, #fff 100%) > mk-time display inline-block From c1510f90adae55ae4b3af117cce2b7267248c728 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 02:03:07 +0900 Subject: [PATCH 075/364] v2503 --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/web/app/mobile/tags/user.tag | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09732dd66b..2cda49be49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2503 (2017/08/30) +----------------- +* デザインの調整 + 2502 (2017/08/30) ----------------- * デザインの修正・調整 diff --git a/package.json b/package.json index 4139c94c60..bce252fa3f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2502", + "version": "0.0.2503", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index c81eb929a8..bd6bbad726 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -362,10 +362,11 @@ display inline-block overflow hidden width calc(100% - 45px) - margin 8px 0 0 44px + margin 8px 0 0 42px line-height 28px white-space nowrap text-overflow ellipsis + font-size 12px > div padding 0 8px 8px 8px From a1f355fc9d2fe646590f192e61aaa3bc0c6a1025 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 29 Aug 2017 21:54:50 +0000 Subject: [PATCH 076/364] chore(package): update @types/node to version 8.0.26 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bce252fa3f..fdf3f0bd6b 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.25", + "@types/node": "8.0.26", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.3", From e89e40c80467418b8c15dc19cbb770f70844f175 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: Wed, 30 Aug 2017 10:59:50 +0900 Subject: [PATCH 077/364] Update DONORS.md --- DONORS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DONORS.md b/DONORS.md index d022c4ef64..21610304e0 100644 --- a/DONORS.md +++ b/DONORS.md @@ -3,6 +3,9 @@ DONORS (no particular order) +* らふぁ +* 俺様 +* なぎうり * スルメ https://surume.tk/ :heart: Thanks for donating, guys! From 4c0fbaedfa4cd1cac6c4980b078330566eafaed5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 11:38:35 +0900 Subject: [PATCH 078/364] =?UTF-8?q?=E3=83=A2=E3=83=90=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E7=89=88=E3=81=AE=E3=82=A2=E3=82=AF=E3=83=86=E3=82=A3=E3=83=93?= =?UTF-8?q?=E3=83=86=E3=82=A3=E3=83=81=E3=83=A3=E3=83=BC=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++ src/web/app/common/tags/index.js | 1 + .../app/common/tags/weekly-activity-chart.tag | 49 +++++++++++++++++++ src/web/app/mobile/tags/user.tag | 2 +- 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/web/app/common/tags/weekly-activity-chart.tag diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cda49be49..f6e78485c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +unreleased +---------- +* New: モバイル版のアクティビティチャートを変更 + 2503 (2017/08/30) ----------------- * デザインの調整 diff --git a/src/web/app/common/tags/index.js b/src/web/app/common/tags/index.js index 1ee8dab42d..dd6ba75d7a 100644 --- a/src/web/app/common/tags/index.js +++ b/src/web/app/common/tags/index.js @@ -27,3 +27,4 @@ require('./activity-table.tag'); require('./reaction-picker.tag'); require('./reactions-viewer.tag'); require('./reaction-icon.tag'); +require('./weekly-activity-chart.tag'); diff --git a/src/web/app/common/tags/weekly-activity-chart.tag b/src/web/app/common/tags/weekly-activity-chart.tag new file mode 100644 index 0000000000..ae9f7071c5 --- /dev/null +++ b/src/web/app/common/tags/weekly-activity-chart.tag @@ -0,0 +1,49 @@ + + + + + + + + + + + diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index bd6bbad726..3ed186de9e 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -230,7 +230,7 @@

%i18n:mobile.tags.mk-user-overview.activity%

- +
+ diff --git a/src/web/app/desktop/tags/post-detail.tag b/src/web/app/desktop/tags/post-detail.tag index 7a90dccf39..58343482d0 100644 --- a/src/web/app/desktop/tags/post-detail.tag +++ b/src/web/app/desktop/tags/post-detail.tag @@ -43,16 +43,18 @@
- - - + -
@@ -315,6 +317,13 @@ }); }; + this.menu = () => { + riot.mount(document.body.appendChild(document.createElement('mk-post-menu')), { + source: this.refs.menuButton, + post: this.p + }); + }; + this.loadContext = () => { this.contextFetching = true; diff --git a/src/web/app/desktop/tags/timeline.tag b/src/web/app/desktop/tags/timeline.tag index bce27cd7f3..cd7ac7d207 100644 --- a/src/web/app/desktop/tags/timeline.tag +++ b/src/web/app/desktop/tags/timeline.tag @@ -128,16 +128,16 @@
- - - - - - + -
-
+
@@ -64,19 +66,14 @@ :scope display block overflow hidden - margin 8px auto + margin 0 auto padding 0 - max-width 500px - width calc(100% - 16px) + width 100% text-align left background #fff border-radius 8px box-shadow 0 0 0 1px rgba(0, 0, 0, 0.2) - @media (min-width 500px) - margin 16px auto - width calc(100% - 32px) - > .fetching padding 64px 0 @@ -269,6 +266,7 @@ this.mixin('api'); + this.compact = this.opts.compact; this.post = this.opts.post; this.isRepost = this.post.repost != null; this.p = this.isRepost ? this.post.repost : this.post; @@ -299,14 +297,16 @@ } // Get replies - this.api('posts/replies', { - post_id: this.p.id, - limit: 8 - }).then(replies => { - this.update({ - replies: replies + if (!this.compact) { + this.api('posts/replies', { + post_id: this.p.id, + limit: 8 + }).then(replies => { + this.update({ + replies: replies + }); }); - }); + } }); this.reply = () => { @@ -332,6 +332,14 @@ }); }; + this.menu = () => { + riot.mount(document.body.appendChild(document.createElement('mk-post-menu')), { + source: this.refs.menuButton, + post: this.p, + compact: true + }); + }; + this.loadContext = () => { this.contextFetching = true; diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index 43470d197e..d8df8b2663 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -181,14 +181,17 @@
- - - +
@@ -558,6 +561,14 @@ compact: true }); }; + + this.menu = () => { + riot.mount(document.body.appendChild(document.createElement('mk-post-menu')), { + source: this.refs.menuButton, + post: this.p, + compact: true + }); + };
diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index d85e3b51fd..0fe4055cf0 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -215,6 +215,7 @@ +

%i18n:mobile.tags.mk-user-overview.recent-posts%

@@ -240,6 +241,9 @@ max-width 600px margin 0 auto + > mk-post-detail + margin 0 0 8px 0 + > section background #eee border-radius 8px From 52138eb4c317a8a23ba5d12a9194937914713f35 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 17:32:03 +0900 Subject: [PATCH 083/364] [Client] Fix bug --- CHANGELOG.md | 1 + src/web/app/common/tags/weekly-activity-chart.tag | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2669bfee74..a9a362dbef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog (Release Notes) unreleased ---------- * New: 投稿のピン留め (#746) +* その他細かな修正 2508 (2017/08/30) ----------------- diff --git a/src/web/app/common/tags/weekly-activity-chart.tag b/src/web/app/common/tags/weekly-activity-chart.tag index ae9f7071c5..d9c6c4bd1c 100644 --- a/src/web/app/common/tags/weekly-activity-chart.tag +++ b/src/web/app/common/tags/weekly-activity-chart.tag @@ -2,13 +2,13 @@ From 631ff6e49048c729c3d71db0e3170d1dec4196fe Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 17:37:11 +0900 Subject: [PATCH 084/364] :v: --- src/web/app/common/tags/index.js | 1 - .../app/common/tags/weekly-activity-chart.tag | 49 ---------------- src/web/app/mobile/tags/user.tag | 56 ++++++++++++++++++- 3 files changed, 54 insertions(+), 52 deletions(-) delete mode 100644 src/web/app/common/tags/weekly-activity-chart.tag diff --git a/src/web/app/common/tags/index.js b/src/web/app/common/tags/index.js index 6e6081da9b..35a9f4586e 100644 --- a/src/web/app/common/tags/index.js +++ b/src/web/app/common/tags/index.js @@ -27,5 +27,4 @@ require('./activity-table.tag'); require('./reaction-picker.tag'); require('./reactions-viewer.tag'); require('./reaction-icon.tag'); -require('./weekly-activity-chart.tag'); require('./post-menu.tag'); diff --git a/src/web/app/common/tags/weekly-activity-chart.tag b/src/web/app/common/tags/weekly-activity-chart.tag deleted file mode 100644 index d9c6c4bd1c..0000000000 --- a/src/web/app/common/tags/weekly-activity-chart.tag +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index 0fe4055cf0..5fc43269d6 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -231,7 +231,7 @@

%i18n:mobile.tags.mk-user-overview.activity%

- +

%i18n:mobile.tags.mk-user-overview.last-used-at%:

@@ -462,7 +462,7 @@ this.api('users/posts', { user_id: this.user.id, with_media: true, - limit: 9 + limit: 6 }).then(posts => { this.initializing = false; posts.forEach(post => { @@ -478,3 +478,55 @@ }); + + + + + + + + + + + + From 7fe0abc5cec71759807a41f383606dd156f11d88 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 17:45:23 +0900 Subject: [PATCH 085/364] Implement #745 --- CHANGELOG.md | 1 + src/api/stream/home.ts | 10 ++++++++++ src/web/app/common/scripts/home-stream.js | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a362dbef..cc5a6bc8a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog (Release Notes) unreleased ---------- * New: 投稿のピン留め (#746) +* New: ホームストリームにメッセージを流すことでlast_used_atを更新できるようにする (#745) * その他細かな修正 2508 (2017/08/30) diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts index 2ab8d3025b..d5fe01c261 100644 --- a/src/api/stream/home.ts +++ b/src/api/stream/home.ts @@ -2,6 +2,7 @@ import * as websocket from 'websocket'; import * as redis from 'redis'; import * as debug from 'debug'; +import User from '../models/user'; import serializePost from '../serializers/post'; const log = debug('misskey'); @@ -35,6 +36,15 @@ export default function homeStream(request: websocket.request, connection: webso const msg = JSON.parse(data.utf8Data); switch (msg.type) { + case 'alive': + // Update lastUsedAt + User.update({ _id: user._id }, { + $set: { + last_used_at: new Date() + } + }); + break; + case 'capture': if (!msg.id) return; const postId = msg.id; diff --git a/src/web/app/common/scripts/home-stream.js b/src/web/app/common/scripts/home-stream.js index c54cbd7f19..de9ceb3b51 100644 --- a/src/web/app/common/scripts/home-stream.js +++ b/src/web/app/common/scripts/home-stream.js @@ -12,6 +12,11 @@ class Connection extends Stream { i: me.token }); + // 最終利用日時を更新するため定期的にaliveメッセージを送信 + setInterval(() => { + this.send({ type: 'alive' }); + }, 1000 * 60); + this.on('i_updated', me.update); this.on('my_token_regenerated', () => { From 5d9572cda22b89621cae4132b47ec2caaac07a22 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 18:06:16 +0900 Subject: [PATCH 086/364] =?UTF-8?q?=E3=83=A2=E3=83=90=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E7=89=88=E3=81=AE=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AB=E7=9F=A5=E3=82=8A=E5=90=88=E3=81=84?= =?UTF-8?q?=E3=81=AE=E3=83=95=E3=82=A9=E3=83=AD=E3=83=AF=E3=83=BC=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + locales/en.yml | 5 +++ locales/ja.yml | 5 +++ src/web/app/mobile/tags/user.tag | 65 ++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc5a6bc8a4..ab207126cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog (Release Notes) unreleased ---------- * New: 投稿のピン留め (#746) +* New: モバイル版のユーザーページに知り合いのフォロワーを表示するように * New: ホームストリームにメッセージを流すことでlast_used_atを更新できるようにする (#745) * その他細かな修正 diff --git a/locales/en.yml b/locales/en.yml index 15d278c370..a410bfb431 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -484,6 +484,7 @@ mobile: recent-posts: "Recent posts" images: "Images" activity: "Activity" + followers-you-know: "Followers you know" last-used-at: "Latest used at" mk-user-overview-posts: @@ -494,6 +495,10 @@ mobile: loading: "Loading" no-photos: "No photos" + mk-user-overview-followers-you-know: + loading: "Loading" + no-users: "No users" + mk-users-list: all: "All" known: "You know" diff --git a/locales/ja.yml b/locales/ja.yml index 7ed4262f1c..eb7e35c7d6 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -485,6 +485,7 @@ mobile: recent-posts: "最近の投稿" images: "画像" activity: "アクティビティ" + followers-you-know: "知り合いのフォロワー" last-used-at: "最終ログイン" mk-user-overview-posts: @@ -495,6 +496,10 @@ mobile: loading: "読み込み中" no-photos: "写真はありません" + mk-user-overview-followers-you-know: + loading: "読み込み中" + no-users: "知り合いのユーザーはいません" + mk-users-list: all: "すべて" known: "知り合い" diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index 5fc43269d6..83231f01d7 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -234,6 +234,12 @@
+
+

%i18n:mobile.tags.mk-user-overview.followers-you-know%

+
+ +
+

%i18n:mobile.tags.mk-user-overview.last-used-at%:

@@ -530,3 +538,60 @@ }); + + +

%i18n:mobile.tags.mk-user-overview-followers-you-know.loading%

+
0 }> + + { + +
+

%i18n:mobile.tags.mk-user-overview-followers-you-know.no-users%

+ + +
From 5d57b288007161a8f2d99bdaebcb5447d1fa6b11 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 18:06:54 +0900 Subject: [PATCH 087/364] v2515 --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab207126cd..066ce8cfee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます -unreleased ----------- +2515 (2017/08/30) +----------------- * New: 投稿のピン留め (#746) * New: モバイル版のユーザーページに知り合いのフォロワーを表示するように * New: ホームストリームにメッセージを流すことでlast_used_atを更新できるようにする (#745) diff --git a/package.json b/package.json index 964179d755..acb182c057 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2508", + "version": "0.0.2515", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From 659446c075f04f2a52faa5f51d01e14dd8d4aa08 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 18:56:51 +0900 Subject: [PATCH 088/364] Fix bug --- CHANGELOG.md | 4 ++++ src/web/app/mobile/tags/timeline.tag | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 066ce8cfee..3f7dadd948 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +unreleased +---------- +* Fix: モバイル版のタイムラインからリアクションやメニューを開けない + 2515 (2017/08/30) ----------------- * New: 投稿のピン留め (#746) diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index d8df8b2663..bc01394554 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -190,7 +190,7 @@ - From d51ac13b237fc71cb6bb95aa006947cd0b1dfe5b Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 30 Aug 2017 18:59:50 +0900 Subject: [PATCH 089/364] #748 --- CHANGELOG.md | 1 + src/web/app/mobile/tags/timeline.tag | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f7dadd948..bca7815d24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog (Release Notes) unreleased ---------- * Fix: モバイル版のタイムラインからリアクションやメニューを開けない +* デザインの調整 2515 (2017/08/30) ----------------- diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index bc01394554..62d47678ac 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -190,7 +190,7 @@ - @@ -454,6 +454,10 @@ &.reacted color $theme-color + &.menu + @media (max-width 350px) + display none + - diff --git a/src/web/app/desktop/tags/ui-header-clock.tag b/src/web/app/desktop/tags/ui-header-clock.tag deleted file mode 100644 index b8cb078497..0000000000 --- a/src/web/app/desktop/tags/ui-header-clock.tag +++ /dev/null @@ -1,86 +0,0 @@ - -
- -
-
- -
- - -
diff --git a/src/web/app/desktop/tags/ui-header-nav.tag b/src/web/app/desktop/tags/ui-header-nav.tag deleted file mode 100644 index c36ce65798..0000000000 --- a/src/web/app/desktop/tags/ui-header-nav.tag +++ /dev/null @@ -1,133 +0,0 @@ - - - - - diff --git a/src/web/app/desktop/tags/ui-header-notifications.tag b/src/web/app/desktop/tags/ui-header-notifications.tag deleted file mode 100644 index 3cd8d1e3df..0000000000 --- a/src/web/app/desktop/tags/ui-header-notifications.tag +++ /dev/null @@ -1,108 +0,0 @@ - - -
- -
- - -
diff --git a/src/web/app/desktop/tags/ui-header-post-button.tag b/src/web/app/desktop/tags/ui-header-post-button.tag deleted file mode 100644 index ca380b06ea..0000000000 --- a/src/web/app/desktop/tags/ui-header-post-button.tag +++ /dev/null @@ -1,42 +0,0 @@ - - - - - diff --git a/src/web/app/desktop/tags/ui-header-search.tag b/src/web/app/desktop/tags/ui-header-search.tag deleted file mode 100644 index 616476f42c..0000000000 --- a/src/web/app/desktop/tags/ui-header-search.tag +++ /dev/null @@ -1,42 +0,0 @@ - - - - - diff --git a/src/web/app/desktop/tags/ui-header.tag b/src/web/app/desktop/tags/ui-header.tag deleted file mode 100644 index fa7f2cb2ac..0000000000 --- a/src/web/app/desktop/tags/ui-header.tag +++ /dev/null @@ -1,86 +0,0 @@ - - - -
-
-
-
-
- -
-
- - - - - -
-
-
-
- - -
diff --git a/src/web/app/desktop/tags/ui-notification.tag b/src/web/app/desktop/tags/ui-notification.tag deleted file mode 100644 index f39d766d8c..0000000000 --- a/src/web/app/desktop/tags/ui-notification.tag +++ /dev/null @@ -1,51 +0,0 @@ - -

{ opts.message }

- - -
diff --git a/src/web/app/desktop/tags/ui.tag b/src/web/app/desktop/tags/ui.tag index 788fb56131..fce0743ff7 100644 --- a/src/web/app/desktop/tags/ui.tag +++ b/src/web/app/desktop/tags/ui.tag @@ -35,3 +35,773 @@ }; + + + + +
+
+
+
+
+ +
+
+ + + + + +
+
+
+
+ + +
+ + + + + + + + + + + + + + + +
+ +
+ + +
+ + + + + + + + +
+ +
+
+ +
+ + +
+ + + + + + + + + +

{ opts.message }

+ + +
From 03f1515f694b415b55269ba14afd2bfa381523d3 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 31 Aug 2017 16:52:23 +0000 Subject: [PATCH 098/364] fix(package): update typescript to version 2.5.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43a05ae469..e137681230 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "tcp-port-used": "0.1.2", "textarea-caret": "3.0.2", "ts-node": "3.3.0", - "typescript": "2.4.2", + "typescript": "2.5.2", "uuid": "3.1.0", "vhost": "3.0.2", "websocket": "1.0.24", From 6e28f5f970a6707733f59dec73d768ec7ddf080d Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 31 Aug 2017 22:14:40 +0000 Subject: [PATCH 099/364] chore(package): update chai to version 4.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43a05ae469..1e6586a630 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@types/webpack": "3.0.10", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", - "chai": "4.1.1", + "chai": "4.1.2", "chai-http": "3.0.0", "css-loader": "0.28.7", "event-stream": "3.3.4", From c52f6803399aa47e083a5bbce9ce2c831a63c617 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 2 Sep 2017 17:26:37 +0000 Subject: [PATCH 100/364] fix(package): update riot to version 3.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 43a05ae469..5c9c902b15 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "redis": "2.8.0", "request": "2.81.0", "rimraf": "2.6.1", - "riot": "3.6.3", + "riot": "3.7.0", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.3", From 825d9b9b04234a0ff40590ea89c91a92175994c8 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 3 Sep 2017 13:22:07 +0000 Subject: [PATCH 101/364] fix(package): update cropperjs to version 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c9c902b15..f48c7fd72c 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "chalk": "2.1.0", "compression": "1.7.0", "cors": "2.8.4", - "cropperjs": "1.0.0-rc.3", + "cropperjs": "1.0.0", "crypto": "1.0.1", "debug": "3.0.1", "deep-equal": "1.0.1", From b8777bd58723f6e93d3e476fd4314a5e2ae0026c 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: Mon, 4 Sep 2017 02:32:06 +0900 Subject: [PATCH 102/364] Update DONORS.md --- DONORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DONORS.md b/DONORS.md index 21610304e0..da71c043ac 100644 --- a/DONORS.md +++ b/DONORS.md @@ -12,7 +12,7 @@ DONORS --- -You donated, but you are not listed here? please contact to us! +Although you donated, you are not listed here? please contact to us! If you want to donate to Misskey, please get in touch with [@syuilo][syuilo-link]. From 016dda27bdc9cf854c6f26309faf09f6f778f904 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: Mon, 4 Sep 2017 02:41:32 +0900 Subject: [PATCH 103/364] Update mocha.opts --- test/mocha.opts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mocha.opts b/test/mocha.opts index cf80ee74bc..907011807d 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1 +1 @@ ---timeout 5000 +--timeout 10000 From f33571f2f42cf9d5313a32195fbe147941a95f87 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 6 Sep 2017 19:41:36 +0900 Subject: [PATCH 104/364] wip --- package.json | 2 + src/tools/ai/categorizer.ts | 89 +++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 src/tools/ai/categorizer.ts diff --git a/package.json b/package.json index a2896f4c70..ae959d1b13 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ "accesses": "2.5.0", "animejs": "2.0.2", "autwh": "0.0.1", + "bayes": "0.0.7", "bcryptjs": "2.4.3", "body-parser": "1.17.2", "cafy": "2.4.0", @@ -120,6 +121,7 @@ "is-root": "1.0.0", "is-url": "1.2.2", "js-yaml": "3.9.1", + "mecab-async": "^0.1.0", "mongodb": "2.2.31", "monk": "6.0.3", "morgan": "1.8.2", diff --git a/src/tools/ai/categorizer.ts b/src/tools/ai/categorizer.ts new file mode 100644 index 0000000000..f70ce1b7d4 --- /dev/null +++ b/src/tools/ai/categorizer.ts @@ -0,0 +1,89 @@ +import * as fs from 'fs'; +const bayes = require('bayes'); +const MeCab = require('mecab-async'); +import Post from '../../api/models/post'; + +export default class Categorizer { + classifier: any; + categorizerDbFilePath: string; + mecab: any; + + constructor(categorizerDbFilePath: string, mecabCommand: string = 'mecab -d /usr/share/mecab/dic/mecab-ipadic-neologd') { + this.categorizerDbFilePath = categorizerDbFilePath; + + this.mecab = new MeCab(); + this.mecab.command = mecabCommand; + + // BIND ----------------------------------- + this.tokenizer = this.tokenizer.bind(this); + } + + tokenizer(text: string) { + return this.mecab.wakachiSync(text); + } + + async init() { + try { + const db = fs.readFileSync(this.categorizerDbFilePath, { + encoding: 'utf8' + }); + + this.classifier = bayes.fromJson(db); + this.classifier.tokenizer = this.tokenizer; + } catch(e) { + this.classifier = bayes({ + tokenizer: this.tokenizer + }); + + // 訓練データ + const verifiedPosts = await Post.find({ + is_category_verified: true + }); + + // 学習 + verifiedPosts.forEach(post => { + this.classifier.learn(post.text, post.category); + }); + + this.save(); + } + } + + async learn(id, category) { + const post = await Post.findOne({ _id: id }); + + Post.update({ _id: id }, { + $set: { + category: category, + is_category_verified: true + } + }); + + this.classifier.learn(post.text, category); + + this.save(); + } + + async categorize(id) { + const post = await Post.findOne({ _id: id }); + + const category = this.classifier.categorize(post.text); + + Post.update({ _id: id }, { + $set: { + category: category + } + }); + } + + async test(text) { + return this.classifier.categorize(text); + } + + save() { + fs.writeFileSync(this.categorizerDbFilePath, this.classifier.toJson(), { + encoding: 'utf8' + }); + } +} + From cf7b1c0c5d86a20328dd7a44f27cff739f4126b3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 6 Sep 2017 21:29:56 +0900 Subject: [PATCH 105/364] wip --- .gitignore | 1 + package.json | 3 +- src/config.ts | 3 + src/tools/ai/categorizer.ts | 48 +++--- src/tools/ai/naive-bayes.js | 302 ++++++++++++++++++++++++++++++++++++ 5 files changed, 334 insertions(+), 23 deletions(-) create mode 100644 src/tools/ai/naive-bayes.js diff --git a/.gitignore b/.gitignore index 42b1bde94f..2ae0f98c5e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /node_modules /built /uploads +/data npm-debug.log *.pem run.bat diff --git a/package.json b/package.json index ae959d1b13..31cf7a02cd 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@types/webpack": "3.0.10", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", + "@types/msgpack-lite": "^0.1.5", "chai": "4.1.2", "chai-http": "3.0.0", "css-loader": "0.28.7", @@ -97,7 +98,6 @@ "accesses": "2.5.0", "animejs": "2.0.2", "autwh": "0.0.1", - "bayes": "0.0.7", "bcryptjs": "2.4.3", "body-parser": "1.17.2", "cafy": "2.4.0", @@ -126,6 +126,7 @@ "monk": "6.0.3", "morgan": "1.8.2", "ms": "2.0.0", + "msgpack-lite": "^0.1.26", "multer": "1.3.0", "nprogress": "0.2.0", "os-utils": "0.0.14", diff --git a/src/config.ts b/src/config.ts index 8f4ada5af9..f333a1f5a9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -68,6 +68,9 @@ type Source = { hook_secret: string; username: string; }; + categorizer?: { + mecab_command?: string; + }; }; /** diff --git a/src/tools/ai/categorizer.ts b/src/tools/ai/categorizer.ts index f70ce1b7d4..c13374161d 100644 --- a/src/tools/ai/categorizer.ts +++ b/src/tools/ai/categorizer.ts @@ -1,36 +1,42 @@ import * as fs from 'fs'; -const bayes = require('bayes'); + +const bayes = require('./naive-bayes.js'); const MeCab = require('mecab-async'); +import * as msgpack from 'msgpack-lite'; + import Post from '../../api/models/post'; +import config from '../../conf'; +/** + * 投稿を学習したり与えられた投稿のカテゴリを予測します + */ export default class Categorizer { - classifier: any; - categorizerDbFilePath: string; - mecab: any; + private classifier: any; + private categorizerDbFilePath: string; + private mecab: any; - constructor(categorizerDbFilePath: string, mecabCommand: string = 'mecab -d /usr/share/mecab/dic/mecab-ipadic-neologd') { - this.categorizerDbFilePath = categorizerDbFilePath; + constructor() { + this.categorizerDbFilePath = `${__dirname}/../../../data/category`; this.mecab = new MeCab(); - this.mecab.command = mecabCommand; + if (config.categorizer.mecab_command) this.mecab.command = config.categorizer.mecab_command; // BIND ----------------------------------- this.tokenizer = this.tokenizer.bind(this); } - tokenizer(text: string) { + private tokenizer(text: string) { return this.mecab.wakachiSync(text); } - async init() { + public async init() { try { - const db = fs.readFileSync(this.categorizerDbFilePath, { - encoding: 'utf8' - }); + const buffer = fs.readFileSync(this.categorizerDbFilePath); + const db = msgpack.decode(buffer); - this.classifier = bayes.fromJson(db); + this.classifier = bayes.import(db); this.classifier.tokenizer = this.tokenizer; - } catch(e) { + } catch (e) { this.classifier = bayes({ tokenizer: this.tokenizer }); @@ -49,7 +55,7 @@ export default class Categorizer { } } - async learn(id, category) { + public async learn(id, category) { const post = await Post.findOne({ _id: id }); Post.update({ _id: id }, { @@ -64,7 +70,7 @@ export default class Categorizer { this.save(); } - async categorize(id) { + public async categorize(id) { const post = await Post.findOne({ _id: id }); const category = this.classifier.categorize(post.text); @@ -76,14 +82,12 @@ export default class Categorizer { }); } - async test(text) { + public async test(text) { return this.classifier.categorize(text); } - save() { - fs.writeFileSync(this.categorizerDbFilePath, this.classifier.toJson(), { - encoding: 'utf8' - }); + private save() { + const buffer = msgpack.encode(this.classifier.export()); + fs.writeFileSync(this.categorizerDbFilePath, buffer); } } - diff --git a/src/tools/ai/naive-bayes.js b/src/tools/ai/naive-bayes.js new file mode 100644 index 0000000000..78f07153cf --- /dev/null +++ b/src/tools/ai/naive-bayes.js @@ -0,0 +1,302 @@ +// Original source code: https://github.com/ttezel/bayes/blob/master/lib/naive_bayes.js (commit: 2c20d3066e4fc786400aaedcf3e42987e52abe3c) +// CUSTOMIZED BY SYUILO + +/* + Expose our naive-bayes generator function +*/ +module.exports = function (options) { + return new Naivebayes(options) +} + +// keys we use to serialize a classifier's state +var STATE_KEYS = module.exports.STATE_KEYS = [ + 'categories', 'docCount', 'totalDocuments', 'vocabulary', 'vocabularySize', + 'wordCount', 'wordFrequencyCount', 'options' +]; + +/** + * Initializes a NaiveBayes instance from a JSON state representation. + * Use this with classifier.toJson(). + * + * @param {String} jsonStr state representation obtained by classifier.toJson() + * @return {NaiveBayes} Classifier + */ +module.exports.fromJson = function (jsonStr) { + var parsed; + try { + parsed = JSON.parse(jsonStr) + } catch (e) { + throw new Error('Naivebayes.fromJson expects a valid JSON string.') + } + // init a new classifier + var classifier = new Naivebayes(parsed.options) + + // override the classifier's state + STATE_KEYS.forEach(function (k) { + if (!parsed[k]) { + throw new Error('Naivebayes.fromJson: JSON string is missing an expected property: `'+k+'`.') + } + classifier[k] = parsed[k] + }) + + return classifier +} + +/** + * Given an input string, tokenize it into an array of word tokens. + * This is the default tokenization function used if user does not provide one in `options`. + * + * @param {String} text + * @return {Array} + */ +var defaultTokenizer = function (text) { + //remove punctuation from text - remove anything that isn't a word char or a space + var rgxPunctuation = /[^(a-zA-ZA-Яa-я0-9_)+\s]/g + + var sanitized = text.replace(rgxPunctuation, ' ') + + return sanitized.split(/\s+/) +} + +/** + * Naive-Bayes Classifier + * + * This is a naive-bayes classifier that uses Laplace Smoothing. + * + * Takes an (optional) options object containing: + * - `tokenizer` => custom tokenization function + * + */ +function Naivebayes (options) { + // set options object + this.options = {} + if (typeof options !== 'undefined') { + if (!options || typeof options !== 'object' || Array.isArray(options)) { + throw TypeError('NaiveBayes got invalid `options`: `' + options + '`. Pass in an object.') + } + this.options = options + } + + this.tokenizer = this.options.tokenizer || defaultTokenizer + + //initialize our vocabulary and its size + this.vocabulary = {} + this.vocabularySize = 0 + + //number of documents we have learned from + this.totalDocuments = 0 + + //document frequency table for each of our categories + //=> for each category, how often were documents mapped to it + this.docCount = {} + + //for each category, how many words total were mapped to it + this.wordCount = {} + + //word frequency table for each category + //=> for each category, how frequent was a given word mapped to it + this.wordFrequencyCount = {} + + //hashmap of our category names + this.categories = {} +} + +/** + * Initialize each of our data structure entries for this new category + * + * @param {String} categoryName + */ +Naivebayes.prototype.initializeCategory = function (categoryName) { + if (!this.categories[categoryName]) { + this.docCount[categoryName] = 0 + this.wordCount[categoryName] = 0 + this.wordFrequencyCount[categoryName] = {} + this.categories[categoryName] = true + } + return this +} + +/** + * train our naive-bayes classifier by telling it what `category` + * the `text` corresponds to. + * + * @param {String} text + * @param {String} class + */ +Naivebayes.prototype.learn = function (text, category) { + var self = this + + //initialize category data structures if we've never seen this category + self.initializeCategory(category) + + //update our count of how many documents mapped to this category + self.docCount[category]++ + + //update the total number of documents we have learned from + self.totalDocuments++ + + //normalize the text into a word array + var tokens = self.tokenizer(text) + + //get a frequency count for each token in the text + var frequencyTable = self.frequencyTable(tokens) + + /* + Update our vocabulary and our word frequency count for this category + */ + + Object + .keys(frequencyTable) + .forEach(function (token) { + //add this word to our vocabulary if not already existing + if (!self.vocabulary[token]) { + self.vocabulary[token] = true + self.vocabularySize++ + } + + var frequencyInText = frequencyTable[token] + + //update the frequency information for this word in this category + if (!self.wordFrequencyCount[category][token]) + self.wordFrequencyCount[category][token] = frequencyInText + else + self.wordFrequencyCount[category][token] += frequencyInText + + //update the count of all words we have seen mapped to this category + self.wordCount[category] += frequencyInText + }) + + return self +} + +/** + * Determine what category `text` belongs to. + * + * @param {String} text + * @return {String} category + */ +Naivebayes.prototype.categorize = function (text) { + var self = this + , maxProbability = -Infinity + , chosenCategory = null + + var tokens = self.tokenizer(text) + var frequencyTable = self.frequencyTable(tokens) + + //iterate thru our categories to find the one with max probability for this text + Object + .keys(self.categories) + .forEach(function (category) { + + //start by calculating the overall probability of this category + //=> out of all documents we've ever looked at, how many were + // mapped to this category + var categoryProbability = self.docCount[category] / self.totalDocuments + + //take the log to avoid underflow + var logProbability = Math.log(categoryProbability) + + //now determine P( w | c ) for each word `w` in the text + Object + .keys(frequencyTable) + .forEach(function (token) { + var frequencyInText = frequencyTable[token] + var tokenProbability = self.tokenProbability(token, category) + + // console.log('token: %s category: `%s` tokenProbability: %d', token, category, tokenProbability) + + //determine the log of the P( w | c ) for this word + logProbability += frequencyInText * Math.log(tokenProbability) + }) + + if (logProbability > maxProbability) { + maxProbability = logProbability + chosenCategory = category + } + }) + + return chosenCategory +} + +/** + * Calculate probability that a `token` belongs to a `category` + * + * @param {String} token + * @param {String} category + * @return {Number} probability + */ +Naivebayes.prototype.tokenProbability = function (token, category) { + //how many times this word has occurred in documents mapped to this category + var wordFrequencyCount = this.wordFrequencyCount[category][token] || 0 + + //what is the count of all words that have ever been mapped to this category + var wordCount = this.wordCount[category] + + //use laplace Add-1 Smoothing equation + return ( wordFrequencyCount + 1 ) / ( wordCount + this.vocabularySize ) +} + +/** + * Build a frequency hashmap where + * - the keys are the entries in `tokens` + * - the values are the frequency of each entry in `tokens` + * + * @param {Array} tokens Normalized word array + * @return {Object} + */ +Naivebayes.prototype.frequencyTable = function (tokens) { + var frequencyTable = Object.create(null) + + tokens.forEach(function (token) { + if (!frequencyTable[token]) + frequencyTable[token] = 1 + else + frequencyTable[token]++ + }) + + return frequencyTable +} + +/** + * Dump the classifier's state as a JSON string. + * @return {String} Representation of the classifier. + */ +Naivebayes.prototype.toJson = function () { + var state = {} + var self = this + STATE_KEYS.forEach(function (k) { + state[k] = self[k] + }) + + var jsonStr = JSON.stringify(state) + + return jsonStr +} + +// (original method) +Naivebayes.prototype.export = function () { + var state = {} + var self = this + STATE_KEYS.forEach(function (k) { + state[k] = self[k] + }) + + return state +} + +module.exports.import = function (data) { + var parsed = data + + // init a new classifier + var classifier = new Naivebayes() + + // override the classifier's state + STATE_KEYS.forEach(function (k) { + if (!parsed[k]) { + throw new Error('Naivebayes.import: data is missing an expected property: `'+k+'`.') + } + classifier[k] = parsed[k] + }) + + return classifier +} From c6b0bf42a112f0d9afa8920d6497cc76205ecaf4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 6 Sep 2017 23:19:58 +0900 Subject: [PATCH 106/364] wip --- locales/en.yml | 12 +++ locales/ja.yml | 12 +++ src/api/endpoints.ts | 4 + src/api/endpoints/posts/categorize.ts | 52 +++++++++++++ src/tools/ai/categorizer.ts | 93 ----------------------- src/tools/ai/predict-all-post-category.ts | 57 ++++++++++++++ src/tools/ai/predict-user-interst.ts | 45 +++++++++++ src/web/app/common/tags/post-menu.tag | 23 ++++++ 8 files changed, 205 insertions(+), 93 deletions(-) create mode 100644 src/api/endpoints/posts/categorize.ts delete mode 100644 src/tools/ai/categorizer.ts create mode 100644 src/tools/ai/predict-all-post-category.ts create mode 100644 src/tools/ai/predict-user-interst.ts diff --git a/locales/en.yml b/locales/en.yml index d40896212b..3b87ea758d 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -22,6 +22,14 @@ common: confused: "Confused" pudding: "Pudding" + post_categories: + music: "Music" + game: "Video Game" + anime: "Anime" + it: "IT" + gadgets: "Gadgets" + photography: "Photography" + input-message-here: "Enter message here" send: "Send" delete: "Delete" @@ -80,6 +88,9 @@ common: mk-post-menu: pin: "Pin" pinned: "Pinned" + select: "Select category" + categorize: "Accept" + categorized: "Category reported. Thank you!" mk-reaction-picker: choose-reaction: "Pick your reaction" @@ -375,6 +386,7 @@ mobile: twitter-integration: "Twitter integration" signin-history: "Sign in history" api: "API" + link: "MisskeyLink" settings: "Settings" signout: "Sign out" diff --git a/locales/ja.yml b/locales/ja.yml index b8e5cff412..13d451b6d8 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -22,6 +22,14 @@ common: confused: "こまこまのこまり" pudding: "Pudding" + post_categories: + music: "音楽" + game: "ゲーム" + anime: "アニメ" + it: "IT" + gadgets: "ガジェット" + photography: "写真" + input-message-here: "ここにメッセージを入力" send: "送信" delete: "削除" @@ -80,6 +88,9 @@ common: mk-post-menu: pin: "ピン留め" pinned: "ピン留めしました" + select: "カテゴリを選択" + categorize: "決定" + categorized: "カテゴリを報告しました。これによりMisskeyが賢くなり、投稿の自動カテゴライズに役立てられます。ご協力ありがとうございました。" mk-reaction-picker: choose-reaction: "リアクションを選択" @@ -375,6 +386,7 @@ mobile: twitter-integration: "Twitter連携" signin-history: "ログイン履歴" api: "API" + link: "Misskeyリンク" settings: "設定" signout: "サインアウト" diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index e5be68c096..97b98895b8 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -394,6 +394,10 @@ const endpoints: Endpoint[] = [ name: 'posts/trend', withCredential: true }, + { + name: 'posts/categorize', + withCredential: true + }, { name: 'posts/reactions', withCredential: true diff --git a/src/api/endpoints/posts/categorize.ts b/src/api/endpoints/posts/categorize.ts new file mode 100644 index 0000000000..3530ba6bc4 --- /dev/null +++ b/src/api/endpoints/posts/categorize.ts @@ -0,0 +1,52 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import Post from '../../models/post'; + +/** + * Categorize a post + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + if (!user.is_pro) { + return rej('This endpoint is available only from a Pro account'); + } + + // Get 'post_id' parameter + const [postId, postIdErr] = $(params.post_id).id().$; + if (postIdErr) return rej('invalid post_id param'); + + // Get categorizee + const post = await Post.findOne({ + _id: postId + }); + + if (post === null) { + return rej('post not found'); + } + + if (post.is_category_verified) { + return rej('This post already has the verified category'); + } + + // Get 'category' parameter + const [category, categoryErr] = $(params.category).string().or([ + 'music', 'game', 'anime', 'it', 'gadgets', 'photography' + ]).$; + if (categoryErr) return rej('invalid category param'); + + // Set category + Post.update({ _id: post._id }, { + $set: { + category: category, + is_category_verified: true + } + }); + + // Send response + res(); +}); diff --git a/src/tools/ai/categorizer.ts b/src/tools/ai/categorizer.ts deleted file mode 100644 index c13374161d..0000000000 --- a/src/tools/ai/categorizer.ts +++ /dev/null @@ -1,93 +0,0 @@ -import * as fs from 'fs'; - -const bayes = require('./naive-bayes.js'); -const MeCab = require('mecab-async'); -import * as msgpack from 'msgpack-lite'; - -import Post from '../../api/models/post'; -import config from '../../conf'; - -/** - * 投稿を学習したり与えられた投稿のカテゴリを予測します - */ -export default class Categorizer { - private classifier: any; - private categorizerDbFilePath: string; - private mecab: any; - - constructor() { - this.categorizerDbFilePath = `${__dirname}/../../../data/category`; - - this.mecab = new MeCab(); - if (config.categorizer.mecab_command) this.mecab.command = config.categorizer.mecab_command; - - // BIND ----------------------------------- - this.tokenizer = this.tokenizer.bind(this); - } - - private tokenizer(text: string) { - return this.mecab.wakachiSync(text); - } - - public async init() { - try { - const buffer = fs.readFileSync(this.categorizerDbFilePath); - const db = msgpack.decode(buffer); - - this.classifier = bayes.import(db); - this.classifier.tokenizer = this.tokenizer; - } catch (e) { - this.classifier = bayes({ - tokenizer: this.tokenizer - }); - - // 訓練データ - const verifiedPosts = await Post.find({ - is_category_verified: true - }); - - // 学習 - verifiedPosts.forEach(post => { - this.classifier.learn(post.text, post.category); - }); - - this.save(); - } - } - - public async learn(id, category) { - const post = await Post.findOne({ _id: id }); - - Post.update({ _id: id }, { - $set: { - category: category, - is_category_verified: true - } - }); - - this.classifier.learn(post.text, category); - - this.save(); - } - - public async categorize(id) { - const post = await Post.findOne({ _id: id }); - - const category = this.classifier.categorize(post.text); - - Post.update({ _id: id }, { - $set: { - category: category - } - }); - } - - public async test(text) { - return this.classifier.categorize(text); - } - - private save() { - const buffer = msgpack.encode(this.classifier.export()); - fs.writeFileSync(this.categorizerDbFilePath, buffer); - } -} diff --git a/src/tools/ai/predict-all-post-category.ts b/src/tools/ai/predict-all-post-category.ts new file mode 100644 index 0000000000..87e198b39b --- /dev/null +++ b/src/tools/ai/predict-all-post-category.ts @@ -0,0 +1,57 @@ +const bayes = require('./naive-bayes.js'); +const MeCab = require('mecab-async'); + +import Post from '../../api/models/post'; +import config from '../../conf'; + +const classifier = bayes({ + tokenizer: this.tokenizer +}); + +const mecab = new MeCab(); +if (config.categorizer.mecab_command) mecab.command = config.categorizer.mecab_command; + +// 訓練データ取得 +Post.find({ + is_category_verified: true +}, { + fields: { + _id: false, + text: true, + category: true + } +}).then(verifiedPosts => { + // 学習 + verifiedPosts.forEach(post => { + classifier.learn(post.text, post.category); + }); + + // 全ての(人間によって証明されていない)投稿を取得 + Post.find({ + text: { + $exists: true + }, + is_category_verified: { + $ne: true + } + }, { + sort: { + _id: -1 + }, + fields: { + _id: true, + text: true + } + }).then(posts => { + posts.forEach(post => { + console.log(`predicting... ${post._id}`); + const category = classifier.categorize(post.text); + + Post.update({ _id: post._id }, { + $set: { + category: category + } + }); + }); + }); +}); diff --git a/src/tools/ai/predict-user-interst.ts b/src/tools/ai/predict-user-interst.ts new file mode 100644 index 0000000000..99bdfa4206 --- /dev/null +++ b/src/tools/ai/predict-user-interst.ts @@ -0,0 +1,45 @@ +import Post from '../../api/models/post'; +import User from '../../api/models/user'; + +export async function predictOne(id) { + console.log(`predict interest of ${id} ...`); + + // TODO: repostなども含める + const recentPosts = await Post.find({ + user_id: id, + category: { + $exists: true + } + }, { + sort: { + _id: -1 + }, + limit: 1000, + fields: { + _id: false, + category: true + } + }); + + const categories = {}; + + recentPosts.forEach(post => { + if (categories[post.category]) { + categories[post.category]++; + } else { + categories[post.category] = 1; + } + }); +} + +export async function predictAll() { + const allUsers = await User.find({}, { + fields: { + _id: true + } + }); + + allUsers.forEach(user => { + predictOne(user._id); + }); +} diff --git a/src/web/app/common/tags/post-menu.tag b/src/web/app/common/tags/post-menu.tag index 33895212bc..be4468a214 100644 --- a/src/web/app/common/tags/post-menu.tag +++ b/src/web/app/common/tags/post-menu.tag @@ -2,6 +2,18 @@
+
+ + +
+ + +

%i18n:mobile.tags.mk-user-overview-followers-you-know.loading%

0 }> From 98411aa64cf278d77b6ffe5eba19011a208212d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 7 Sep 2017 18:16:38 +0900 Subject: [PATCH 131/364] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f75549fcc..c19b889325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +unreleased +---------- +* New: 投稿することの多いキーワードをユーザーページに表示する (#768) + 2544 (2017/09/06) ----------------- * 投稿のカテゴリに関する実験的な実装 From 24983b6269f4ac07a4dec7e8812e5d726f7d1c70 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 7 Sep 2017 18:21:15 +0900 Subject: [PATCH 132/364] Fix --- locales/en.yml | 3 +++ locales/ja.yml | 3 +++ src/web/app/mobile/tags/user.tag | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/locales/en.yml b/locales/en.yml index 0af748aa69..05b4663c16 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -509,6 +509,9 @@ mobile: loading: "Loading" no-photos: "No photos" + mk-user-overview-keywords: + no-keywords: "No keywords" + mk-user-overview-followers-you-know: loading: "Loading" no-users: "No users" diff --git a/locales/ja.yml b/locales/ja.yml index 15f9e9db90..86da082723 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -509,6 +509,9 @@ mobile: loading: "読み込み中" no-photos: "写真はありません" + mk-user-overview-keywords: + no-keywords: "キーワードはありません(十分な数の投稿をしていない可能性があります)" + mk-user-overview-followers-you-know: loading: "読み込み中" no-users: "知り合いのユーザーはいません" diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index 06d4da9d3f..928e0188a9 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -552,7 +552,7 @@ { keyword }
-

%i18n:mobile.tags.mk-user-overview-followers-you-know.no-users%

+

%i18n:mobile.tags.mk-user-overview-keywords.no-keywords%

+ + +

%i18n:mobile.tags.mk-user-overview-followers-you-know.loading%

0 }> From 13a568889cabd36539b6205acbb0f9ce42b6419b Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Sep 2017 23:29:33 +0900 Subject: [PATCH 139/364] Implement #770 --- CHANGELOG.md | 1 + locales/en.yml | 5 + locales/ja.yml | 5 + src/api/endpoints.ts | 3 + .../users/get_frequently_replied_users.ts | 96 +++++++++++++++++++ src/web/app/mobile/tags/index.js | 1 + src/web/app/mobile/tags/init-following.tag | 54 +---------- src/web/app/mobile/tags/user-card.tag | 55 +++++++++++ src/web/app/mobile/tags/user.tag | 58 +++++++++++ 9 files changed, 228 insertions(+), 50 deletions(-) create mode 100644 src/api/endpoints/users/get_frequently_replied_users.ts create mode 100644 src/web/app/mobile/tags/user-card.tag diff --git a/CHANGELOG.md b/CHANGELOG.md index b071274d36..cf3d82f701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ChangeLog (Release Notes) unreleased ---------- * New: ユーザーページによく使うドメインを表示 (#771) +* New: よくリプライするユーザーをユーザーページに表示 (#770) 2566 (2017/09/07) ----------------- diff --git a/locales/en.yml b/locales/en.yml index fd07be2aed..a7dd3aea23 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -499,6 +499,7 @@ mobile: activity: "Activity" keywords: "Keywords" domains: "Domains" + frequently-replied-users: "Frequently talking users" followers-you-know: "Followers you know" last-used-at: "Latest used at" @@ -516,6 +517,10 @@ mobile: mk-user-overview-domains: no-domains: "No domains" + mk-user-overview-frequently-replied-users: + loading: "Loading" + no-users: "No users" + mk-user-overview-followers-you-know: loading: "Loading" no-users: "No users" diff --git a/locales/ja.yml b/locales/ja.yml index 832390f5fe..451650ef76 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -499,6 +499,7 @@ mobile: activity: "アクティビティ" keywords: "キーワード" domains: "頻出ドメイン" + frequently-replied-users: "よく会話するユーザー" followers-you-know: "知り合いのフォロワー" last-used-at: "最終ログイン" @@ -516,6 +517,10 @@ mobile: mk-user-overview-domains: no-domains: "よく表れるドメインは検出されませんでした" + mk-user-overview-frequently-replied-users: + loading: "読み込み中" + no-users: "よく会話するユーザーはいません" + mk-user-overview-followers-you-know: loading: "読み込み中" no-users: "知り合いのユーザーはいません" diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index 97b98895b8..f05762340c 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -326,6 +326,9 @@ const endpoints: Endpoint[] = [ withCredential: true, kind: 'account-read' }, + { + name: 'users/get_frequently_replied_users' + }, { name: 'following/create', diff --git a/src/api/endpoints/users/get_frequently_replied_users.ts b/src/api/endpoints/users/get_frequently_replied_users.ts new file mode 100644 index 0000000000..2e0e2e40a7 --- /dev/null +++ b/src/api/endpoints/users/get_frequently_replied_users.ts @@ -0,0 +1,96 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import Post from '../../models/post'; +import User from '../../models/user'; +import serialize from '../../serializers/user'; + +module.exports = (params, me) => new Promise(async (res, rej) => { + // Get 'user_id' parameter + const [userId, userIdErr] = $(params.user_id).id().$; + if (userIdErr) return rej('invalid user_id param'); + + // Lookup user + const user = await User.findOne({ + _id: userId + }, { + fields: { + _id: true + } + }); + + if (user === null) { + return rej('user not found'); + } + + // Fetch recent posts + const recentPosts = await Post.find({ + user_id: user._id, + reply_to_id: { + $exists: true, + $ne: null + } + }, { + sort: { + _id: -1 + }, + limit: 1000, + fields: { + _id: false, + reply_to_id: true + } + }); + + // 投稿が少なかったら中断 + if (recentPosts.length === 0) { + return res([]); + } + + const replyTargetPosts = await Post.find({ + _id: { + $in: recentPosts.map(p => p.reply_to_id) + }, + user_id: { + $ne: user._id + } + }, { + fields: { + _id: false, + user_id: true + } + }); + + const repliedUsers = {}; + + // Extract replies from recent posts + replyTargetPosts.forEach(post => { + const userId = post.user_id.toString(); + if (repliedUsers[userId]) { + repliedUsers[userId]++; + } else { + repliedUsers[userId] = 1; + } + }); + + // Calc peak + let peak = 0; + Object.keys(repliedUsers).forEach(user => { + if (repliedUsers[user] > peak) peak = repliedUsers[user]; + }); + + // Sort replies by frequency + const repliedUsersSorted = Object.keys(repliedUsers).sort((a, b) => repliedUsers[b] - repliedUsers[a]); + + // Lookup top 10 replies + const topRepliedUsers = repliedUsersSorted.slice(0, 10); + + // Make replies object (includes weights) + const repliesObj = await Promise.all(topRepliedUsers.map(async (user) => ({ + user: await serialize(user, me, { detail: true }), + weight: repliedUsers[user] / peak + }))); + + // Response + res(repliesObj); +}); diff --git a/src/web/app/mobile/tags/index.js b/src/web/app/mobile/tags/index.js index 6f985a91fd..c5aafd20ba 100644 --- a/src/web/app/mobile/tags/index.js +++ b/src/web/app/mobile/tags/index.js @@ -49,3 +49,4 @@ require('./users-list.tag'); require('./user-following.tag'); require('./user-followers.tag'); require('./init-following.tag'); +require('./user-card.tag'); diff --git a/src/web/app/mobile/tags/init-following.tag b/src/web/app/mobile/tags/init-following.tag index d0b63ff5db..6357f86a29 100644 --- a/src/web/app/mobile/tags/init-following.tag +++ b/src/web/app/mobile/tags/init-following.tag @@ -1,16 +1,9 @@

気になるユーザーをフォロー:

0 }> -
-
- - avatar - -
- { name } -

@{ username }

- -
+ + +

おすすめのユーザーは見つかりませんでした。

読み込んでいます

@@ -37,49 +30,10 @@ padding 16px background #eee - > .user - display inline-block - width 200px - text-align center - border-radius 8px - background #fff - + > mk-user-card &:not(:last-child) margin-right 16px - > header - display block - height 80px - background-color #ddd - background-size cover - background-position center - border-radius 8px 8px 0 0 - - > a - > img - position absolute - top 20px - left calc(50% - 40px) - width 80px - height 80px - border solid 2px #fff - border-radius 8px - - > .name - display block - margin 24px 0 0 0 - font-size 16px - color #555 - - > .username - margin 0 - font-size 15px - color #ccc - - > mk-follow-button - display inline-block - margin 8px 0 16px 0 - > .empty margin 0 padding 16px diff --git a/src/web/app/mobile/tags/user-card.tag b/src/web/app/mobile/tags/user-card.tag new file mode 100644 index 0000000000..d0c79698c5 --- /dev/null +++ b/src/web/app/mobile/tags/user-card.tag @@ -0,0 +1,55 @@ + +
+ + avatar + +
+ { user.name } +

@{ user.username }

+ + + +
diff --git a/src/web/app/mobile/tags/user.tag b/src/web/app/mobile/tags/user.tag index a323559218..f29f0a0c86 100644 --- a/src/web/app/mobile/tags/user.tag +++ b/src/web/app/mobile/tags/user.tag @@ -246,6 +246,12 @@
+
+

%i18n:mobile.tags.mk-user-overview.frequently-replied-users%

+
+ +
+

%i18n:mobile.tags.mk-user-overview.followers-you-know%

@@ -619,6 +625,58 @@ + +

%i18n:mobile.tags.mk-user-overview-frequently-replied-users.loading%

+
0 }> + + + +
+

%i18n:mobile.tags.mk-user-overview-frequently-replied-users.no-users%

+ + +
+

%i18n:mobile.tags.mk-user-overview-followers-you-know.loading%

0 }> From c3ab70b021393435b403b69e30628e03002bffad Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Sep 2017 23:30:40 +0900 Subject: [PATCH 140/364] v2584 --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf3d82f701..c45400f884 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます -unreleased ----------- +2584 (2017/09/08) +----------------- * New: ユーザーページによく使うドメインを表示 (#771) * New: よくリプライするユーザーをユーザーページに表示 (#770) diff --git a/package.json b/package.json index e3a5ae6395..0dbfa1a10c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2566", + "version": "0.0.2584", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From 1323a08a5f1d09986dc834d6f83ed9201f6188a5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Sep 2017 02:58:36 +0900 Subject: [PATCH 141/364] Fix English --- locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.yml b/locales/en.yml index a7dd3aea23..1df3001e5a 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -501,7 +501,7 @@ mobile: domains: "Domains" frequently-replied-users: "Frequently talking users" followers-you-know: "Followers you know" - last-used-at: "Latest used at" + last-used-at: "Last used at" mk-user-overview-posts: loading: "Loading" 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 142/364] 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 143/364] 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 144/364] 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 145/364] 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 146/364] 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 147/364] 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 148/364] 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 149/364] 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 150/364] 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 151/364] 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 152/364] 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 153/364] 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 154/364] 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 155/364] 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 156/364] 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 157/364] 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 158/364] 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 159/364] 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; } From a12cc1a1b067745695bd6f55defe5eb2d7400da0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Sep 2017 17:31:37 +0900 Subject: [PATCH 160/364] Refactoring --- src/api/private/signin.ts | 4 ++-- src/api/private/signup.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/private/signin.ts b/src/api/private/signin.ts index afa83e50c3..c7dc243980 100644 --- a/src/api/private/signin.ts +++ b/src/api/private/signin.ts @@ -1,6 +1,6 @@ import * as express from 'express'; import * as bcrypt from 'bcryptjs'; -import User from '../models/user'; +import { default as User, IUser } from '../models/user'; import Signin from '../models/signin'; import serialize from '../serializers/signin'; import event from '../event'; @@ -23,7 +23,7 @@ export default async (req: express.Request, res: express.Response) => { } // Fetch user - const user = await User.findOne({ + const user: IUser = await User.findOne({ username_lower: username.toLowerCase() }, { fields: { diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index 899fa88472..bcc17a876d 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -1,7 +1,7 @@ import * as express from 'express'; import * as bcrypt from 'bcryptjs'; import recaptcha = require('recaptcha-promise'); -import User from '../models/user'; +import { default as User, IUser } from '../models/user'; import { validateUsername, validatePassword } from '../models/user'; import serialize from '../serializers/user'; import generateUserToken from '../common/generate-native-user-token'; @@ -61,7 +61,7 @@ export default async (req: express.Request, res: express.Response) => { const secret = generateUserToken(); // Create account - const account = await User.insert({ + const account: IUser = await User.insert({ token: secret, avatar_id: null, banner_id: null, From 6c5960811a616d0ef230471d91a716a9464498ac Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 17 Sep 2017 15:09:51 +0000 Subject: [PATCH 161/364] fix(package): update animejs to version 2.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d72a10ee92..675bc2a8c9 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ }, "dependencies": { "accesses": "2.5.0", - "animejs": "2.0.2", + "animejs": "2.1.0", "autwh": "0.0.1", "bcryptjs": "2.4.3", "body-parser": "1.18.1", From df340e6aba8f40736d37dea5553443da451ac58a Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 18 Sep 2017 14:15:58 +0000 Subject: [PATCH 162/364] chore(package): update @types/morgan to version 1.7.33 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 675bc2a8c9..2e39cfeca7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@types/mocha": "2.2.43", "@types/mongodb": "2.2.11", "@types/monk": "1.0.6", - "@types/morgan": "1.7.32", + "@types/morgan": "1.7.33", "@types/ms": "0.7.30", "@types/multer": "1.3.2", "@types/node": "8.0.28", From 731c6d22a0da2ffbf6eb3883f98677e26840d575 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 18 Sep 2017 15:06:23 +0000 Subject: [PATCH 163/364] fix(package): update inquirer to version 3.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 675bc2a8c9..f094ae73fe 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "file-type": "6.1.0", "fuckadblock": "3.2.1", "gm": "1.23.0", - "inquirer": "3.2.3", + "inquirer": "3.3.0", "is-root": "1.0.0", "is-url": "1.2.2", "js-yaml": "3.10.0", From 9ae042f9dd5ff924687493e9a3728f2cb983aef4 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 18 Sep 2017 23:35:10 +0000 Subject: [PATCH 164/364] fix(package): update cafy to version 3.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 675bc2a8c9..54ad789558 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "autwh": "0.0.1", "bcryptjs": "2.4.3", "body-parser": "1.18.1", - "cafy": "2.4.0", + "cafy": "3.0.0", "chalk": "2.1.0", "compression": "1.7.0", "cors": "2.8.4", From 5ad34defa7bddffbd450bf0632860d27bee40e4c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 19 Sep 2017 18:19:06 +0000 Subject: [PATCH 165/364] chore(package): update @types/webpack to version 3.0.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54ad789558..fe08fdb823 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", "@types/uuid": "3.4.2", - "@types/webpack": "3.0.10", + "@types/webpack": "3.0.11", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", "chai": "4.1.2", From 6417dd19347e7f443ec7c39d83bba69d685155f5 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 19 Sep 2017 20:25:22 +0000 Subject: [PATCH 166/364] fix(package): update request to version 2.82.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54ad789558..c58bdca414 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "recaptcha-promise": "0.1.3", "reconnecting-websocket": "3.2.1", "redis": "2.8.0", - "request": "2.81.0", + "request": "2.82.0", "rimraf": "2.6.2", "riot": "3.7.0", "rndstr": "1.0.0", From bd1e09713ebb65d19f20cdb129b22fe81ea389f1 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 21 Sep 2017 21:35:51 +0000 Subject: [PATCH 167/364] chore(package): update @types/node to version 8.0.29 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a22decef9b..d8b505505e 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.28", + "@types/node": "8.0.29", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.3", From 5cf72dcf9b7c04175c398ab01e9b4b0dc4b763ea Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 22 Sep 2017 17:04:18 +0000 Subject: [PATCH 168/364] fix(package): update body-parser to version 1.18.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8b505505e..ddda43cf23 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "animejs": "2.1.0", "autwh": "0.0.1", "bcryptjs": "2.4.3", - "body-parser": "1.18.1", + "body-parser": "1.18.2", "cafy": "3.0.0", "chalk": "2.1.0", "compression": "1.7.0", From e90cc4eb0a5a6901108394f6f2c58df3a33fcc1b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 22 Sep 2017 18:07:47 +0000 Subject: [PATCH 169/364] chore(package): update @types/node to version 8.0.30 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8b505505e..3c8c0f92a8 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.29", + "@types/node": "8.0.30", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.3", From 6846dab586b7ec30d623820a23767f3898941bcb Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 23 Sep 2017 10:32:59 +0000 Subject: [PATCH 170/364] fix(package): update file-type to version 6.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8b505505e..171998c9a7 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "elasticsearch": "13.3.1", "escape-regexp": "0.0.1", "express": "4.15.4", - "file-type": "6.1.0", + "file-type": "6.2.0", "fuckadblock": "3.2.1", "gm": "1.23.0", "inquirer": "3.3.0", From 03166c8f2d63841ac811b199066db4eccd9a44cd Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 23 Sep 2017 14:29:19 +0000 Subject: [PATCH 171/364] fix(package): update riot to version 3.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d67256106..0df1c99433 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "redis": "2.8.0", "request": "2.82.0", "rimraf": "2.6.2", - "riot": "3.7.0", + "riot": "3.7.2", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.4", From 9d345a68c3a28f9ff09770d9b01630f9d93f162c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 23 Sep 2017 17:21:57 +0000 Subject: [PATCH 172/364] fix(package): update reconnecting-websocket to version 3.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0df1c99433..7e517a8096 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "pug": "2.0.0-rc.4", "ratelimiter": "3.0.3", "recaptcha-promise": "0.1.3", - "reconnecting-websocket": "3.2.1", + "reconnecting-websocket": "3.2.2", "redis": "2.8.0", "request": "2.82.0", "rimraf": "2.6.2", From 2431b503bf00f18dc125537abe2b28d905b182e9 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 25 Sep 2017 17:10:52 +0000 Subject: [PATCH 173/364] fix(package): update animejs to version 2.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e517a8096..4d51475609 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ }, "dependencies": { "accesses": "2.5.0", - "animejs": "2.1.0", + "animejs": "2.2.0", "autwh": "0.0.1", "bcryptjs": "2.4.3", "body-parser": "1.18.2", From 3fb047e23937e85fde5a04d4b9b705c13a2e71a6 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 25 Sep 2017 19:42:45 +0000 Subject: [PATCH 174/364] chore(package): update @types/webpack to version 3.0.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d51475609..89b5a54b9d 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", "@types/uuid": "3.4.2", - "@types/webpack": "3.0.11", + "@types/webpack": "3.0.12", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", "chai": "4.1.2", From 47ad9599752e06382ac58cde8b4c90de4e91e409 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 25 Sep 2017 21:27:51 +0000 Subject: [PATCH 175/364] chore(package): update @types/node to version 8.0.31 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d51475609..f50c9c8b23 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.30", + "@types/node": "8.0.31", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.3", From 4c5f9cc83012f62ed9e92f6b185b9c62769dee96 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 26 Sep 2017 17:46:57 +0000 Subject: [PATCH 176/364] fix(package): update serve-favicon to version 2.4.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d51475609..0a437eefb4 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,7 @@ "riot": "3.7.2", "rndstr": "1.0.0", "s-age": "1.1.0", - "serve-favicon": "2.4.4", + "serve-favicon": "2.4.5", "summaly": "2.0.3", "syuilo-password-strength": "0.0.1", "tcp-port-used": "0.1.2", From 7b559ac8d4142b9c1ca3c5c37bcd00ae739858fd Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 26 Sep 2017 20:35:17 +0000 Subject: [PATCH 177/364] fix(package): update debug to version 3.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a437eefb4..88b111fcd8 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "cors": "2.8.4", "cropperjs": "1.0.0", "crypto": "1.0.1", - "debug": "3.0.1", + "debug": "3.1.0", "deep-equal": "1.0.1", "deepcopy": "0.6.3", "diskusage": "^0.2.2", From c321dac1edf1ac86fb549a1169869846bce4ef2f Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 27 Sep 2017 00:17:46 +0000 Subject: [PATCH 178/364] fix(package): update typescript to version 2.5.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a437eefb4..4cb3ed3545 100644 --- a/package.json +++ b/package.json @@ -148,7 +148,7 @@ "tcp-port-used": "0.1.2", "textarea-caret": "3.0.2", "ts-node": "3.3.0", - "typescript": "2.5.2", + "typescript": "2.5.3", "uuid": "3.1.0", "vhost": "3.0.2", "websocket": "1.0.24", From 10a2e981e943777d21508ed493808c6c48353258 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 27 Sep 2017 02:57:50 +0000 Subject: [PATCH 179/364] fix(package): update morgan to version 1.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a437eefb4..14d1f84c3e 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "moji": "^0.5.1", "mongodb": "2.2.31", "monk": "6.0.4", - "morgan": "1.8.2", + "morgan": "1.9.0", "ms": "2.0.0", "multer": "1.3.0", "nprogress": "0.2.0", From 589ff5c01de0a69af70b9ab2f54f5ebd6859fab5 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 27 Sep 2017 05:03:33 +0000 Subject: [PATCH 180/364] fix(package): update request to version 2.83.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a437eefb4..fd1592c6a9 100644 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "recaptcha-promise": "0.1.3", "reconnecting-websocket": "3.2.2", "redis": "2.8.0", - "request": "2.82.0", + "request": "2.83.0", "rimraf": "2.6.2", "riot": "3.7.2", "rndstr": "1.0.0", From 1fe1e8d8bfabf46bc69f8bdf1efa19e1b18c1d5c Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 27 Sep 2017 05:46:08 +0000 Subject: [PATCH 181/364] fix(package): update compression to version 1.7.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a437eefb4..74dca61224 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "body-parser": "1.18.2", "cafy": "3.0.0", "chalk": "2.1.0", - "compression": "1.7.0", + "compression": "1.7.1", "cors": "2.8.4", "cropperjs": "1.0.0", "crypto": "1.0.1", From 98e6ce6d6a1ebf31ccb2b1748deae671f8222a70 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 28 Sep 2017 07:55:56 +0000 Subject: [PATCH 182/364] chore(package): update @types/elasticsearch to version 5.0.17 Closes #698 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0a437eefb4..4552041115 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@types/cors": "2.8.1", "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", - "@types/elasticsearch": "5.0.14", + "@types/elasticsearch": "5.0.17", "@types/event-stream": "3.3.32", "@types/express": "4.0.37", "@types/gm": "1.17.32", From 93b3c7cd0c0ce020183ed3ba112984b184215680 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 1 Oct 2017 09:40:22 +0000 Subject: [PATCH 183/364] fix(package): update riot to version 3.7.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb0987b25..22bf817929 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "redis": "2.8.0", "request": "2.83.0", "rimraf": "2.6.2", - "riot": "3.7.2", + "riot": "3.7.3", "rndstr": "1.0.0", "s-age": "1.1.0", "serve-favicon": "2.4.5", From 5daf490224b3d4fa69718e065d3739ef0b8c0d7a Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 3 Oct 2017 12:17:24 +0000 Subject: [PATCH 184/364] chore(package): update style-loader to version 0.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb0987b25..0f34c09fbd 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "mocha": "3.5.3", "riot-tag-loader": "1.0.0", "string-replace-webpack-plugin": "0.1.3", - "style-loader": "0.18.2", + "style-loader": "0.19.0", "stylus": "0.54.5", "stylus-loader": "3.0.1", "swagger-jsdoc": "1.9.7", From c3fcdd2c9a4726933babf7ef56e4665ecd813e3b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 3 Oct 2017 14:28:12 +0000 Subject: [PATCH 185/364] chore(package): update @types/mongodb to version 2.2.12 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb0987b25..69aaa8ff2f 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@types/is-url": "1.2.28", "@types/js-yaml": "3.9.0", "@types/mocha": "2.2.43", - "@types/mongodb": "2.2.11", + "@types/mongodb": "2.2.12", "@types/monk": "1.0.6", "@types/morgan": "1.7.33", "@types/ms": "0.7.30", From 8473a627838b3c2ff1ebaaa90ecf47cd64efd229 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 3 Oct 2017 15:36:39 +0000 Subject: [PATCH 186/364] chore(package): update @types/node to version 8.0.32 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb0987b25..08b35dd2e9 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@types/morgan": "1.7.33", "@types/ms": "0.7.30", "@types/multer": "1.3.2", - "@types/node": "8.0.31", + "@types/node": "8.0.32", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", "@types/request": "2.0.3", From 132c14d93eaec80d7fca4e866774c71fe226299d Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 3 Oct 2017 18:26:58 +0000 Subject: [PATCH 187/364] chore(package): update @types/webpack to version 3.0.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb0987b25..30401757e7 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", "@types/uuid": "3.4.2", - "@types/webpack": "3.0.12", + "@types/webpack": "3.0.13", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", "chai": "4.1.2", From a8a91c4be761d5a62bc26519b16b021e895aa775 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 4 Oct 2017 18:28:21 +0000 Subject: [PATCH 188/364] chore(package): update @types/request to version 2.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb0987b25..bb7cbc3a65 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/node": "8.0.31", "@types/ratelimiter": "2.1.28", "@types/redis": "2.6.0", - "@types/request": "2.0.3", + "@types/request": "2.0.4", "@types/rimraf": "2.0.0", "@types/riot": "3.6.0", "@types/serve-favicon": "2.2.28", From 852a302ce76be2b2b0535cc35c1364ebb57f1237 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 6 Oct 2017 10:29:37 +0000 Subject: [PATCH 189/364] chore(package): update gulp-imagemin to version 3.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b56f97c797..cb23269479 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "event-stream": "3.3.4", "gulp": "3.9.1", "gulp-cssnano": "2.1.2", - "gulp-imagemin": "3.3.0", + "gulp-imagemin": "3.4.0", "gulp-htmlmin": "3.0.0", "gulp-mocha": "4.3.1", "gulp-pug": "3.3.0", From aa5ca06830e8848fb213cd179c304990f01561a3 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 6 Oct 2017 17:26:20 +0000 Subject: [PATCH 190/364] chore(package): update @types/mongodb to version 2.2.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cb23269479..0336725bda 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@types/is-url": "1.2.28", "@types/js-yaml": "3.9.0", "@types/mocha": "2.2.43", - "@types/mongodb": "2.2.12", + "@types/mongodb": "2.2.13", "@types/monk": "1.0.6", "@types/morgan": "1.7.33", "@types/ms": "0.7.30", From 6a5c6280ffd3ffe820beb23294f1c2c1f5deb9cf Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Oct 2017 03:36:46 +0900 Subject: [PATCH 191/364] :v: --- src/api/bot/core.ts | 88 +++++++++++++++++++ src/api/bot/interfaces/line.ts | 37 ++++++++ src/api/endpoints/i/appdata/set.ts | 2 +- src/api/models/user.ts | 3 + src/api/serializers/user.ts | 1 + src/api/server.ts | 2 + .../scripts => common}/get-post-summary.js | 4 + src/config.ts | 3 + src/web/app/desktop/script.js | 2 +- src/web/app/desktop/tags/notifications.tag | 2 +- src/web/app/desktop/tags/pages/home.tag | 2 +- .../app/mobile/tags/notification-preview.tag | 2 +- src/web/app/mobile/tags/notification.tag | 2 +- src/web/app/mobile/tags/notifications.tag | 2 +- src/web/app/mobile/tags/page/home.tag | 2 +- src/web/app/mobile/tags/post-detail.tag | 2 +- src/web/app/mobile/tags/timeline.tag | 2 +- src/web/app/mobile/tags/user.tag | 2 +- tslint.json | 1 + 19 files changed, 150 insertions(+), 11 deletions(-) create mode 100644 src/api/bot/core.ts create mode 100644 src/api/bot/interfaces/line.ts rename src/{web/app/common/scripts => common}/get-post-summary.js (88%) diff --git a/src/api/bot/core.ts b/src/api/bot/core.ts new file mode 100644 index 0000000000..002ac1b06e --- /dev/null +++ b/src/api/bot/core.ts @@ -0,0 +1,88 @@ +import * as EventEmitter from 'events'; +import * as bcrypt from 'bcryptjs'; + +import User, { IUser } from '../models/user'; + +export default class BotCore extends EventEmitter { + public user: IUser; + + private context: Context = null; + + constructor(user: IUser) { + super(); + + this.user = user; + } + + public async q(query: string): Promise { + if (this.context != null) { + return await this.context.q(query); + } + + switch (query) { + case 'ping': + return 'PONG'; + case 'ログイン': + case 'サインイン': + this.context = new SigninContext(this); + return await this.context.greet(); + default: + return '?'; + } + } + + public setUser(user: IUser) { + this.user = user; + this.emit('set-user', user); + } +} + +abstract class Context { + protected core: BotCore; + + public abstract async greet(): Promise; + public abstract async q(query: string): Promise; + + constructor(core: BotCore) { + this.core = core; + } +} + +class SigninContext extends Context { + private temporaryUser: IUser; + + public async greet(): Promise { + return 'まずユーザー名を教えてください:'; + } + + public async q(query: string): Promise { + if (this.temporaryUser == null) { + // Fetch user + const user: IUser = await User.findOne({ + username_lower: query.toLowerCase() + }, { + fields: { + data: false, + profile: false + } + }); + + if (user === null) { + return `${query}というユーザーは存在しませんでした... もう一度教えてください:`; + } else { + this.temporaryUser = user; + return `パスワードを教えてください:`; + } + } else { + // Compare password + const same = bcrypt.compareSync(query, this.temporaryUser.password); + + if (same) { + this.core.setUser(this.temporaryUser); + return `${this.temporaryUser.name}さん、おかえりなさい!`; + } else { + return `パスワードが違います... もう一度教えてください:`; + } + } + } +} diff --git a/src/api/bot/interfaces/line.ts b/src/api/bot/interfaces/line.ts new file mode 100644 index 0000000000..4bee844c12 --- /dev/null +++ b/src/api/bot/interfaces/line.ts @@ -0,0 +1,37 @@ +import * as EventEmitter from 'events'; +import * as express from 'express'; +import * as crypto from 'crypto'; +//import User from '../../models/user'; +import config from '../../../conf'; +/*import BotCore from '../core'; + +const sessions: { + userId: string; + session: BotCore; +}[] = []; +*/ +module.exports = async (app: express.Application) => { + if (config.line_bot == null) return; + + const handler = new EventEmitter(); + + app.post('/hooks/line', (req, res, next) => { + // req.headers['X-Line-Signature'] は常に string ですが、型定義の都合上 + // string | string[] になっているので string を明示しています + const sig1 = req.headers['X-Line-Signature'] as string; + + const hash = crypto.createHmac('sha256', config.line_bot.channel_secret) + .update(JSON.stringify(req.body)); + + const sig2 = hash.digest('base64'); + + // シグネチャ比較 + if (sig1 === sig2) { + console.log(req.body); + handler.emit(req.body.type); + res.sendStatus(200); + } else { + res.sendStatus(400); + } + }); +}; diff --git a/src/api/endpoints/i/appdata/set.ts b/src/api/endpoints/i/appdata/set.ts index 24f192de6b..9c3dbe185b 100644 --- a/src/api/endpoints/i/appdata/set.ts +++ b/src/api/endpoints/i/appdata/set.ts @@ -21,7 +21,7 @@ module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) = const [data, dataError] = $(params.data).optional.object() .pipe(obj => { const hasInvalidData = Object.entries(obj).some(([k, v]) => - $(k).string().match(/^[a-z_]+$/).isNg() && $(v).string().isNg()); + $(k).string().match(/^[a-z_]+$/).nok() && $(v).string().nok()); return !hasInvalidData; }).$; if (dataError) return rej('invalid data param'); diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 1591b339bc..4f8086d42b 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -57,6 +57,9 @@ export type IUser = { user_id: string; screen_name: string; }; + line: { + user_id: string; + }; description: string; profile: { location: string; diff --git a/src/api/serializers/user.ts b/src/api/serializers/user.ts index 23a176096a..3deff2d003 100644 --- a/src/api/serializers/user.ts +++ b/src/api/serializers/user.ts @@ -79,6 +79,7 @@ export default ( delete _user.twitter.access_token; delete _user.twitter.access_token_secret; } + delete _user.line; // Visible via only the official client if (!opts.includeSecrets) { diff --git a/src/api/server.ts b/src/api/server.ts index c98167eb3e..fdff0c7546 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -54,4 +54,6 @@ app.use((req, res, next) => { require('./service/github')(app); require('./service/twitter')(app); +require('./bot/interfaces/line')(app); + module.exports = app; diff --git a/src/web/app/common/scripts/get-post-summary.js b/src/common/get-post-summary.js similarity index 88% rename from src/web/app/common/scripts/get-post-summary.js rename to src/common/get-post-summary.js index 83eda8f6b4..f7a481a164 100644 --- a/src/web/app/common/scripts/get-post-summary.js +++ b/src/common/get-post-summary.js @@ -1,3 +1,7 @@ +/** + * 投稿を表す文字列を取得します。 + * @param {*} post 投稿 + */ const summarize = post => { let summary = post.text ? post.text : ''; diff --git a/src/config.ts b/src/config.ts index f8facdee2e..0ea332f67d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -68,6 +68,9 @@ type Source = { hook_secret: string; username: string; }; + line_bot?: { + channel_secret: string; + }; analysis?: { mecab_command?: string; }; diff --git a/src/web/app/desktop/script.js b/src/web/app/desktop/script.js index 2e81147943..e3dc8b7d96 100644 --- a/src/web/app/desktop/script.js +++ b/src/web/app/desktop/script.js @@ -11,7 +11,7 @@ import * as riot from 'riot'; import init from '../init'; import route from './router'; import fuckAdBlock from './scripts/fuck-ad-block'; -import getPostSummary from '../common/scripts/get-post-summary'; +import getPostSummary from '../../../common/get-post-summary'; /** * init diff --git a/src/web/app/desktop/tags/notifications.tag b/src/web/app/desktop/tags/notifications.tag index 21e4fe7fa5..4747d1c0f4 100644 --- a/src/web/app/desktop/tags/notifications.tag +++ b/src/web/app/desktop/tags/notifications.tag @@ -207,7 +207,7 @@ diff --git a/src/web/app/mobile/tags/notification.tag b/src/web/app/mobile/tags/notification.tag index 3663709525..416493ee23 100644 --- a/src/web/app/mobile/tags/notification.tag +++ b/src/web/app/mobile/tags/notification.tag @@ -163,7 +163,7 @@ diff --git a/src/web/app/mobile/tags/notifications.tag b/src/web/app/mobile/tags/notifications.tag index 2f314769db..9985b3351c 100644 --- a/src/web/app/mobile/tags/notifications.tag +++ b/src/web/app/mobile/tags/notifications.tag @@ -78,7 +78,7 @@ diff --git a/src/web/app/mobile/tags/notification.tag b/src/web/app/mobile/tags/notification.tag index 416493ee23..53222b9dbe 100644 --- a/src/web/app/mobile/tags/notification.tag +++ b/src/web/app/mobile/tags/notification.tag @@ -163,7 +163,7 @@ diff --git a/src/web/app/mobile/tags/notifications.tag b/src/web/app/mobile/tags/notifications.tag index 9985b3351c..7370aa84d3 100644 --- a/src/web/app/mobile/tags/notifications.tag +++ b/src/web/app/mobile/tags/notifications.tag @@ -78,7 +78,7 @@ From ce471edf2d01ad270635701529096861995d0024 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 22 Oct 2017 15:23:23 +0900 Subject: [PATCH 243/364] v2735 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58ec237093..ba307ece92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2735 (2017/10/22) +----------------- +* モバイル版からでもクライアントバージョンを確認できるように + 2732 (2017/10/22) ----------------- * 依存関係の更新など diff --git a/package.json b/package.json index befa8b2b4e..4ddb3cb451 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2732", + "version": "0.0.2735", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From 28938b40a4940f8c09619289b64cc75bca2947f0 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: Sun, 22 Oct 2017 16:36:58 +0900 Subject: [PATCH 244/364] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3aeac828e3..4eeac44f5e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ and more! You can touch with your own eyes at https://misskey.xyz/. Setup and Installation ---------------------------------------------------------------- -Please see [Setup and installation guide](./docs/setup.en.md). +If you want to create your Misskey instance, +please see [Setup and installation guide](./docs/setup.en.md). Contribution ---------------------------------------------------------------- From 8bbf2c98e2590f314cee6e459be601797273df9d Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Mon, 23 Oct 2017 02:38:32 +0000 Subject: [PATCH 245/364] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4eeac44f5e..b777618f46 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ and more! You can touch with your own eyes at https://misskey.xyz/. Setup and Installation ---------------------------------------------------------------- -If you want to create your Misskey instance, +If you want to run your own instance of Misskey, please see [Setup and installation guide](./docs/setup.en.md). Contribution From fdcff509d48081bdf58291f9c383b0ab8273c280 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 24 Oct 2017 02:40:07 +0000 Subject: [PATCH 246/364] chore(package): update uglifyjs-webpack-plugin to version 1.0.1 Closes #841 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ddb3cb451..0b990ea40f 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "tslint": "5.7.0", "uglify-es": "3.0.27", "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony", - "uglifyjs-webpack-plugin": "1.0.0-beta.2", + "uglifyjs-webpack-plugin": "1.0.1", "webpack": "3.8.1" }, "dependencies": { From 7d95989fa03021fbaf163d661afb144ba580161e Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 24 Oct 2017 04:31:04 +0000 Subject: [PATCH 247/364] fix(package): update chalk to version 2.3.0 Closes #833 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ddb3cb451..2284bb01b0 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "bcryptjs": "2.4.3", "body-parser": "1.18.2", "cafy": "3.0.0", - "chalk": "2.1.0", + "chalk": "2.3.0", "compression": "1.7.1", "cors": "2.8.4", "cropperjs": "1.1.3", From 27f98578c527a1a73c45be228eb979436d2e5ec3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 25 Oct 2017 08:01:20 +0900 Subject: [PATCH 248/364] :v: --- locales/en.yml | 2 +- locales/ja.yml | 2 +- src/web/app/common/tags/error.tag | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 1df3001e5a..d4dfbf76bf 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -64,7 +64,7 @@ common: mk-error: title: "Unable to connect to the server" - description: "インターネット回線に問題があるか、サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから再度お試しください。" + description: "There is a problem with Internet connection, or the server may be down or maintaining. Please {try again} later." thanks: "Thank you for using Misskey." mk-forkit: diff --git a/locales/ja.yml b/locales/ja.yml index 451650ef76..9a8490deca 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -64,7 +64,7 @@ common: mk-error: title: "サーバーに接続できません" - description: "インターネット回線に問題があるか、サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから再度お試しください。" + description: "インターネット回線に問題があるか、サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから{再度お試し}ください。" thanks: "いつもMisskeyをご利用いただきありがとうございます。" mk-forkit: diff --git a/src/web/app/common/tags/error.tag b/src/web/app/common/tags/error.tag index a06f17cd1c..7a2976541d 100644 --- a/src/web/app/common/tags/error.tag +++ b/src/web/app/common/tags/error.tag @@ -1,7 +1,13 @@

%i18n:common.tags.mk-error.title%

-

%i18n:common.tags.mk-error.description%

+

{ + '%i18n:common.tags.mk-error.description%'.substr(0, '%i18n:common.tags.mk-error.description%'.indexOf('{')) + }{ + '%i18n:common.tags.mk-error.description%'.match(/\{(.+?)\}/)[1] + }{ + '%i18n:common.tags.mk-error.description%'.substr('%i18n:common.tags.mk-error.description%'.indexOf('}') + 1) + }

%i18n:common.tags.mk-error.thanks%

+ + +

%i18n:common.tags.mk-error.troubleshooter.title%

+
+

{ network == null ? '%i18n:common.tags.mk-error.troubleshooter.checking-network%' : '%i18n:common.tags.mk-error.troubleshooter.network%' }

+

{ internet == null ? '%i18n:common.tags.mk-error.troubleshooter.checking-internet%' : '%i18n:common.tags.mk-error.troubleshooter.internet%' }

+

{ server == null ? '%i18n:common.tags.mk-error.troubleshooter.checking-server%' : '%i18n:common.tags.mk-error.troubleshooter.server%' }

+
+

%i18n:common.tags.mk-error.troubleshooter.finding%

+

%i18n:common.tags.mk-error.troubleshooter.no-network%
%i18n:common.tags.mk-error.troubleshooter.no-network-desc%

+

%i18n:common.tags.mk-error.troubleshooter.no-internet%
%i18n:common.tags.mk-error.troubleshooter.no-internet-desc%

+

%i18n:common.tags.mk-error.troubleshooter.no-server%
%i18n:common.tags.mk-error.troubleshooter.no-server-desc%

+

%i18n:common.tags.mk-error.troubleshooter.success%
%i18n:common.tags.mk-error.troubleshooter.success-desc%

+ + + +
From cc1dbf771249c709805f48271ab7c165bfea1da3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 25 Oct 2017 17:57:30 +0900 Subject: [PATCH 253/364] v2742 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba307ece92..675ffe62ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2742 (2017/10/25) +----------------- +* トラブルシューティングを実装するなど + 2735 (2017/10/22) ----------------- * モバイル版からでもクライアントバージョンを確認できるように diff --git a/package.json b/package.json index 4ddb3cb451..1f604b9ce1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2735", + "version": "0.0.2742", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From e581ce3014d52579877743b29b348e220f4c734a Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 25 Oct 2017 20:27:24 +0900 Subject: [PATCH 254/364] =?UTF-8?q?=E3=83=A1=E3=82=B8=E3=83=A3=E3=83=BC?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=92=E6=98=8E?= =?UTF-8?q?=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/app/desktop/tags/home-widgets/version.tag | 2 +- src/web/app/mobile/tags/page/settings.tag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web/app/desktop/tags/home-widgets/version.tag b/src/web/app/desktop/tags/home-widgets/version.tag index fa92afc49f..ea5307061c 100644 --- a/src/web/app/desktop/tags/home-widgets/version.tag +++ b/src/web/app/desktop/tags/home-widgets/version.tag @@ -1,5 +1,5 @@ -

ver { version }

+

ver { version } (葵 aoi)

+ + diff --git a/src/web/app/desktop/tags/ui.tag b/src/web/app/desktop/tags/ui.tag index e0d7393b08..452a72c00a 100644 --- a/src/web/app/desktop/tags/ui.tag +++ b/src/web/app/desktop/tags/ui.tag @@ -319,18 +319,26 @@ -
    -
  • - - -

    %i18n:desktop.tags.mk-ui-header-nav.home%

    -
    -
  • -
  • - - -

    %i18n:desktop.tags.mk-ui-header-nav.messaging%

    - +
      + +
    • + + +

      %i18n:desktop.tags.mk-ui-header-nav.home%

      +
      +
    • +
    • + + +

      %i18n:desktop.tags.mk-ui-header-nav.messaging%

      + +
      +
    • + +
    • + + +

      %i18n:desktop.tags.mk-ui-header-nav.bbs%

    • From caa47cb38cfc3950539c78ca2e70f2c50e815d2c Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 30 Oct 2017 22:12:10 +0900 Subject: [PATCH 273/364] =?UTF-8?q?=E6=9C=AA=E8=AA=AD=E3=81=AE=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E3=81=8C=E3=81=82=E3=82=8B=E5=A0=B4=E5=90=88=E3=82=A2?= =?UTF-8?q?=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 + locales/en.yml | 1 + locales/ja.yml | 1 + src/api/common/read-notification.ts | 52 +++ src/api/endpoints.ts | 10 +- src/api/endpoints/i/notifications.ts | 14 +- .../notifications/get_unread_count.ts | 23 ++ .../endpoints/notifications/mark_as_read.ts | 47 --- .../notifications/mark_as_read_all.ts | 32 ++ src/api/models/notification.ts | 5 + src/api/stream/home.ts | 6 + src/web/app/desktop/tags/notifications.tag | 6 + src/web/app/mobile/tags/index.js | 2 - src/web/app/mobile/tags/notifications.tag | 6 + .../app/mobile/tags/page/notifications.tag | 14 + src/web/app/mobile/tags/ui-header.tag | 156 -------- src/web/app/mobile/tags/ui-nav.tag | 170 -------- src/web/app/mobile/tags/ui.tag | 368 ++++++++++++++++++ 18 files changed, 525 insertions(+), 392 deletions(-) create mode 100644 src/api/common/read-notification.ts create mode 100644 src/api/endpoints/notifications/get_unread_count.ts delete mode 100644 src/api/endpoints/notifications/mark_as_read.ts create mode 100644 src/api/endpoints/notifications/mark_as_read_all.ts delete mode 100644 src/web/app/mobile/tags/ui-header.tag delete mode 100644 src/web/app/mobile/tags/ui-nav.tag diff --git a/CHANGELOG.md b/CHANGELOG.md index ca41d016c1..bf5c1fcb2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +unreleased +---------- +* New: 未読の通知がある場合アイコンを表示するように + 2747 (2017/10/25) ----------------- * Fix: 非ログイン状態ですべてのページが致命的な問題を発生させる (#89) diff --git a/locales/en.yml b/locales/en.yml index 03d5306d3e..020813ddbb 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -389,6 +389,7 @@ mobile: mk-notifications-page: notifications: "Notifications" + read-all: "Are you sure you want to mark as read all your notifications?" mk-post-page: title: "Post" diff --git a/locales/ja.yml b/locales/ja.yml index b640f0f248..1b3058fe02 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -389,6 +389,7 @@ mobile: mk-notifications-page: notifications: "通知" + read-all: "すべての通知を既読にしますか?" mk-post-page: title: "投稿" diff --git a/src/api/common/read-notification.ts b/src/api/common/read-notification.ts new file mode 100644 index 0000000000..3009cc5d08 --- /dev/null +++ b/src/api/common/read-notification.ts @@ -0,0 +1,52 @@ +import * as mongo from 'mongodb'; +import { default as Notification, INotification } from '../models/notification'; +import publishUserStream from '../event'; + +/** + * Mark as read notification(s) + */ +export default ( + user: string | mongo.ObjectID, + message: string | string[] | INotification | INotification[] | mongo.ObjectID | mongo.ObjectID[] +) => new Promise(async (resolve, reject) => { + + const userId = mongo.ObjectID.prototype.isPrototypeOf(user) + ? user + : new mongo.ObjectID(user); + + const ids: mongo.ObjectID[] = Array.isArray(message) + ? mongo.ObjectID.prototype.isPrototypeOf(message[0]) + ? (message as mongo.ObjectID[]) + : typeof message[0] === 'string' + ? (message as string[]).map(m => new mongo.ObjectID(m)) + : (message as INotification[]).map(m => m._id) + : mongo.ObjectID.prototype.isPrototypeOf(message) + ? [(message as mongo.ObjectID)] + : typeof message === 'string' + ? [new mongo.ObjectID(message)] + : [(message as INotification)._id]; + + // Update documents + await Notification.update({ + _id: { $in: ids }, + is_read: false + }, { + $set: { + is_read: true + } + }, { + multi: true + }); + + // Calc count of my unread notifications + const count = await Notification + .count({ + notifiee_id: userId, + is_read: false + }); + + if (count == 0) { + // 全ての(いままで未読だった)通知を(これで)読みましたよというイベントを発行 + publishUserStream(userId, 'read_all_notifications'); + } +}); diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index f05762340c..29a97bcb8a 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -195,6 +195,11 @@ const endpoints: Endpoint[] = [ withCredential: true, kind: 'notification-read' }, + { + name: 'notifications/get_unread_count', + withCredential: true, + kind: 'notification-read' + }, { name: 'notifications/delete', withCredential: true, @@ -205,11 +210,6 @@ const endpoints: Endpoint[] = [ withCredential: true, kind: 'notification-write' }, - { - name: 'notifications/mark_as_read', - withCredential: true, - kind: 'notification-write' - }, { name: 'notifications/mark_as_read_all', withCredential: true, diff --git a/src/api/endpoints/i/notifications.ts b/src/api/endpoints/i/notifications.ts index 5575fb7412..607e0768a4 100644 --- a/src/api/endpoints/i/notifications.ts +++ b/src/api/endpoints/i/notifications.ts @@ -5,6 +5,7 @@ import $ from 'cafy'; import Notification from '../../models/notification'; import serialize from '../../serializers/notification'; import getFriends from '../../common/get-friends'; +import read from '../../common/read-notification'; /** * Get notifications @@ -91,17 +92,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => { // Mark as read all if (notifications.length > 0 && markAsRead) { - const ids = notifications - .filter(x => x.is_read == false) - .map(x => x._id); - - // Update documents - await Notification.update({ - _id: { $in: ids } - }, { - $set: { is_read: true } - }, { - multi: true - }); + read(user._id, notifications); } }); diff --git a/src/api/endpoints/notifications/get_unread_count.ts b/src/api/endpoints/notifications/get_unread_count.ts new file mode 100644 index 0000000000..9514e78713 --- /dev/null +++ b/src/api/endpoints/notifications/get_unread_count.ts @@ -0,0 +1,23 @@ +/** + * Module dependencies + */ +import Notification from '../../models/notification'; + +/** + * Get count of unread notifications + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + const count = await Notification + .count({ + notifiee_id: user._id, + is_read: false + }); + + res({ + count: count + }); +}); diff --git a/src/api/endpoints/notifications/mark_as_read.ts b/src/api/endpoints/notifications/mark_as_read.ts deleted file mode 100644 index 5cce33e850..0000000000 --- a/src/api/endpoints/notifications/mark_as_read.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Notification from '../../models/notification'; -import serialize from '../../serializers/notification'; -import event from '../../event'; - -/** - * Mark as read a notification - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - const [notificationId, notificationIdErr] = $(params.notification_id).id().$; - if (notificationIdErr) return rej('invalid notification_id param'); - - // Get notification - const notification = await Notification - .findOne({ - _id: notificationId, - i: user._id - }); - - if (notification === null) { - return rej('notification-not-found'); - } - - // Update - notification.is_read = true; - Notification.update({ _id: notification._id }, { - $set: { - is_read: true - } - }); - - // Response - res(); - - // Serialize - const notificationObj = await serialize(notification); - - // Publish read_notification event - event(user._id, 'read_notification', notificationObj); -}); diff --git a/src/api/endpoints/notifications/mark_as_read_all.ts b/src/api/endpoints/notifications/mark_as_read_all.ts new file mode 100644 index 0000000000..3550e344c4 --- /dev/null +++ b/src/api/endpoints/notifications/mark_as_read_all.ts @@ -0,0 +1,32 @@ +/** + * Module dependencies + */ +import Notification from '../../models/notification'; +import event from '../../event'; + +/** + * Mark as read all notifications + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + // Update documents + await Notification.update({ + notifiee_id: user._id, + is_read: false + }, { + $set: { + is_read: true + } + }, { + multi: true + }); + + // Response + res(); + + // 全ての通知を読みましたよというイベントを発行 + event(user._id, 'read_all_notifications'); +}); diff --git a/src/api/models/notification.ts b/src/api/models/notification.ts index 1c1f429a0d..1065e8baaa 100644 --- a/src/api/models/notification.ts +++ b/src/api/models/notification.ts @@ -1,3 +1,8 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; export default db.get('notifications') as any; // fuck type definition + +export interface INotification { + _id: mongo.ObjectID; +} diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts index d5fe01c261..7c8f3bfec8 100644 --- a/src/api/stream/home.ts +++ b/src/api/stream/home.ts @@ -4,6 +4,7 @@ import * as debug from 'debug'; import User from '../models/user'; import serializePost from '../serializers/post'; +import readNotification from '../common/read-notification'; const log = debug('misskey'); @@ -45,6 +46,11 @@ export default function homeStream(request: websocket.request, connection: webso }); break; + case 'read_notification': + if (!msg.id) return; + readNotification(user._id, msg.id); + break; + case 'capture': if (!msg.id) return; const postId = msg.id; diff --git a/src/web/app/desktop/tags/notifications.tag b/src/web/app/desktop/tags/notifications.tag index 1046358ce9..a4f66105a8 100644 --- a/src/web/app/desktop/tags/notifications.tag +++ b/src/web/app/desktop/tags/notifications.tag @@ -252,6 +252,12 @@ }); this.onNotification = notification => { + // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない + this.stream.send({ + type: 'read_notification', + id: notification.id + }); + this.notifications.unshift(notification); this.update(); }; diff --git a/src/web/app/mobile/tags/index.js b/src/web/app/mobile/tags/index.js index c5aafd20ba..a79f4f7e7e 100644 --- a/src/web/app/mobile/tags/index.js +++ b/src/web/app/mobile/tags/index.js @@ -1,6 +1,4 @@ require('./ui.tag'); -require('./ui-header.tag'); -require('./ui-nav.tag'); require('./page/entrance.tag'); require('./page/entrance/signin.tag'); require('./page/entrance/signup.tag'); diff --git a/src/web/app/mobile/tags/notifications.tag b/src/web/app/mobile/tags/notifications.tag index 7370aa84d3..2e95990314 100644 --- a/src/web/app/mobile/tags/notifications.tag +++ b/src/web/app/mobile/tags/notifications.tag @@ -123,6 +123,12 @@ }); this.onNotification = notification => { + // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない + this.stream.send({ + type: 'read_notification', + id: notification.id + }); + this.notifications.unshift(notification); this.update(); }; diff --git a/src/web/app/mobile/tags/page/notifications.tag b/src/web/app/mobile/tags/page/notifications.tag index 06a5be039f..743de04393 100644 --- a/src/web/app/mobile/tags/page/notifications.tag +++ b/src/web/app/mobile/tags/page/notifications.tag @@ -10,16 +10,30 @@ import ui from '../../scripts/ui-event'; import Progress from '../../../common/scripts/loading'; + this.mixin('api'); + this.on('mount', () => { document.title = 'Misskey | %i18n:mobile.tags.mk-notifications-page.notifications%'; ui.trigger('title', '%i18n:mobile.tags.mk-notifications-page.notifications%'); document.documentElement.style.background = '#313a42'; + ui.trigger('func', () => { + this.readAll(); + }, 'check'); + Progress.start(); this.refs.ui.refs.notifications.on('fetched', () => { Progress.done(); }); }); + + this.readAll = () => { + const ok = window.confirm('%i18n:mobile.tags.mk-notifications-page.read-all%'); + + if (!ok) return; + + this.api('notifications/mark_as_read_all'); + }; diff --git a/src/web/app/mobile/tags/ui-header.tag b/src/web/app/mobile/tags/ui-header.tag deleted file mode 100644 index 10b44b2153..0000000000 --- a/src/web/app/mobile/tags/ui-header.tag +++ /dev/null @@ -1,156 +0,0 @@ - - -
      -
      -
      - - -

      Misskey

      - -
      -
      - - -
      diff --git a/src/web/app/mobile/tags/ui-nav.tag b/src/web/app/mobile/tags/ui-nav.tag deleted file mode 100644 index 34235ba4f1..0000000000 --- a/src/web/app/mobile/tags/ui-nav.tag +++ /dev/null @@ -1,170 +0,0 @@ - -
      - - - -
      diff --git a/src/web/app/mobile/tags/ui.tag b/src/web/app/mobile/tags/ui.tag index 9d9cd4d74a..fb8cbcdbd2 100644 --- a/src/web/app/mobile/tags/ui.tag +++ b/src/web/app/mobile/tags/ui.tag @@ -30,9 +30,377 @@ }; this.onStreamNotification = notification => { + // TODO: ユーザーが画面を見てないと思われるとき(ブラウザやタブがアクティブじゃないなど)は送信しない + this.stream.send({ + type: 'read_notification', + id: notification.id + }); + riot.mount(document.body.appendChild(document.createElement('mk-notify')), { notification: notification }); }; + + + +
      +
      +
      + + +

      Misskey

      + +
      +
      + + +
      + + +
      + + + +
      From 460c6d448bc98a4006bda810fdb30a59f5955d65 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 30 Oct 2017 22:12:52 +0900 Subject: [PATCH 274/364] v2752 --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf5c1fcb2c..2f75462e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます -unreleased ----------- +2752 (2017/10/30) +----------------- * New: 未読の通知がある場合アイコンを表示するように 2747 (2017/10/25) diff --git a/package.json b/package.json index 43a0159619..7a81bed7a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2747", + "version": "0.0.2752", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From dc9fddf839df7959a83819eb7064f402db05f200 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 31 Oct 2017 21:42:11 +0900 Subject: [PATCH 275/364] RENAME: bbs -> channel --- locales/en.yml | 7 ++- locales/ja.yml | 7 ++- src/api/endpoints/bbs/threads/create.ts | 12 ++--- src/api/models/{bbs-thread.ts => channel.ts} | 4 +- src/api/serializers/bbs-thread.ts | 44 ------------------- src/api/serializers/channel.ts | 44 +++++++++++++++++++ src/web/app/desktop/tags/index.js | 2 +- .../tags/pages/{bbs.tag => channels.tag} | 12 ++--- 8 files changed, 65 insertions(+), 67 deletions(-) rename src/api/models/{bbs-thread.ts => channel.ts} (75%) delete mode 100644 src/api/serializers/bbs-thread.ts create mode 100644 src/api/serializers/channel.ts rename src/web/app/desktop/tags/pages/{bbs.tag => channels.tag} (64%) diff --git a/locales/en.yml b/locales/en.yml index f0204b52cb..da532fc78a 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -352,10 +352,9 @@ desktop: mk-repost-form-window: title: "Are you sure you want to repost this post?" - mk-bbs-page: - title: "Misskey BBS" - new: "Create new thread" - thread-title: "Thread title" + mk-channels-page: + new: "Create new channel" + channel-title: "Channel title" mobile: tags: diff --git a/locales/ja.yml b/locales/ja.yml index 65d92782f2..1ae94652b5 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -352,10 +352,9 @@ desktop: mk-repost-form-window: title: "この投稿をRepostしますか?" - mk-bbs-page: - title: "Misskey掲示板" - new: "スレッドを作成" - thread-title: "スレッドのタイトル" + mk-channels-page: + new: "チャンネルを作成" + channel-title: "チャンネルのタイトル" mobile: tags: diff --git a/src/api/endpoints/bbs/threads/create.ts b/src/api/endpoints/bbs/threads/create.ts index 71d61d8711..d9b4d34a0c 100644 --- a/src/api/endpoints/bbs/threads/create.ts +++ b/src/api/endpoints/bbs/threads/create.ts @@ -2,11 +2,11 @@ * Module dependencies */ import $ from 'cafy'; -import Thread from '../../../models/bbs-thread'; -import serialize from '../../../serializers/bbs-thread'; +import Channel from '../../../models/channel'; +import serialize from '../../../serializers/channel'; /** - * Create a thread + * Create a channel * * @param {any} params * @param {any} user @@ -17,13 +17,13 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { const [title, titleErr] = $(params.title).string().range(1, 100).$; if (titleErr) return rej('invalid title param'); - // Create a thread - const thread = await Thread.insert({ + // Create a channel + const channel = await Channel.insert({ created_at: new Date(), user_id: user._id, title: title }); // Response - res(await serialize(thread)); + res(await serialize(channel)); }); diff --git a/src/api/models/bbs-thread.ts b/src/api/models/channel.ts similarity index 75% rename from src/api/models/bbs-thread.ts rename to src/api/models/channel.ts index a92157c6f4..79edb71367 100644 --- a/src/api/models/bbs-thread.ts +++ b/src/api/models/channel.ts @@ -1,11 +1,11 @@ import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -const collection = db.get('bbs_threads'); +const collection = db.get('channels'); export default collection as any; // fuck type definition -export type IBbsThread = { +export type IChannel = { _id: mongo.ObjectID; created_at: Date; title: string; diff --git a/src/api/serializers/bbs-thread.ts b/src/api/serializers/bbs-thread.ts deleted file mode 100644 index d9e41a8468..0000000000 --- a/src/api/serializers/bbs-thread.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import deepcopy = require('deepcopy'); -import { IUser } from '../models/user'; -import { default as Thread, IBbsThread } from '../models/bbs-thread'; - -/** - * Serialize a thread - * - * @param thread target - * @param me? serializee - * @return response - */ -export default ( - thread: string | mongo.ObjectID | IBbsThread, - me?: string | mongo.ObjectID | IUser -) => new Promise(async (resolve, reject) => { - - let _thread: any; - - // Populate the thread if 'thread' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(thread)) { - _thread = await Thread.findOne({ - _id: thread - }); - } else if (typeof thread === 'string') { - _thread = await Thread.findOne({ - _id: new mongo.ObjectID(thread) - }); - } else { - _thread = deepcopy(thread); - } - - // Rename _id to id - _thread.id = _thread._id; - delete _thread._id; - - // Remove needless properties - delete _thread.user_id; - - resolve(_thread); -}); diff --git a/src/api/serializers/channel.ts b/src/api/serializers/channel.ts new file mode 100644 index 0000000000..d4e16d6be3 --- /dev/null +++ b/src/api/serializers/channel.ts @@ -0,0 +1,44 @@ +/** + * Module dependencies + */ +import * as mongo from 'mongodb'; +import deepcopy = require('deepcopy'); +import { IUser } from '../models/user'; +import { default as Channel, IChannel } from '../models/channel'; + +/** + * Serialize a channel + * + * @param channel target + * @param me? serializee + * @return response + */ +export default ( + channel: string | mongo.ObjectID | IChannel, + me?: string | mongo.ObjectID | IUser +) => new Promise(async (resolve, reject) => { + + let _channel: any; + + // Populate the channel if 'channel' is ID + if (mongo.ObjectID.prototype.isPrototypeOf(channel)) { + _channel = await Channel.findOne({ + _id: channel + }); + } else if (typeof channel === 'string') { + _channel = await Channel.findOne({ + _id: new mongo.ObjectID(channel) + }); + } else { + _channel = deepcopy(channel); + } + + // Rename _id to id + _channel.id = _channel._id; + delete _channel._id; + + // Remove needless properties + delete _channel.user_id; + + resolve(_channel); +}); diff --git a/src/web/app/desktop/tags/index.js b/src/web/app/desktop/tags/index.js index fa7161ddfa..6d49006526 100644 --- a/src/web/app/desktop/tags/index.js +++ b/src/web/app/desktop/tags/index.js @@ -61,7 +61,7 @@ require('./pages/user.tag'); require('./pages/post.tag'); require('./pages/search.tag'); require('./pages/not-found.tag'); -require('./pages/bbs.tag'); +require('./pages/channels.tag'); require('./autocomplete-suggestion.tag'); require('./progress-dialog.tag'); require('./user-preview.tag'); diff --git a/src/web/app/desktop/tags/pages/bbs.tag b/src/web/app/desktop/tags/pages/channels.tag similarity index 64% rename from src/web/app/desktop/tags/pages/bbs.tag rename to src/web/app/desktop/tags/pages/channels.tag index cb58af1934..9e47e52d25 100644 --- a/src/web/app/desktop/tags/pages/bbs.tag +++ b/src/web/app/desktop/tags/pages/channels.tag @@ -1,4 +1,4 @@ - +

      %i18n:desktop.tags.mk-bbs-page.title%

      @@ -18,13 +18,13 @@ }); this.new = () => { - const title = window.prompt('%i18n:desktop.tags.mk-bbs-page.thread-title%'); + const title = window.prompt('%i18n:desktop.tags.mk-bbs-page.channel-title%'); - this.api('bbs/threads/create', { + this.api('bbs/channels/create', { title: title - }).then(thread => { - location.href = '/bbs/' + thread.id; + }).then(channel => { + location.href = '/bbs/' + channel.id; }); }; - + From b4340b1d91a6fc1679c3cb891ea800e1b491109c Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 31 Oct 2017 22:09:09 +0900 Subject: [PATCH 276/364] wip --- src/api/endpoints/posts/create.ts | 47 +++++++++++++++++++++++++++---- src/api/models/post.ts | 1 + 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index 805dba7f83..42a55f850e 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -4,9 +4,9 @@ import $ from 'cafy'; import deepEqual = require('deep-equal'); import parse from '../../common/text'; -import Post from '../../models/post'; -import { isValidText } from '../../models/post'; +import { default as Post, IPost, isValidText } from '../../models/post'; import { default as User, IUser } from '../../models/user'; +import { default as Channel, IChannel } from '../../models/channel'; import Following from '../../models/following'; import DriveFile from '../../models/drive-file'; import Watching from '../../models/post-watching'; @@ -62,7 +62,8 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { const [repostId, repostIdErr] = $(params.repost_id).optional.id().$; if (repostIdErr) return rej('invalid repost_id'); - let repost = null; + let repost: IPost = null; + let isQuote = false; if (repostId !== undefined) { // Fetch repost to post repost = await Post.findOne({ @@ -84,18 +85,20 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { } }); + isQuote = text != null || files != null; + // 直近と同じRepost対象かつ引用じゃなかったらエラー if (latestPost && latestPost.repost_id && latestPost.repost_id.equals(repost._id) && - text === undefined && files === null) { + !isQuote) { return rej('cannot repost same post that already reposted in your latest post'); } // 直近がRepost対象かつ引用じゃなかったらエラー if (latestPost && latestPost._id.equals(repost._id) && - text === undefined && files === null) { + !isQuote) { return rej('cannot repost your latest post'); } } @@ -104,7 +107,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { const [inReplyToPostId, inReplyToPostIdErr] = $(params.reply_to_id).optional.id().$; if (inReplyToPostIdErr) return rej('invalid in_reply_to_post_id'); - let inReplyToPost = null; + let inReplyToPost: IPost = null; if (inReplyToPostId !== undefined) { // Fetch reply inReplyToPost = await Post.findOne({ @@ -121,6 +124,37 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { } } + // Get 'channel_id' parameter + const [channelId, channelIdErr] = $(params.channel_id).optional.id().$; + if (channelIdErr) return rej('invalid channel_id'); + + let channel: IChannel = null; + if (channelId !== undefined) { + // Fetch channel + channel = await Channel.findOne({ + _id: channelId + }); + + if (channel === null) { + return rej('channel not found'); + } + + // 返信対象の投稿がこのチャンネルじゃなかったらダメ + if (inReplyToPost && !channelId.equals(inReplyToPost.channel_id)) { + return rej('チャンネル内部からチャンネル外部の投稿に返信することはできません'); + } + + // Repost対象の投稿がこのチャンネルじゃなかったらダメ + if (repost && !channelId.equals(repost.channel_id)) { + return rej('チャンネル内部からチャンネル外部の投稿をRepostすることはできません'); + } + + // 引用ではないRepostはダメ + if (repost && !isQuote) { + return rej('チャンネル内部では引用ではないRepostをすることはできません'); + } + } + // Get 'poll' parameter const [poll, pollErr] = $(params.poll).optional.strict.object() .have('choices', $().array('string') @@ -164,6 +198,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // 投稿を作成 const post = await Post.insert({ created_at: new Date(), + channel_id: channel ? channel._id : undefined, media_ids: files ? files.map(file => file._id) : undefined, reply_to_id: inReplyToPost ? inReplyToPost._id : undefined, repost_id: repost ? repost._id : undefined, diff --git a/src/api/models/post.ts b/src/api/models/post.ts index 8b9f7f5ef6..fe07dcb0b1 100644 --- a/src/api/models/post.ts +++ b/src/api/models/post.ts @@ -10,6 +10,7 @@ export function isValidText(text: string): boolean { export type IPost = { _id: mongo.ObjectID; + channel_id: mongo.ObjectID; created_at: Date; media_ids: mongo.ObjectID[]; reply_to_id: mongo.ObjectID; From 30a4e839a687bed7ed839e3c17f6781bb4b76499 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 31 Oct 2017 22:14:12 +0900 Subject: [PATCH 277/364] Fix indent --- src/api/endpoints/posts/create.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index 42a55f850e..e0a02fa4a0 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -186,11 +186,11 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { repost: user.latest_post.repost_id ? user.latest_post.repost_id.toString() : null, media_ids: (user.latest_post.media_ids || []).map(id => id.toString()) }, { - text: text, - reply: inReplyToPost ? inReplyToPost._id.toString() : null, - repost: repost ? repost._id.toString() : null, - media_ids: (files || []).map(file => file._id.toString()) - })) { + text: text, + reply: inReplyToPost ? inReplyToPost._id.toString() : null, + repost: repost ? repost._id.toString() : null, + media_ids: (files || []).map(file => file._id.toString()) + })) { return rej('duplicate'); } } From 5efb52b9f563ae7d6b5383d054a6c21fee676b68 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 31 Oct 2017 22:35:31 +0900 Subject: [PATCH 278/364] wip --- locales/en.yml | 2 +- locales/ja.yml | 2 +- src/api/endpoints.ts | 12 ++++++++++-- .../endpoints/{bbs/threads => channels}/create.ts | 4 ++-- src/web/app/desktop/router.js | 5 +++++ src/web/app/desktop/tags/pages/channels.tag | 8 +++----- src/web/app/desktop/tags/ui.tag | 8 ++++---- 7 files changed, 26 insertions(+), 15 deletions(-) rename src/api/endpoints/{bbs/threads => channels}/create.ts (84%) diff --git a/locales/en.yml b/locales/en.yml index da532fc78a..5c7a1165ba 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -241,7 +241,7 @@ desktop: mk-ui-header-nav: home: "Home" messaging: "Messages" - bbs: "BBS" + channels: "Channels" info: "News" mk-ui-header-search: diff --git a/locales/ja.yml b/locales/ja.yml index 1ae94652b5..dd76a2b900 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -241,7 +241,7 @@ desktop: mk-ui-header-nav: home: "ホーム" messaging: "メッセージ" - bbs: "掲示板" + channels: "チャンネル" info: "お知らせ" mk-ui-header-search: diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index 29a97bcb8a..26177b8775 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -474,8 +474,16 @@ const endpoints: Endpoint[] = [ name: 'messaging/messages/create', withCredential: true, kind: 'messaging-write' - } - + }, + { + name: 'channels/create', + withCredential: true, + limit: { + duration: ms('1hour'), + max: 3, + minInterval: ms('10seconds') + } + }, ]; export default endpoints; diff --git a/src/api/endpoints/bbs/threads/create.ts b/src/api/endpoints/channels/create.ts similarity index 84% rename from src/api/endpoints/bbs/threads/create.ts rename to src/api/endpoints/channels/create.ts index d9b4d34a0c..74b089dfc3 100644 --- a/src/api/endpoints/bbs/threads/create.ts +++ b/src/api/endpoints/channels/create.ts @@ -2,8 +2,8 @@ * Module dependencies */ import $ from 'cafy'; -import Channel from '../../../models/channel'; -import serialize from '../../../serializers/channel'; +import Channel from '../../models/channel'; +import serialize from '../../serializers/channel'; /** * Create a channel diff --git a/src/web/app/desktop/router.js b/src/web/app/desktop/router.js index afa8a2dce3..51738f3afa 100644 --- a/src/web/app/desktop/router.js +++ b/src/web/app/desktop/router.js @@ -9,6 +9,7 @@ let page = null; export default me => { route('/', index); route('/i>mentions', mentions); + route('/channel', channels); route('/post::post', post); route('/search::query', search); route('/:user', user.bind(null, 'home')); @@ -54,6 +55,10 @@ export default me => { mount(el); } + function channels() { + mount(document.createElement('mk-channels-page')); + } + function notFound() { mount(document.createElement('mk-not-found')); } diff --git a/src/web/app/desktop/tags/pages/channels.tag b/src/web/app/desktop/tags/pages/channels.tag index 9e47e52d25..03fae3c8d1 100644 --- a/src/web/app/desktop/tags/pages/channels.tag +++ b/src/web/app/desktop/tags/pages/channels.tag @@ -1,8 +1,7 @@
      -

      %i18n:desktop.tags.mk-bbs-page.title%

      - +
      + + diff --git a/src/web/app/desktop/tags/pages/channels.tag b/src/web/app/desktop/tags/pages/channels.tag index 03fae3c8d1..220f1ca50e 100644 --- a/src/web/app/desktop/tags/pages/channels.tag +++ b/src/web/app/desktop/tags/pages/channels.tag @@ -18,7 +18,7 @@ this.new = () => { const title = window.prompt('%i18n:desktop.tags.mk-channels-page.channel-title%'); - this.api('bbs/channels/create', { + this.api('channels/create', { title: title }).then(channel => { location.href = '/channel/' + channel.id; diff --git a/src/web/app/desktop/tags/pages/user.tag b/src/web/app/desktop/tags/pages/user.tag index 864fe22735..811ca5c0fd 100644 --- a/src/web/app/desktop/tags/pages/user.tag +++ b/src/web/app/desktop/tags/pages/user.tag @@ -16,7 +16,7 @@ this.refs.ui.refs.user.on('user-fetched', user => { Progress.set(0.5); - document.title = user.name + ' | Misskey' + document.title = user.name + ' | Misskey'; }); this.refs.ui.refs.user.on('loaded', () => { From 346c2959e058fa445ebb82e71eb37ef023ba6bd4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 00:10:30 +0900 Subject: [PATCH 280/364] wip --- src/api/endpoints.ts | 3 + src/api/endpoints/channels/posts.ts | 79 +++++++++++++++++ src/web/app/common/scripts/channel-stream.js | 14 +++ src/web/app/desktop/tags/pages/channel.tag | 87 +++++++++++++++++++ .../app/desktop/tags/pages/drive-chooser.tag | 44 ++++++++++ 5 files changed, 227 insertions(+) create mode 100644 src/api/endpoints/channels/posts.ts create mode 100644 src/web/app/common/scripts/channel-stream.js create mode 100644 src/web/app/desktop/tags/pages/drive-chooser.tag diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index 45b83fc9e5..88c01d4e7f 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -487,6 +487,9 @@ const endpoints: Endpoint[] = [ { name: 'channels/show' }, + { + name: 'channels/posts' + }, ]; export default endpoints; diff --git a/src/api/endpoints/channels/posts.ts b/src/api/endpoints/channels/posts.ts new file mode 100644 index 0000000000..fa91fb93ee --- /dev/null +++ b/src/api/endpoints/channels/posts.ts @@ -0,0 +1,79 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import { default as Channel, IChannel } from '../../models/channel'; +import { default as Post, IPost } from '../../models/post'; +import serialize from '../../serializers/post'; + +/** + * Show a posts of a channel + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + // Get 'limit' parameter + const [limit = 1000, limitErr] = $(params.limit).optional.number().range(1, 1000).$; + if (limitErr) return rej('invalid limit param'); + + // Get 'since_id' parameter + const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; + if (sinceIdErr) return rej('invalid since_id param'); + + // Get 'max_id' parameter + const [maxId, maxIdErr] = $(params.max_id).optional.id().$; + if (maxIdErr) return rej('invalid max_id param'); + + // Check if both of since_id and max_id is specified + if (sinceId && maxId) { + return rej('cannot set since_id and max_id'); + } + + // Get 'channel_id' parameter + const [channelId, channelIdErr] = $(params.channel_id).id().$; + if (channelIdErr) return rej('invalid channel_id param'); + + // Fetch channel + const channel: IChannel = await Channel.findOne({ + _id: channelId + }); + + if (channel === null) { + return rej('channel not found'); + } + + //#region Construct query + const sort = { + _id: -1 + }; + + const query = { + channel_id: channel._id + } as any; + + if (sinceId) { + sort._id = 1; + query._id = { + $gt: sinceId + }; + } else if (maxId) { + query._id = { + $lt: maxId + }; + } + //#endregion Construct query + + // Issue query + const posts = await Post + .find(query, { + limit: limit, + sort: sort + }); + + // Serialize + res(await Promise.all(posts.map(async (post) => + await serialize(post, user) + ))); +}); diff --git a/src/web/app/common/scripts/channel-stream.js b/src/web/app/common/scripts/channel-stream.js new file mode 100644 index 0000000000..38e7d91132 --- /dev/null +++ b/src/web/app/common/scripts/channel-stream.js @@ -0,0 +1,14 @@ +'use strict'; + +import Stream from './stream'; + +/** + * Channel stream connection + */ +class Connection extends Stream { + constructor() { + super('channel'); + } +} + +export default Connection; diff --git a/src/web/app/desktop/tags/pages/channel.tag b/src/web/app/desktop/tags/pages/channel.tag index 4fa172f99d..8a3034f40c 100644 --- a/src/web/app/desktop/tags/pages/channel.tag +++ b/src/web/app/desktop/tags/pages/channel.tag @@ -2,6 +2,8 @@

      { parent.channel.title }

      + +
      + + +
      + { post.user.name } +
      +
      + { post.text } +
      + + +
      + + +

      { reply.user.name }への返信: (or キャンセル)

      + + + + + +
      diff --git a/src/web/app/desktop/tags/pages/drive-chooser.tag b/src/web/app/desktop/tags/pages/drive-chooser.tag new file mode 100644 index 0000000000..49741ad40c --- /dev/null +++ b/src/web/app/desktop/tags/pages/drive-chooser.tag @@ -0,0 +1,44 @@ + + +
      + + + +
      + + + +
      From 71c3e11708dad327924bdcb95193d44c2b11a907 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 01:38:19 +0900 Subject: [PATCH 281/364] wip --- src/api/endpoints/channels/create.ts | 3 +- src/api/endpoints/posts/create.ts | 17 +++++++++++ src/api/models/channel.ts | 1 + src/api/serializers/post.ts | 8 ++++- src/web/app/desktop/tags/pages/channel.tag | 35 ++++++++++++++++++---- src/web/app/desktop/tags/timeline.tag | 4 +++ src/web/app/mobile/tags/timeline.tag | 4 +++ 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/src/api/endpoints/channels/create.ts b/src/api/endpoints/channels/create.ts index 74b089dfc3..e0c0e0192a 100644 --- a/src/api/endpoints/channels/create.ts +++ b/src/api/endpoints/channels/create.ts @@ -21,7 +21,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { const channel = await Channel.insert({ created_at: new Date(), user_id: user._id, - title: title + title: title, + index: 0 }); // Response diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index e0a02fa4a0..183cabf135 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -153,6 +153,16 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { if (repost && !isQuote) { return rej('チャンネル内部では引用ではないRepostをすることはできません'); } + } else { + // 返信対象の投稿がチャンネルへの投稿だったらダメ + if (inReplyToPost && inReplyToPost.channel_id != null) { + return rej('チャンネル外部からチャンネル内部の投稿に返信することはできません'); + } + + // Repost対象の投稿がチャンネルへの投稿だったらダメ + if (repost && repost.channel_id != null) { + return rej('チャンネル外部からチャンネル内部の投稿をRepostすることはできません'); + } } // Get 'poll' parameter @@ -199,6 +209,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { const post = await Post.insert({ created_at: new Date(), channel_id: channel ? channel._id : undefined, + index: channel ? channel.index + 1 : undefined, media_ids: files ? files.map(file => file._id) : undefined, reply_to_id: inReplyToPost ? inReplyToPost._id : undefined, repost_id: repost ? repost._id : undefined, @@ -217,6 +228,12 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // ----------------------------------------------------------- // Post processes + Channel.update({ _id: channel._id }, { + $inc: { + index: 1 + } + }); + User.update({ _id: user._id }, { $set: { latest_post: post diff --git a/src/api/models/channel.ts b/src/api/models/channel.ts index 79edb71367..c80e84dbc8 100644 --- a/src/api/models/channel.ts +++ b/src/api/models/channel.ts @@ -10,4 +10,5 @@ export type IChannel = { created_at: Date; title: string; user_id: mongo.ObjectID; + index: number; }; diff --git a/src/api/serializers/post.ts b/src/api/serializers/post.ts index df917a8595..7d40df2d6a 100644 --- a/src/api/serializers/post.ts +++ b/src/api/serializers/post.ts @@ -8,6 +8,7 @@ import Reaction from '../models/post-reaction'; import { IUser } from '../models/user'; import Vote from '../models/poll-vote'; import serializeApp from './app'; +import serializeChannel from './channel'; import serializeUser from './user'; import serializeDriveFile from './drive-file'; import parse from '../common/text'; @@ -76,8 +77,13 @@ const self = ( _post.app = await serializeApp(_post.app_id); } + // Populate channel + if (_post.channel_id) { + _post.channel = await serializeChannel(_post.channel_id); + } + + // Populate media if (_post.media_ids) { - // Populate media _post.media = await Promise.all(_post.media_ids.map(async fileId => await serializeDriveFile(fileId) )); diff --git a/src/web/app/desktop/tags/pages/channel.tag b/src/web/app/desktop/tags/pages/channel.tag index 8a3034f40c..ebd26f07b8 100644 --- a/src/web/app/desktop/tags/pages/channel.tag +++ b/src/web/app/desktop/tags/pages/channel.tag @@ -2,8 +2,9 @@

      { parent.channel.title }

      - - + +
      +
      @@ -57,9 +60,13 @@
      - { post.user.name } + { post.index }: + { post.user.name } + + ID:{ post.user.username }
      + >>{ post.reply_to.index } { post.text }
      -

      { reply.user.name }への返信: (or キャンセル)

      +

      >>{ reply.index } ({ reply.user.name }): [x]

      - - -
- - - - diff --git a/src/web/app/desktop/tags/pages/selectdrive.tag b/src/web/app/desktop/tags/pages/selectdrive.tag new file mode 100644 index 0000000000..b196357d85 --- /dev/null +++ b/src/web/app/desktop/tags/pages/selectdrive.tag @@ -0,0 +1,159 @@ + + +
+ + + +
+ + + +
From f37fb38640a31c4b8865a5562628197ff21f3cce Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 03:17:14 +0900 Subject: [PATCH 284/364] wip --- docs/setup.en.md | 1 + docs/setup.ja.md | 1 + locales/en.yml | 13 +++-- locales/ja.yml | 13 +++-- src/api/endpoints/posts/create.ts | 7 ++- src/api/event.ts | 6 +++ src/api/stream/channel.ts | 12 +++++ src/api/streaming.ts | 22 +++++--- src/config.ts | 2 + src/web/app/ch/router.js | 32 ++++++++++++ src/web/app/ch/script.js | 18 +++++++ src/web/app/ch/style.styl | 4 ++ .../tags/pages => ch/tags}/channel.tag | 52 +++++++++++++------ src/web/app/ch/tags/index.js | 2 + src/web/app/ch/tags/index.tag | 24 +++++++++ src/web/app/common/scripts/channel-stream.js | 6 ++- src/web/app/common/scripts/config.js | 2 + src/web/app/desktop/router.js | 12 ----- src/web/app/desktop/tags/index.js | 2 - src/web/app/desktop/tags/pages/channels.tag | 28 ---------- src/web/app/desktop/tags/timeline.tag | 2 +- src/web/app/desktop/tags/ui.tag | 6 +-- src/web/app/mobile/tags/timeline.tag | 2 +- src/web/app/mobile/tags/ui.tag | 5 +- webpack/webpack.config.ts | 1 + 25 files changed, 189 insertions(+), 86 deletions(-) create mode 100644 src/api/stream/channel.ts create mode 100644 src/web/app/ch/router.js create mode 100644 src/web/app/ch/script.js create mode 100644 src/web/app/ch/style.styl rename src/web/app/{desktop/tags/pages => ch/tags}/channel.tag (76%) create mode 100644 src/web/app/ch/tags/index.js create mode 100644 src/web/app/ch/tags/index.tag delete mode 100644 src/web/app/desktop/tags/pages/channels.tag diff --git a/docs/setup.en.md b/docs/setup.en.md index 3e48935346..dbc0599b5a 100644 --- a/docs/setup.en.md +++ b/docs/setup.en.md @@ -25,6 +25,7 @@ Note that Misskey uses following subdomains: * **api**.*{primary domain}* * **auth**.*{primary domain}* * **about**.*{primary domain}* +* **ch**.*{primary domain}* * **stats**.*{primary domain}* * **status**.*{primary domain}* * **dev**.*{primary domain}* diff --git a/docs/setup.ja.md b/docs/setup.ja.md index 4f48a08088..602fd9b6a1 100644 --- a/docs/setup.ja.md +++ b/docs/setup.ja.md @@ -26,6 +26,7 @@ Misskeyは以下のサブドメインを使います: * **api**.*{primary domain}* * **auth**.*{primary domain}* * **about**.*{primary domain}* +* **ch**.*{primary domain}* * **stats**.*{primary domain}* * **status**.*{primary domain}* * **dev**.*{primary domain}* diff --git a/locales/en.yml b/locales/en.yml index 5c7a1165ba..643649b46c 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -164,6 +164,12 @@ common: mk-uploader: waiting: "Waiting" +ch: + tags: + mk-index: + new: "Create new channel" + channel-title: "Channel title" + desktop: tags: mk-api-info: @@ -241,7 +247,7 @@ desktop: mk-ui-header-nav: home: "Home" messaging: "Messages" - channels: "Channels" + ch: "Channels" info: "News" mk-ui-header-search: @@ -352,10 +358,6 @@ desktop: mk-repost-form-window: title: "Are you sure you want to repost this post?" - mk-channels-page: - new: "Create new channel" - channel-title: "Channel title" - mobile: tags: mk-drive-file-viewer: @@ -496,6 +498,7 @@ mobile: home: "Home" notifications: "Notifications" messaging: "Messages" + ch: "Channels" drive: "Drive" settings: "Settings" about: "About Misskey" diff --git a/locales/ja.yml b/locales/ja.yml index dd76a2b900..9fd7d94f0b 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -164,6 +164,12 @@ common: mk-uploader: waiting: "待機中" +ch: + tags: + mk-index: + new: "チャンネルを作成" + channel-title: "チャンネルのタイトル" + desktop: tags: mk-api-info: @@ -241,7 +247,7 @@ desktop: mk-ui-header-nav: home: "ホーム" messaging: "メッセージ" - channels: "チャンネル" + ch: "チャンネル" info: "お知らせ" mk-ui-header-search: @@ -352,10 +358,6 @@ desktop: mk-repost-form-window: title: "この投稿をRepostしますか?" - mk-channels-page: - new: "チャンネルを作成" - channel-title: "チャンネルのタイトル" - mobile: tags: mk-drive-file-viewer: @@ -496,6 +498,7 @@ mobile: home: "ホーム" notifications: "通知" messaging: "メッセージ" + ch: "チャンネル" search: "検索" drive: "ドライブ" settings: "設定" diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index 183cabf135..34265dcbc3 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -13,7 +13,7 @@ import Watching from '../../models/post-watching'; import serialize from '../../serializers/post'; import notify from '../../common/notify'; import watch from '../../common/watch-post'; -import event from '../../event'; +import { default as event, publishChannelStream } from '../../event'; import config from '../../../conf'; /** @@ -258,6 +258,11 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // Publish event to myself's stream event(user._id, 'post', postObj); + // Publish event to channel + if (channel) { + publishChannelStream(channel._id, 'post', postObj); + } + // Fetch all followers const followers = await Following .find({ diff --git a/src/api/event.ts b/src/api/event.ts index 9613a9f7cc..909b0d2556 100644 --- a/src/api/event.ts +++ b/src/api/event.ts @@ -25,6 +25,10 @@ class MisskeyEvent { this.publish(`messaging-stream:${userId}-${otherpartyId}`, type, typeof value === 'undefined' ? null : value); } + public publishChannelStream(channelId: ID, type: string, value?: any): void { + this.publish(`channel-stream:${channelId}`, type, typeof value === 'undefined' ? null : value); + } + private publish(channel: string, type: string, value?: any): void { const message = value == null ? { type: type } : @@ -41,3 +45,5 @@ export default ev.publishUserStream.bind(ev); export const publishPostStream = ev.publishPostStream.bind(ev); export const publishMessagingStream = ev.publishMessagingStream.bind(ev); + +export const publishChannelStream = ev.publishChannelStream.bind(ev); diff --git a/src/api/stream/channel.ts b/src/api/stream/channel.ts new file mode 100644 index 0000000000..d67d77cbf4 --- /dev/null +++ b/src/api/stream/channel.ts @@ -0,0 +1,12 @@ +import * as websocket from 'websocket'; +import * as redis from 'redis'; + +export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient): void { + const channel = request.resourceURL.query.channel; + + // Subscribe channel stream + subscriber.subscribe(`misskey:channel-stream:${channel}`); + subscriber.on('message', (_, data) => { + connection.send(data); + }); +} diff --git a/src/api/streaming.ts b/src/api/streaming.ts index db600013b9..0e512fb210 100644 --- a/src/api/streaming.ts +++ b/src/api/streaming.ts @@ -9,6 +9,7 @@ import isNativeToken from './common/is-native-token'; import homeStream from './stream/home'; import messagingStream from './stream/messaging'; import serverStream from './stream/server'; +import channelStream from './stream/channel'; module.exports = (server: http.Server) => { /** @@ -26,14 +27,6 @@ module.exports = (server: http.Server) => { return; } - const user = await authenticate(request.resourceURL.query.i); - - if (user == null) { - connection.send('authentication-failed'); - connection.close(); - return; - } - // Connect to Redis const subscriber = redis.createClient( config.redis.port, config.redis.host); @@ -43,6 +36,19 @@ module.exports = (server: http.Server) => { subscriber.quit(); }); + if (request.resourceURL.pathname === '/channel') { + channelStream(request, connection, subscriber); + return; + } + + const user = await authenticate(request.resourceURL.query.i); + + if (user == null) { + connection.send('authentication-failed'); + connection.close(); + return; + } + const channel = request.resourceURL.pathname === '/' ? homeStream : request.resourceURL.pathname === '/messaging' ? messagingStream : diff --git a/src/config.ts b/src/config.ts index 46a93f5fef..18017e9740 100644 --- a/src/config.ts +++ b/src/config.ts @@ -88,6 +88,7 @@ type Mixin = { api_url: string; auth_url: string; about_url: string; + ch_url: stirng; stats_url: string; status_url: string; dev_url: string; @@ -122,6 +123,7 @@ export default function load() { mixin.secondary_scheme = config.secondary_url.substr(0, config.secondary_url.indexOf('://')); mixin.api_url = `${mixin.scheme}://api.${mixin.host}`; mixin.auth_url = `${mixin.scheme}://auth.${mixin.host}`; + mixin.ch_url = `${mixin.scheme}://ch.${mixin.host}`; mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`; mixin.about_url = `${mixin.scheme}://about.${mixin.host}`; mixin.stats_url = `${mixin.scheme}://stats.${mixin.host}`; diff --git a/src/web/app/ch/router.js b/src/web/app/ch/router.js new file mode 100644 index 0000000000..424158f403 --- /dev/null +++ b/src/web/app/ch/router.js @@ -0,0 +1,32 @@ +import * as riot from 'riot'; +const route = require('page'); +let page = null; + +export default me => { + route('/', index); + route('/:channel', channel); + route('*', notFound); + + function index() { + mount(document.createElement('mk-index')); + } + + function channel(ctx) { + const el = document.createElement('mk-channel'); + el.setAttribute('id', ctx.params.channel); + mount(el); + } + + function notFound() { + mount(document.createElement('mk-not-found')); + } + + // EXEC + route(); +}; + +function mount(content) { + if (page) page.unmount(); + const body = document.getElementById('app'); + page = riot.mount(body.appendChild(content))[0]; +} diff --git a/src/web/app/ch/script.js b/src/web/app/ch/script.js new file mode 100644 index 0000000000..760d405c52 --- /dev/null +++ b/src/web/app/ch/script.js @@ -0,0 +1,18 @@ +/** + * Channels + */ + +// Style +import './style.styl'; + +require('./tags'); +import init from '../init'; +import route from './router'; + +/** + * init + */ +init(me => { + // Start routing + route(me); +}); diff --git a/src/web/app/ch/style.styl b/src/web/app/ch/style.styl new file mode 100644 index 0000000000..2fc3ac3fca --- /dev/null +++ b/src/web/app/ch/style.styl @@ -0,0 +1,4 @@ +@import "../base" + +html + background #efefef diff --git a/src/web/app/desktop/tags/pages/channel.tag b/src/web/app/ch/tags/channel.tag similarity index 76% rename from src/web/app/desktop/tags/pages/channel.tag rename to src/web/app/ch/tags/channel.tag index a14c0648c4..b16844b8bc 100644 --- a/src/web/app/desktop/tags/pages/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -1,14 +1,19 @@ - - -
-

{ parent.channel.title }

- - - -
- -
-
+ +
+

{ channel.title }

+ + + +
+ +
+

参加するにはログインまたは新規登録してください

+
+
+
+ Misskey ver { version } (葵 aoi) +
+
-
+
@@ -127,7 +147,7 @@ + diff --git a/src/web/app/common/scripts/channel-stream.js b/src/web/app/common/scripts/channel-stream.js index 38e7d91132..17944dbe45 100644 --- a/src/web/app/common/scripts/channel-stream.js +++ b/src/web/app/common/scripts/channel-stream.js @@ -6,8 +6,10 @@ import Stream from './stream'; * Channel stream connection */ class Connection extends Stream { - constructor() { - super('channel'); + constructor(channelId) { + super('channel', { + channel: channelId + }); } } diff --git a/src/web/app/common/scripts/config.js b/src/web/app/common/scripts/config.js index 75a7abba29..c5015622f0 100644 --- a/src/web/app/common/scripts/config.js +++ b/src/web/app/common/scripts/config.js @@ -6,6 +6,7 @@ const host = isRoot ? Url.host : Url.host.substring(Url.host.indexOf('.') + 1, U const scheme = Url.protocol; const url = `${scheme}//${host}`; const apiUrl = `${scheme}//api.${host}`; +const chUrl = `${scheme}//ch.${host}`; const devUrl = `${scheme}//dev.${host}`; const aboutUrl = `${scheme}//about.${host}`; const statsUrl = `${scheme}//stats.${host}`; @@ -16,6 +17,7 @@ export default { scheme, url, apiUrl, + chUrl, devUrl, aboutUrl, statsUrl, diff --git a/src/web/app/desktop/router.js b/src/web/app/desktop/router.js index df67bb7b7c..977e3fa9a6 100644 --- a/src/web/app/desktop/router.js +++ b/src/web/app/desktop/router.js @@ -10,8 +10,6 @@ export default me => { route('/', index); route('/selectdrive', selectDrive); route('/i>mentions', mentions); - route('/channel', channels); - route('/channel/:channel', channel); route('/post::post', post); route('/search::query', search); route('/:user', user.bind(null, 'home')); @@ -57,16 +55,6 @@ export default me => { mount(el); } - function channel(ctx) { - const el = document.createElement('mk-channel-page'); - el.setAttribute('id', ctx.params.channel); - mount(el); - } - - function channels() { - mount(document.createElement('mk-channels-page')); - } - function selectDrive() { mount(document.createElement('mk-selectdrive-page')); } diff --git a/src/web/app/desktop/tags/index.js b/src/web/app/desktop/tags/index.js index 0b92d8c236..37fdfe37e4 100644 --- a/src/web/app/desktop/tags/index.js +++ b/src/web/app/desktop/tags/index.js @@ -61,8 +61,6 @@ require('./pages/user.tag'); require('./pages/post.tag'); require('./pages/search.tag'); require('./pages/not-found.tag'); -require('./pages/channel.tag'); -require('./pages/channels.tag'); require('./pages/selectdrive.tag'); require('./autocomplete-suggestion.tag'); require('./progress-dialog.tag'); diff --git a/src/web/app/desktop/tags/pages/channels.tag b/src/web/app/desktop/tags/pages/channels.tag deleted file mode 100644 index 220f1ca50e..0000000000 --- a/src/web/app/desktop/tags/pages/channels.tag +++ /dev/null @@ -1,28 +0,0 @@ - - -
- -
-
- - -
diff --git a/src/web/app/desktop/tags/timeline.tag b/src/web/app/desktop/tags/timeline.tag index 17b2c66dc8..64b64f902f 100644 --- a/src/web/app/desktop/tags/timeline.tag +++ b/src/web/app/desktop/tags/timeline.tag @@ -112,7 +112,7 @@
-

{ p.channel.title }:

+

{ p.channel.title }:

diff --git a/src/web/app/desktop/tags/ui.tag b/src/web/app/desktop/tags/ui.tag index 7527358dce..3123c34f4f 100644 --- a/src/web/app/desktop/tags/ui.tag +++ b/src/web/app/desktop/tags/ui.tag @@ -335,10 +335,10 @@ -
  • - +
  • + -

    %i18n:desktop.tags.mk-ui-header-nav.channels%

    +

    %i18n:desktop.tags.mk-ui-header-nav.ch%

  • diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index b26a5cb108..ad18521df6 100644 --- a/src/web/app/mobile/tags/timeline.tag +++ b/src/web/app/mobile/tags/timeline.tag @@ -164,7 +164,7 @@
    -

    { p.channel.title }:

    +

    { p.channel.title }:

    diff --git a/src/web/app/mobile/tags/ui.tag b/src/web/app/mobile/tags/ui.tag index fb8cbcdbd2..b2d96f6b8b 100644 --- a/src/web/app/mobile/tags/ui.tag +++ b/src/web/app/mobile/tags/ui.tag @@ -231,10 +231,11 @@
  • %i18n:mobile.tags.mk-ui-nav.messaging%
    • %i18n:mobile.tags.mk-ui-nav.settings%
    • diff --git a/webpack/webpack.config.ts b/webpack/webpack.config.ts index 5199285d55..066df18157 100644 --- a/webpack/webpack.config.ts +++ b/webpack/webpack.config.ts @@ -16,6 +16,7 @@ module.exports = langs.map(([lang, locale]) => { const entry = { desktop: './src/web/app/desktop/script.js', mobile: './src/web/app/mobile/script.js', + ch: './src/web/app/ch/script.js', stats: './src/web/app/stats/script.js', status: './src/web/app/status/script.js', dev: './src/web/app/dev/script.js', From 3c4719a0b119c78108edeff2ecf7965f1c517237 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 03:31:36 +0900 Subject: [PATCH 285/364] wip --- src/web/app/ch/tags/channel.tag | 2 +- src/web/app/mobile/router.js | 5 ++ src/web/app/mobile/tags/drive.tag | 6 +- src/web/app/mobile/tags/index.js | 1 + src/web/app/mobile/tags/page/selectdrive.tag | 83 ++++++++++++++++++++ 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/web/app/mobile/tags/page/selectdrive.tag diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index b16844b8bc..d43113a554 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -11,7 +11,7 @@

    - Misskey ver { version } (葵 aoi) + Misskey ver { version } (葵 aoi)
    + + From 20707d6fd9ce2dea1342ad38156c32fcec82217a Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 03:41:34 +0900 Subject: [PATCH 286/364] wip --- locales/en.yml | 3 +++ locales/ja.yml | 3 +++ src/web/app/ch/tags/channel.tag | 24 +++++++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index 643649b46c..afb6d2f2fb 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -360,6 +360,9 @@ desktop: mobile: tags: + mk-selectdrive-page: + select-file: "Select file(s)" + mk-drive-file-viewer: download: "Download" rename: "Rename" diff --git a/locales/ja.yml b/locales/ja.yml index 9fd7d94f0b..03975556b5 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -360,6 +360,9 @@ desktop: mobile: tags: + mk-selectdrive-page: + select-file: "ファイルを選択" + mk-drive-file-viewer: download: "ダウンロード" rename: "名前を変更" diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index d43113a554..e8537e3f0a 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -1,9 +1,13 @@

    { channel.title }

    - - - +

    読み込み中

    +
    +

    > + + + +

    @@ -33,6 +37,7 @@ this.id = this.opts.id; this.fetching = true; + this.postsFetching = true; this.channel = null; this.posts = null; this.connection = new ChannelStream(this.id); @@ -60,6 +65,7 @@ channel_id: this.id }).then(posts => { this.update({ + postsFetching: false, posts: posts }); }); @@ -84,6 +90,7 @@
    { post.index }: { post.user.name } + ID:{ post.user.username }
    @@ -114,6 +121,17 @@ > mk-time margin-right 0.5em + &:first-of-type + display none + + @media (max-width 600px) + > mk-time + &:first-of-type + display initial + + &:last-of-type + display none + > div padding 0 0 1em 2em From 0cffc1cac0140a420c64e039487c32237c581d5e Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 03:42:50 +0900 Subject: [PATCH 287/364] wip --- src/web/app/ch/tags/channel.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index e8537e3f0a..43a1f851f8 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -3,7 +3,7 @@

    { channel.title }

    読み込み中

    -

    > +

    まだ投稿がありません

    From 42be937fcb6f02037ff4024a2fb1cf463c50ce0c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 04:11:56 +0900 Subject: [PATCH 288/364] wip --- src/api/endpoints.ts | 3 ++ src/api/endpoints/channels.ts | 59 +++++++++++++++++++++++++++++++++ src/web/app/ch/tags/channel.tag | 7 ++-- src/web/app/ch/tags/index.tag | 13 ++++++-- 4 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 src/api/endpoints/channels.ts diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index 88c01d4e7f..c4dacad857 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -490,6 +490,9 @@ const endpoints: Endpoint[] = [ { name: 'channels/posts' }, + { + name: 'channels' + }, ]; export default endpoints; diff --git a/src/api/endpoints/channels.ts b/src/api/endpoints/channels.ts new file mode 100644 index 0000000000..e10c943896 --- /dev/null +++ b/src/api/endpoints/channels.ts @@ -0,0 +1,59 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import Channel from '../models/channel'; +import serialize from '../serializers/channel'; + +/** + * Get all channels + * + * @param {any} params + * @param {any} me + * @return {Promise} + */ +module.exports = (params, me) => new Promise(async (res, rej) => { + // Get 'limit' parameter + const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; + if (limitErr) return rej('invalid limit param'); + + // Get 'since_id' parameter + const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; + if (sinceIdErr) return rej('invalid since_id param'); + + // Get 'max_id' parameter + const [maxId, maxIdErr] = $(params.max_id).optional.id().$; + if (maxIdErr) return rej('invalid max_id param'); + + // Check if both of since_id and max_id is specified + if (sinceId && maxId) { + return rej('cannot set since_id and max_id'); + } + + // Construct query + const sort = { + _id: -1 + }; + const query = {} as any; + if (sinceId) { + sort._id = 1; + query._id = { + $gt: sinceId + }; + } else if (maxId) { + query._id = { + $lt: maxId + }; + } + + // Issue query + const channels = await Channel + .find(query, { + limit: limit, + sort: sort + }); + + // Serialize + res(await Promise.all(channels.map(async channel => + await serialize(channel, me)))); +}); diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index 43a1f851f8..12a6b5a3b9 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -1,4 +1,6 @@ +
    Misskey Channels
    +

    { channel.title }

    読み込み中

    @@ -21,10 +23,9 @@ diff --git a/src/web/app/ch/tags/index.tag b/src/web/app/ch/tags/index.tag index 1c0a037c2d..a64ddb6ccd 100644 --- a/src/web/app/ch/tags/index.tag +++ b/src/web/app/ch/tags/index.tag @@ -1,5 +1,9 @@ - + +
    + From 51006a6815fe02aa915c59ca5d42ab3234884442 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 13:25:43 +0900 Subject: [PATCH 312/364] v2793 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd8ecb57e3..6a86e24c61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2793 (2017/11/01) +----------------- +* なんか + 2783 (2017/11/01) ----------------- * なんか diff --git a/package.json b/package.json index eaafeb9fd5..87db0c8e1e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2783", + "version": "0.0.2793", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From 3cbb3ff81fc12feeedc779dc5ff00733c67f9133 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 13:39:05 +0900 Subject: [PATCH 313/364] wip --- src/api/endpoints/posts/create.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index 360b5df0d9..b3fbdf6fa2 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -249,8 +249,11 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { } } - // Publish event to myself's stream - event(user._id, 'post', postObj); + // TODO + if (!channel) { + // Publish event to myself's stream + event(user._id, 'post', postObj); + } if (channel) { // Increment channel index(posts count) From fcdf2c4f89c4eb7bb666337d7e162e1c5e727e61 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 1 Nov 2017 06:55:03 +0000 Subject: [PATCH 314/364] chore(package): update awesome-typescript-loader to version 3.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 87db0c8e1e..dd5a57015a 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@types/webpack": "3.0.13", "@types/webpack-stream": "3.2.7", "@types/websocket": "0.0.34", - "awesome-typescript-loader": "3.2.3", + "awesome-typescript-loader": "3.3.0", "chai": "4.1.2", "chai-http": "3.0.0", "css-loader": "0.28.7", From 86901b68b84bb68167c6a3d8cd043e63ba66bed2 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 16:42:15 +0900 Subject: [PATCH 315/364] =?UTF-8?q?=E3=81=84=E3=81=84=E6=84=9F=E3=81=98?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/app/ch/tags/channel.tag | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index 602b80bc11..fdc9ab4cef 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -182,12 +182,13 @@

    >>{ reply.index } ({ reply.user.name }): [x]

    - +
    +
    1. { name }
    @@ -202,6 +203,19 @@ this.mixin('api'); this.channel = this.opts.channel; + this.files = null; + + this.on('mount', () => { + this.refs.uploader.on('uploaded', file => { + this.update({ + files: [file] + }); + }); + }); + + this.upload = file => { + this.refs.uploader.upload(file); + }; this.clearReply = () => { this.update({ @@ -217,7 +231,7 @@ this.refs.text.value = ''; }; - this.post = e => { + this.post = () => { this.update({ wait: true }); @@ -250,5 +264,17 @@ }; window.open(CONFIG.url + '/selectdrive?multiple=true', '_blank'); }; + + this.onkeydown = e => { + if ((e.which == 10 || e.which == 13) && (e.ctrlKey || e.metaKey)) this.post(); + }; + + this.onpaste = e => { + e.clipboardData.items.forEach(item => { + if (item.kind == 'file') { + this.upload(item.getAsFile()); + } + }); + };
    From 8234862bf759efab6d5214c4250913a80458d890 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 16:42:51 +0900 Subject: [PATCH 316/364] v2795 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a86e24c61..9b2f3d7c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2795 (2017/11/01) +----------------- +* いい感じに + 2793 (2017/11/01) ----------------- * なんか diff --git a/package.json b/package.json index 87db0c8e1e..09e5a62399 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2793", + "version": "0.0.2795", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From b65e038686913812a1e6ddf7e1288337c6fe5fe7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 16:48:00 +0900 Subject: [PATCH 317/364] Better progress bar --- src/web/app/ch/tags/channel.tag | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index fdc9ab4cef..c6921e1a5c 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -51,10 +51,18 @@ Progress.start(); + const fetched = false; + + // チャンネル概要読み込み this.api('channels/show', { channel_id: this.id }).then(channel => { - Progress.done(); + if (fetched) { + Progress.done(); + } else { + Progress.set(0.5); + fetched = true; + } this.update({ fetching: false, @@ -64,9 +72,17 @@ document.title = channel.title + ' | Misskey' }); + // 投稿読み込み this.api('channels/posts', { channel_id: this.id }).then(posts => { + if (fetched) { + Progress.done(); + } else { + Progress.set(0.5); + fetched = true; + } + this.update({ postsFetching: false, posts: posts From e221d410e056ea348c994efb9d0a7f3b9addd2eb Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 17:09:24 +0900 Subject: [PATCH 318/364] Fix bug --- src/web/app/ch/tags/channel.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index c6921e1a5c..67b012cb5c 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -51,7 +51,7 @@ Progress.start(); - const fetched = false; + let fetched = false; // チャンネル概要読み込み this.api('channels/show', { From 5e2053ca869cbfe18a2e552f228e8138b6a95f61 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 17:20:54 +0900 Subject: [PATCH 319/364] :v: --- src/web/app/ch/tags/channel.tag | 54 +++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index 67b012cb5c..ad254c98e5 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -3,12 +3,20 @@

    { channel.title }

    -

    読み込み中

    -
    -

    まだ投稿がありません

    - - - + + + +
    +

    読み込み中

    +
    +

    まだ投稿がありません

    + + + +

    @@ -29,6 +37,14 @@ > h1 font-size 1.5em color #f00 + + > .share + > * + margin-right 4px + + > .body + margin 8px 0 0 0 + + + + + + + + + + + From 2b3937d7318f06344c9524fca7c71d81da25d603 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 17:21:26 +0900 Subject: [PATCH 320/364] v2799 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b2f3d7c0b..03282eb3cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +2799 (2017/11/01) +----------------- +* いい感じに + 2795 (2017/11/01) ----------------- * いい感じに diff --git a/package.json b/package.json index 09e5a62399..a45d3b36ca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.2795", + "version": "0.0.2799", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From d6b03c43eb818a5e13a8ad1ec69697e4600c5c2c Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 1 Nov 2017 19:33:08 +0900 Subject: [PATCH 321/364] Implement Channel Watching --- src/api/endpoints.ts | 8 ++++ src/api/endpoints/channels/create.ts | 11 ++++- src/api/endpoints/channels/unwatch.ts | 60 +++++++++++++++++++++++++++ src/api/endpoints/channels/watch.ts | 58 ++++++++++++++++++++++++++ src/api/endpoints/posts/create.ts | 43 ++++++++++++------- src/api/endpoints/posts/timeline.ts | 39 ++++++++++++----- src/api/models/channel-watching.ts | 3 ++ src/api/serializers/channel.ts | 22 ++++++++++ src/web/app/ch/tags/channel.tag | 27 ++++++++++++ 9 files changed, 244 insertions(+), 27 deletions(-) create mode 100644 src/api/endpoints/channels/unwatch.ts create mode 100644 src/api/endpoints/channels/watch.ts create mode 100644 src/api/models/channel-watching.ts diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index c4dacad857..afefce39e5 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -490,6 +490,14 @@ const endpoints: Endpoint[] = [ { name: 'channels/posts' }, + { + name: 'channels/watch', + withCredential: true + }, + { + name: 'channels/unwatch', + withCredential: true + }, { name: 'channels' }, diff --git a/src/api/endpoints/channels/create.ts b/src/api/endpoints/channels/create.ts index e0c0e0192a..a8d7c29dc1 100644 --- a/src/api/endpoints/channels/create.ts +++ b/src/api/endpoints/channels/create.ts @@ -3,6 +3,7 @@ */ import $ from 'cafy'; import Channel from '../../models/channel'; +import Watching from '../../models/channel-watching'; import serialize from '../../serializers/channel'; /** @@ -22,9 +23,17 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { created_at: new Date(), user_id: user._id, title: title, - index: 0 + index: 0, + watching_count: 1 }); // Response res(await serialize(channel)); + + // Create Watching + await Watching.insert({ + created_at: new Date(), + user_id: user._id, + channel_id: channel._id + }); }); diff --git a/src/api/endpoints/channels/unwatch.ts b/src/api/endpoints/channels/unwatch.ts new file mode 100644 index 0000000000..19d3be118a --- /dev/null +++ b/src/api/endpoints/channels/unwatch.ts @@ -0,0 +1,60 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import Channel from '../../models/channel'; +import Watching from '../../models/channel-watching'; + +/** + * Unwatch a channel + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + // Get 'channel_id' parameter + const [channelId, channelIdErr] = $(params.channel_id).id().$; + if (channelIdErr) return rej('invalid channel_id param'); + + //#region Fetch channel + const channel = await Channel.findOne({ + _id: channelId + }); + + if (channel === null) { + return rej('channel not found'); + } + //#endregion + + //#region Check whether not watching + const exist = await Watching.findOne({ + user_id: user._id, + channel_id: channel._id, + deleted_at: { $exists: false } + }); + + if (exist === null) { + return rej('already not watching'); + } + //#endregion + + // Delete watching + await Watching.update({ + _id: exist._id + }, { + $set: { + deleted_at: new Date() + } + }); + + // Send response + res(); + + // Decrement watching count + Channel.update(channel._id, { + $inc: { + watching_count: -1 + } + }); +}); diff --git a/src/api/endpoints/channels/watch.ts b/src/api/endpoints/channels/watch.ts new file mode 100644 index 0000000000..030e0dd411 --- /dev/null +++ b/src/api/endpoints/channels/watch.ts @@ -0,0 +1,58 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import Channel from '../../models/channel'; +import Watching from '../../models/channel-watching'; + +/** + * Watch a channel + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = (params, user) => new Promise(async (res, rej) => { + // Get 'channel_id' parameter + const [channelId, channelIdErr] = $(params.channel_id).id().$; + if (channelIdErr) return rej('invalid channel_id param'); + + //#region Fetch channel + const channel = await Channel.findOne({ + _id: channelId + }); + + if (channel === null) { + return rej('channel not found'); + } + //#endregion + + //#region Check whether already watching + const exist = await Watching.findOne({ + user_id: user._id, + channel_id: channel._id, + deleted_at: { $exists: false } + }); + + if (exist !== null) { + return rej('already watching'); + } + //#endregion + + // Create Watching + await Watching.insert({ + created_at: new Date(), + user_id: user._id, + channel_id: channel._id + }); + + // Send response + res(); + + // Increment watching count + Channel.update(channel._id, { + $inc: { + watching_count: 1 + } + }); +}); diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index b3fbdf6fa2..2326f7baf1 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -10,6 +10,7 @@ import { default as Channel, IChannel } from '../../models/channel'; import Following from '../../models/following'; import DriveFile from '../../models/drive-file'; import Watching from '../../models/post-watching'; +import ChannelWatching from '../../models/channel-watching'; import serialize from '../../serializers/post'; import notify from '../../common/notify'; import watch from '../../common/watch-post'; @@ -249,26 +250,11 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { } } - // TODO + // タイムラインへの投稿 if (!channel) { // Publish event to myself's stream event(user._id, 'post', postObj); - } - if (channel) { - // Increment channel index(posts count) - Channel.update({ _id: channel._id }, { - $inc: { - index: 1 - } - }); - - // Publish event to channel - publishChannelStream(channel._id, 'post', postObj); - } - - // TODO - if (!channel) { // Fetch all followers const followers = await Following .find({ @@ -285,6 +271,31 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { event(following.follower_id, 'post', postObj)); } + // チャンネルへの投稿 + if (channel) { + // Increment channel index(posts count) + Channel.update({ _id: channel._id }, { + $inc: { + index: 1 + } + }); + + // Publish event to channel + publishChannelStream(channel._id, 'post', postObj); + + // Get channel watchers + const watches = await ChannelWatching.find({ + channel_id: channel._id, + // 削除されたドキュメントは除く + deleted_at: { $exists: false } + }); + + // チャンネルの視聴者(のタイムライン)に配信 + watches.forEach(w => { + event(w.user_id, 'post', postObj); + }); + } + // Increment my posts count User.update({ _id: user._id }, { $inc: { diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts index fe096442b4..aa5aff5ba5 100644 --- a/src/api/endpoints/posts/timeline.ts +++ b/src/api/endpoints/posts/timeline.ts @@ -3,6 +3,7 @@ */ import $ from 'cafy'; import Post from '../../models/post'; +import ChannelWatching from '../../models/channel-watching'; import getFriends from '../../common/get-friends'; import serialize from '../../serializers/post'; @@ -32,26 +33,43 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { return rej('cannot set since_id and max_id'); } - // ID list of the user $self and other users who the user follows + // ID list of the user itself and other users who the user follows const followingIds = await getFriends(user._id); - // Construct query + // Watchしているチャンネルを取得 + const watches = await ChannelWatching.find({ + user_id: user._id, + // 削除されたドキュメントは除く + deleted_at: { $exists: false } + }); + + //#region Construct query const sort = { _id: -1 }; + const query = { - user_id: { - $in: followingIds - }, - // TODO $or: [{ - channel_id: { - $exists: false - } + // フォローしている人のタイムラインへの投稿 + user_id: { + $in: followingIds + }, + // 「タイムラインへの」投稿に限定するためにチャンネルが指定されていないもののみに限る + $or: [{ + channel_id: { + $exists: false + } + }, { + channel_id: null + }] }, { - channel_id: null + // Watchしているチャンネルへの投稿 + channel_id: { + $in: watches.map(w => w.channel_id) + } }] } as any; + if (sinceId) { sort._id = 1; query._id = { @@ -62,6 +80,7 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => { $lt: maxId }; } + //#endregion // Issue query const timeline = await Post diff --git a/src/api/models/channel-watching.ts b/src/api/models/channel-watching.ts new file mode 100644 index 0000000000..6184ae408d --- /dev/null +++ b/src/api/models/channel-watching.ts @@ -0,0 +1,3 @@ +import db from '../../db/mongodb'; + +export default db.get('channel_watching') as any; // fuck type definition diff --git a/src/api/serializers/channel.ts b/src/api/serializers/channel.ts index d4e16d6be3..3cba39aa16 100644 --- a/src/api/serializers/channel.ts +++ b/src/api/serializers/channel.ts @@ -5,6 +5,7 @@ import * as mongo from 'mongodb'; import deepcopy = require('deepcopy'); import { IUser } from '../models/user'; import { default as Channel, IChannel } from '../models/channel'; +import Watching from '../models/channel-watching'; /** * Serialize a channel @@ -40,5 +41,26 @@ export default ( // Remove needless properties delete _channel.user_id; + // Me + const meId: mongo.ObjectID = me + ? mongo.ObjectID.prototype.isPrototypeOf(me) + ? me as mongo.ObjectID + : typeof me === 'string' + ? new mongo.ObjectID(me) + : (me as IUser)._id + : null; + + if (me) { + //#region Watchしているかどうか + const watch = await Watching.findOne({ + user_id: meId, + channel_id: _channel.id, + deleted_at: { $exists: false } + }); + + _channel.is_watching = watch !== null; + //#endregion + } + resolve(_channel); }); diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index ad254c98e5..57cedf10d4 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -4,6 +4,11 @@

    { channel.title }

    +
    +

    このチャンネルをウォッチしています ウォッチ解除

    +

    このチャンネルをウォッチする

    +
    +