From e49f7f40bc15814bdcab84d9fece281ccd257c43 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 13 Apr 2018 23:04:22 +0900 Subject: [PATCH 01/62] Update index.ts --- src/server/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/index.ts b/src/server/index.ts index db41a1dcb5..28babeed68 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -53,6 +53,7 @@ function createServer() { Object.keys(config.https).forEach(k => { certs[k] = fs.readFileSync(config.https[k]); }); + certs['allowHTTP1'] = true return http2.createSecureServer(certs, app.callback()); } else { return http.createServer(app.callback()); From fde2782a9eb5dcd7a706bee2401ce44c891c3653 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:45:44 +0900 Subject: [PATCH 02/62] Cache url preview --- src/server/web/url-preview.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index 4b3f44a5da..d5464d0cd4 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -5,6 +5,10 @@ module.exports = async (ctx: Koa.Context) => { const summary = await summaly(ctx.query.url); summary.icon = wrap(summary.icon); summary.thumbnail = wrap(summary.thumbnail); + + // Cache 7days + ctx.set('Cache-Control', 'max-age=604800, immutable'); + ctx.body = summary; }; From 8260464090aefce364ca5ce5d116f12f0b84e617 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:46:03 +0900 Subject: [PATCH 03/62] Add note --- src/server/file/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/file/index.ts b/src/server/file/index.ts index d305286d12..29056c63e7 100644 --- a/src/server/file/index.ts +++ b/src/server/file/index.ts @@ -14,6 +14,7 @@ const app = new Koa(); app.use(cors()); app.use(async (ctx, next) => { + // Cache 365days ctx.set('Cache-Control', 'max-age=31536000, immutable'); await next(); }); From 39feb54aab62ec39c94f546c13fe353d8bc9e4c1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:50:43 +0900 Subject: [PATCH 04/62] Fix: Add missing semicolon --- src/server/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/index.ts b/src/server/index.ts index 28babeed68..622164d386 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -53,7 +53,7 @@ function createServer() { Object.keys(config.https).forEach(k => { certs[k] = fs.readFileSync(config.https[k]); }); - certs['allowHTTP1'] = true + certs['allowHTTP1'] = true; return http2.createSecureServer(certs, app.callback()); } else { return http.createServer(app.callback()); From ec6300f5aee265a6d7051794a1b8111347f4f96d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:54:54 +0900 Subject: [PATCH 05/62] :v: --- src/server/index.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/server/index.ts b/src/server/index.ts index 622164d386..5db3da2b93 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -63,13 +63,9 @@ function createServer() { export default () => new Promise(resolve => { const server = createServer(); - /** - * Steaming - */ + // Init stream server require('./api/streaming')(server); - /** - * Server listen - */ + // Listen server.listen(config.port, resolve); }); From 79475f6856d757eb60389f54b2f028bd03c8e747 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:56:10 +0900 Subject: [PATCH 06/62] set ja as default --- src/client/app/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/app/boot.js b/src/client/app/boot.js index ef828d9637..13abc86ad9 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -30,9 +30,9 @@ //#endregion // Detect the user language - // Note: The default language is English + // Note: The default language is Japanese let lang = navigator.language.split('-')[0]; - if (!/^(en|ja)$/.test(lang)) lang = 'en'; + if (!/^(en|ja)$/.test(lang)) lang = 'ja'; if (localStorage.getItem('lang')) lang = localStorage.getItem('lang'); if (ENV != 'production') lang = 'ja'; From 3cdb32048849be82757c5641ff46b25993ce1bcc Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:04:55 +0900 Subject: [PATCH 07/62] Use require to avoid warning --- src/server/activitypub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index 2a99bccfc4..804f0f870d 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -1,5 +1,5 @@ import * as Router from 'koa-router'; -import { parseRequest } from 'http-signature'; +const parseRequest = require('http-signature'); import { createHttp } from '../queue'; import pack from '../remote/activitypub/renderer'; From 04285c9498859edca86f2f70f7bddda204ecee9d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:23:06 +0900 Subject: [PATCH 08/62] Fix bug --- package.json | 1 + src/server/activitypub.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d82e5d2330..ea2b0f2514 100644 --- a/package.json +++ b/package.json @@ -137,6 +137,7 @@ "js-yaml": "3.11.0", "jsdom": "11.7.0", "koa": "2.5.0", + "koa-body": "^2.5.0", "koa-bodyparser": "4.2.0", "koa-compress": "^2.0.0", "koa-favicon": "2.0.1", diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index 804f0f870d..954cc7480e 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -1,4 +1,5 @@ import * as Router from 'koa-router'; +const koaBody = require('koa-body'); const parseRequest = require('http-signature'); import { createHttp } from '../queue'; @@ -18,7 +19,7 @@ const router = new Router(); //#region Routing // inbox -router.post('/users/:user/inbox', ctx => { +router.post('/users/:user/inbox', koaBody(), ctx => { let signature; ctx.req.headers.authorization = 'Signature ' + ctx.req.headers.signature; From ddab1698baacd7b93382f07f6aa4c62fdd0e6d85 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:38:55 +0900 Subject: [PATCH 09/62] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 46288e0c4a..ead032615f 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,9 @@ ultimately sophisticated new type of mini-blog based SNS. :sparkles: Features ---------------------------------------------------------------- * Automatically updated timeline +* Reactions * Private messages -* Two-Factor Authentication support * ServiceWorker support -* Web API for third-party applications * ActivityPub compatible and more! You can touch with your own eyes at https://misskey.xyz/. From 10abe03ed7a5b9c5732d8db2e5c486b6bbad767c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:40:12 +0900 Subject: [PATCH 10/62] Fix bug --- src/client/app/common/mios.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/app/common/mios.ts b/src/client/app/common/mios.ts index ccc73eebc3..f4bb60fcdb 100644 --- a/src/client/app/common/mios.ts +++ b/src/client/app/common/mios.ts @@ -441,10 +441,14 @@ export default class MiOS extends EventEmitter { document.body.appendChild(spinner); } + const onFinally = () => { + if (--pending === 0) spinner.parentNode.removeChild(spinner); + }; + // Append a credential if (this.isSignedIn) (data as any).i = this.i.token; - return new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { const viaStream = this.stream.hasConnection && (localStorage.getItem('apiViaStream') ? localStorage.getItem('apiViaStream') == 'true' : true); @@ -453,8 +457,6 @@ export default class MiOS extends EventEmitter { const id = Math.random().toString(); stream.once(`api-res:${id}`, res => { - if (--pending === 0) spinner.parentNode.removeChild(spinner); - if (res.res) { resolve(res.res); } else { @@ -489,8 +491,6 @@ export default class MiOS extends EventEmitter { credentials: endpoint === 'signin' ? 'include' : 'omit', cache: 'no-cache' }).then(async (res) => { - if (--pending === 0) spinner.parentNode.removeChild(spinner); - const body = res.status === 204 ? null : await res.json(); if (this.debug) { @@ -508,6 +508,10 @@ export default class MiOS extends EventEmitter { }).catch(reject); } }); + + promise.then(onFinally, onFinally); + + return promise; } /** From 0debbf9e64f8b504f4f0fb47f1006f0ff132cc08 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 05:14:22 +0900 Subject: [PATCH 11/62] v4835 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea2b0f2514..1e8b6a7dc9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.4771", + "version": "0.0.4835", "codename": "nighthike", "license": "MIT", "description": "A miniblog-based SNS", From a42b8606245db4ce0f6e775d5ddc84e179cc7af4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 05:16:15 +0900 Subject: [PATCH 12/62] =?UTF-8?q?=E4=B8=80=E6=99=82=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E6=97=A5=E6=9C=AC=E8=AA=9E=E3=81=AE=E3=81=BF=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/boot.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 13abc86ad9..70705e8149 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -31,10 +31,11 @@ // Detect the user language // Note: The default language is Japanese - let lang = navigator.language.split('-')[0]; - if (!/^(en|ja)$/.test(lang)) lang = 'ja'; - if (localStorage.getItem('lang')) lang = localStorage.getItem('lang'); - if (ENV != 'production') lang = 'ja'; + //let lang = navigator.language.split('-')[0]; + //if (!/^(en|ja)$/.test(lang)) lang = 'ja'; + //if (localStorage.getItem('lang')) lang = localStorage.getItem('lang'); + //if (ENV != 'production') lang = 'ja'; + const lang = 'ja'; // Detect the user agent const ua = navigator.userAgent.toLowerCase(); From 7eac0bb1d66dbc10f09d1d43f7a997d2c2e0710f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 05:23:13 +0900 Subject: [PATCH 13/62] wait 3 sec --- src/client/app/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/app/boot.js b/src/client/app/boot.js index 70705e8149..2675fa233a 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -81,7 +81,7 @@ script.setAttribute('defer', 'true'); head.appendChild(script); - // 1秒経ってもスクリプトがロードされない場合はバージョンが古くて + // 3秒経ってもスクリプトがロードされない場合はバージョンが古くて // 404になっているせいかもしれないので、バージョンを確認して古ければ更新する // // 読み込まれたスクリプトからこのタイマーを解除できるように、 @@ -119,5 +119,5 @@ // Force reload location.reload(true); } - }, 1000); + }, 3000); } From f0be021d851bfca0df4ab71dbbc56edf82134f50 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:18:18 +0900 Subject: [PATCH 14/62] Fix bug --- src/client/app/common/mios.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/app/common/mios.ts b/src/client/app/common/mios.ts index f4bb60fcdb..41825c3b74 100644 --- a/src/client/app/common/mios.ts +++ b/src/client/app/common/mios.ts @@ -457,7 +457,9 @@ export default class MiOS extends EventEmitter { const id = Math.random().toString(); stream.once(`api-res:${id}`, res => { - if (res.res) { + if (res == null || Object.keys(res).length == 0) { + resolve(null); + } else if (res.res) { resolve(res.res); } else { reject(res.e); From 8bf05e47df91f9e15fb30ca8468389a459b8edb7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:27:17 +0900 Subject: [PATCH 15/62] Fix bug --- src/server/api/service/twitter.ts | 54 +++++++++++++++++-------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts index 9fb01b44ef..0de2e68c60 100644 --- a/src/server/api/service/twitter.ts +++ b/src/server/api/service/twitter.ts @@ -107,7 +107,7 @@ if (config.twitter == null) { ctx.redirect(twCtx.url); }); - router.get('/tw/cb', ctx => { + router.get('/tw/cb', async ctx => { const userToken = getUserToken(ctx); if (userToken == null) { @@ -141,31 +141,37 @@ if (config.twitter == null) { return; } - redis.get(userToken, async (_, twCtx) => { - const result = await twAuth.done(JSON.parse(twCtx), verifier); - - const user = await User.findOneAndUpdate({ - host: null, - token: userToken - }, { - $set: { - twitter: { - accessToken: result.accessToken, - accessTokenSecret: result.accessTokenSecret, - userId: result.userId, - screenName: result.screenName - } - } + const get = new Promise((res, rej) => { + redis.get(userToken, async (_, twCtx) => { + res(twCtx); }); - - ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`; - - // Publish i updated event - event(user._id, 'i_updated', await pack(user, user, { - detail: true, - includeSecrets: true - })); }); + + const twCtx = await get; + + const result = await twAuth.done(JSON.parse(twCtx), verifier); + + const user = await User.findOneAndUpdate({ + host: null, + token: userToken + }, { + $set: { + twitter: { + accessToken: result.accessToken, + accessTokenSecret: result.accessTokenSecret, + userId: result.userId, + screenName: result.screenName + } + } + }); + + ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`; + + // Publish i updated event + event(user._id, 'i_updated', await pack(user, user, { + detail: true, + includeSecrets: true + })); } }); } From f61348f697050dc979298e330b793ad05c8ca842 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:27:30 +0900 Subject: [PATCH 16/62] v4840 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1e8b6a7dc9..766d700fb4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.4835", + "version": "0.0.4840", "codename": "nighthike", "license": "MIT", "description": "A miniblog-based SNS", From bf57b2ad1362e2ea619c3a23aba337e6ac54e738 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:41:33 +0900 Subject: [PATCH 17/62] Fix bug --- src/server/api/service/twitter.ts | 34 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts index 0de2e68c60..284ae7ee22 100644 --- a/src/server/api/service/twitter.ts +++ b/src/server/api/service/twitter.ts @@ -118,21 +118,27 @@ if (config.twitter == null) { return; } - redis.get(sessid, async (_, twCtx) => { - const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier); - - const user = await User.findOne({ - host: null, - 'twitter.userId': result.userId - }) as ILocalUser; - - if (user == null) { - ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`); - return; - } - - signin(ctx, user, true); + const get = new Promise((res, rej) => { + redis.get(sessid, async (_, twCtx) => { + res(twCtx); + }); }); + + const twCtx = await get; + + const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier); + + const user = await User.findOne({ + host: null, + 'twitter.userId': result.userId + }) as ILocalUser; + + if (user == null) { + ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`); + return; + } + + signin(ctx, user, true); } else { const verifier = ctx.query.oauth_verifier; From 725b7fdfa5023de7077316e63d7351380dda08b7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:56:25 +0900 Subject: [PATCH 18/62] Update DONORS.md --- DONORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DONORS.md b/DONORS.md index 6b56b13e0b..35e3aa9fd1 100644 --- a/DONORS.md +++ b/DONORS.md @@ -12,6 +12,7 @@ The list of people who have sent donation for Misskey. * 音船 https://otofune.me/ * aqz https://misskey.xyz/aqz * kotodu "虚無創作中" +* Maya Minatsuki :heart: Thanks for donating, guys! From 366e1f7df56d604201257f01fa528821bbdff527 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 07:58:08 +0900 Subject: [PATCH 19/62] Update example.yml --- .config/example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/example.yml b/.config/example.yml index 0e167ccb77..4772a1f22f 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -12,7 +12,7 @@ url: # 待受ポート port: -# TLSの設定(利用しない場合は省略可能) +# TLSの設定(利用しない場合は省略してください) https: # 証明書のパス... key: From 6c1bd75a108893b13b9a491838a3cd15df27b070 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:18:51 +0900 Subject: [PATCH 20/62] Update DONORS.md --- DONORS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DONORS.md b/DONORS.md index 35e3aa9fd1..0e0c7c1d77 100644 --- a/DONORS.md +++ b/DONORS.md @@ -13,6 +13,9 @@ The list of people who have sent donation for Misskey. * aqz https://misskey.xyz/aqz * kotodu "虚無創作中" * Maya Minatsuki +* Knzk https://knzk.me/@Knzk +* ねじわさび https://knzk.me/@y +* NCLS https://knzk.me/@imncls :heart: Thanks for donating, guys! From bcc5449e47956e9786646abf688a3161aa89912a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:22:58 +0900 Subject: [PATCH 21/62] =?UTF-8?q?=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AF=E3=81=8A=E3=81=99?= =?UTF-8?q?=E3=81=99=E3=82=81=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AB?= =?UTF-8?q?=E5=90=AB=E3=82=81=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/users/recommendation.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index 2de22da13e..e367e65a6c 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -30,15 +30,13 @@ module.exports = (params, me) => new Promise(async (res, rej) => { _id: { $nin: followingIds }, - $or: [ - { - 'lastUsedAt': { - $gte: new Date(Date.now() - ms('7days')) - } - }, { - host: { $ne: null } + $or: [{ + 'lastUsedAt': { + $gte: new Date(Date.now() - ms('7days')) } - ] + }, { + host: null + }] }, { limit: limit, skip: offset, From a6d08774bc68dd06771ba105d6c02c9d1813dba9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:27:16 +0900 Subject: [PATCH 22/62] Update DONORS.md --- DONORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DONORS.md b/DONORS.md index 0e0c7c1d77..008f3592cd 100644 --- a/DONORS.md +++ b/DONORS.md @@ -14,7 +14,7 @@ The list of people who have sent donation for Misskey. * kotodu "虚無創作中" * Maya Minatsuki * Knzk https://knzk.me/@Knzk -* ねじわさび https://knzk.me/@y +* ねじりわさび https://knzk.me/@y * NCLS https://knzk.me/@imncls :heart: Thanks for donating, guys! From 26c979bcece39a81133eb42c3d043c8be9c028f1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:29:18 +0900 Subject: [PATCH 23/62] Better indexes --- src/models/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/user.ts b/src/models/user.ts index c121790c31..97b7a997e5 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -22,9 +22,9 @@ import SwSubscription, { deleteSwSubscription } from './sw-subscription'; const User = db.get('users'); -User.createIndex('username'); -User.createIndex('usernameLower'); -User.createIndex('token'); +User.createIndex(['username', 'host'], { unique: true }); +User.createIndex(['usernameLower', 'host'], { unique: true }); +User.createIndex('token', { unique: true }); User.createIndex('uri', { sparse: true, unique: true }); export default User; From d81c20f163f0884d04cd11e46221bfefc0ac9f22 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:39:07 +0900 Subject: [PATCH 24/62] =?UTF-8?q?hostLower=E3=81=AF=E5=BB=83=E6=AD=A2?= =?UTF-8?q?=E3=81=97=E3=81=A6host=E3=81=ABlower=E3=81=97=E3=81=9F=E3=82=82?= =?UTF-8?q?=E3=81=AE=E3=82=92=E5=85=A5=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/note.ts | 1 - src/models/user.ts | 1 - src/queue/processors/http/process-inbox.ts | 2 +- src/remote/activitypub/objects/person.ts | 4 +--- src/remote/resolve-user.ts | 12 ++++++------ src/server/api/common/get-host-lower.ts | 2 +- src/server/api/endpoints/users/notes.ts | 2 +- src/server/api/private/signup.ts | 1 - src/services/note/create.ts | 1 - 9 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/models/note.ts b/src/models/note.ts index 3c1c2e18e1..6d315db4cf 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -66,7 +66,6 @@ export type INote = { }; _user: { host: string; - hostLower: string; account: { inbox?: string; }; diff --git a/src/models/user.ts b/src/models/user.ts index 97b7a997e5..cf5a4a3616 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -49,7 +49,6 @@ type IUserBase = { isSuspended: boolean; keywords: string[]; host: string; - hostLower: string; }; export interface ILocalUser extends IUserBase { diff --git a/src/queue/processors/http/process-inbox.ts b/src/queue/processors/http/process-inbox.ts index ce5b7d5a89..a2c6bf4f90 100644 --- a/src/queue/processors/http/process-inbox.ts +++ b/src/queue/processors/http/process-inbox.ts @@ -32,7 +32,7 @@ export default async (job: kue.Job, done): Promise => { return; } - user = await User.findOne({ usernameLower: username, hostLower: host }) as IRemoteUser; + user = await User.findOne({ usernameLower: username, host: host.toLowerCase() }) as IRemoteUser; } else { user = await User.findOne({ host: { $ne: null }, diff --git a/src/remote/activitypub/objects/person.ts b/src/remote/activitypub/objects/person.ts index f7ec064cdb..6c060f879c 100644 --- a/src/remote/activitypub/objects/person.ts +++ b/src/remote/activitypub/objects/person.ts @@ -74,8 +74,7 @@ export async function createPerson(value: any, resolver?: Resolver): Promise matched.toLowerCase()); + const host = toUnicode(finger.subject.replace(/^.*?@/, '')).toLowerCase(); const summaryDOM = JSDOM.fragment(person.summary); // Create user @@ -92,7 +91,6 @@ export async function createPerson(value: any, resolver?: Resolver): Promise { +export default async (username, _host, option) => { const usernameLower = username.toLowerCase(); - const hostLowerAscii = toASCII(host).toLowerCase(); - const hostLower = toUnicode(hostLowerAscii); + const hostAscii = toASCII(_host).toLowerCase(); + const host = toUnicode(hostAscii); - if (config.host == hostLower) { + if (config.host == host) { return await User.findOne({ usernameLower }); } - let user = await User.findOne({ usernameLower, hostLower }, option); + let user = await User.findOne({ usernameLower, host }, option); if (user === null) { - const acctLower = `${usernameLower}@${hostLowerAscii}`; + const acctLower = `${usernameLower}@${hostAscii}`; const finger = await webFinger(acctLower); const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self'); diff --git a/src/server/api/common/get-host-lower.ts b/src/server/api/common/get-host-lower.ts index fc4b30439e..550c233001 100644 --- a/src/server/api/common/get-host-lower.ts +++ b/src/server/api/common/get-host-lower.ts @@ -1,5 +1,5 @@ import { toUnicode } from 'punycode'; export default host => { - return toUnicode(host).replace(/[A-Z]+/, match => match.toLowerCase()); + return toUnicode(host).toLowerCase(); }; diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index e91b75e1d3..bd4247c79c 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -65,7 +65,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const q = userId !== undefined ? { _id: userId } - : { usernameLower: username.toLowerCase(), hostLower: getHostLower(host) } ; + : { usernameLower: username.toLowerCase(), host: getHostLower(host) } ; // Lookup user const user = await User.findOne(q, { diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index 15257b869f..cf51dec4d2 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -118,7 +118,6 @@ export default async (ctx: Koa.Context) => { username: username, usernameLower: username.toLowerCase(), host: null, - hostLower: null, keypair: generateKeypair(), token: secret, email: null, diff --git a/src/services/note/create.ts b/src/services/note/create.ts index b238cd5607..603851adb5 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -78,7 +78,6 @@ export default async (user: IUser, data: { _renote: data.renote ? { userId: data.renote.userId } : null, _user: { host: user.host, - hostLower: user.hostLower, inbox: isRemoteUser(user) ? user.inbox : undefined } }; From 08531e800251609515025b0f544d98e9145e6e0b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:42:18 +0900 Subject: [PATCH 25/62] Add some indexes --- src/models/user.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/models/user.ts b/src/models/user.ts index cf5a4a3616..686bcc5ec5 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -22,6 +22,8 @@ import SwSubscription, { deleteSwSubscription } from './sw-subscription'; const User = db.get('users'); +User.createIndex('username'); +User.createIndex('usernameLower'); User.createIndex(['username', 'host'], { unique: true }); User.createIndex(['usernameLower', 'host'], { unique: true }); User.createIndex('token', { unique: true }); From 6baf793c4c12f409e8c2fd0033b503937ca01bdc Mon Sep 17 00:00:00 2001 From: imncls Date: Sat, 14 Apr 2018 14:52:50 +0900 Subject: [PATCH 26/62] Use more natural words --- DONORS.md => DONATORS.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename DONORS.md => DONATORS.md (90%) diff --git a/DONORS.md b/DONATORS.md similarity index 90% rename from DONORS.md rename to DONATORS.md index 008f3592cd..c60024ee4e 100644 --- a/DONORS.md +++ b/DONATORS.md @@ -1,8 +1,8 @@ -DONORS +DONATORS ====== The list of people who have sent donation for Misskey. -(no particular order) +(In random order, honorific titles are omitted.) * らふぁ * 俺様 diff --git a/README.md b/README.md index ead032615f..e8abd2c209 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ please see [Setup and installation guide](./docs/setup.en.md). ---------------------------------------------------------------- If you want to donate to Misskey, please see [this](./docs/donate.ja.md). -[List of all donors](./DONORS.md) +[List of all donators](./DONATORS.md) :mortar_board: Notable contributors ---------------------------------------------------------------- From b914cfadc50a001d1f970ada22f823e79d095a33 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 23:26:34 +0900 Subject: [PATCH 27/62] Update DONATORS.md --- DONATORS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/DONATORS.md b/DONATORS.md index c60024ee4e..6fe5df04b7 100644 --- a/DONATORS.md +++ b/DONATORS.md @@ -1,5 +1,5 @@ DONATORS -====== +======== The list of people who have sent donation for Misskey. (In random order, honorific titles are omitted.) @@ -15,7 +15,8 @@ The list of people who have sent donation for Misskey. * Maya Minatsuki * Knzk https://knzk.me/@Knzk * ねじりわさび https://knzk.me/@y -* NCLS https://knzk.me/@imncls +* NCLS https://knzk.me/@imncls] +* こじま @skoji@sandbox.skoji.jp :heart: Thanks for donating, guys! From 101492bb8077cb4878812dc51fb1dcbdda611dc2 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sat, 14 Apr 2018 23:34:40 +0900 Subject: [PATCH 28/62] =?UTF-8?q?nameId=20=E2=86=92=20name=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/dev/views/new-app.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/dev/views/new-app.vue b/src/client/app/dev/views/new-app.vue index a3d7af4b97..b293b03752 100644 --- a/src/client/app/dev/views/new-app.vue +++ b/src/client/app/dev/views/new-app.vue @@ -77,7 +77,7 @@ export default Vue.extend({ this.nidState = 'wait'; - (this as any).api('app/nameId/available', { + (this as any).api('app/name_id/available', { nameId: this.nid }).then(result => { this.nidState = result.available ? 'ok' : 'unavailable'; From 93b0fe821b88624177b03438708aa56c41e85adc Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 23:41:25 +0900 Subject: [PATCH 29/62] Fix bug --- src/client/app/dev/views/new-app.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/dev/views/new-app.vue b/src/client/app/dev/views/new-app.vue index b293b03752..bf19e6da57 100644 --- a/src/client/app/dev/views/new-app.vue +++ b/src/client/app/dev/views/new-app.vue @@ -66,7 +66,7 @@ export default Vue.extend({ const err = !this.nid.match(/^[a-zA-Z0-9_]+$/) ? 'invalid-format' : - this.nid.length < 3 ? 'min-range' : + this.nid.length < 1 ? 'min-range' : this.nid.length > 30 ? 'max-range' : null; From 01bf93bc3fef0258157ce732a933d8f3c4f1bdb8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Apr 2018 00:02:16 +0900 Subject: [PATCH 30/62] Add opencollective link --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e8abd2c209..956e56336e 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,11 @@ and more! You can touch with your own eyes at https://misskey.xyz/. If you want to run your own instance of Misskey, please see [Setup and installation guide](./docs/setup.en.md). -:yen: Donation +:heart: Backers ---------------------------------------------------------------- -If you want to donate to Misskey, please see [this](./docs/donate.ja.md). +Support us with a monthly donation and help us continue our activities. -[List of all donators](./DONATORS.md) +[![Backers][backers-image]][support-url] :mortar_board: Notable contributors ---------------------------------------------------------------- @@ -61,6 +61,12 @@ Misskey is an open-source software licensed under [GNU AGPLv3](LICENSE). [himawari-badge]: https://img.shields.io/badge/%E5%8F%A4%E8%B0%B7-%E5%90%91%E6%97%A5%E8%91%B5-1684c5.svg?style=flat-square [sakurako-badge]: https://img.shields.io/badge/%E5%A4%A7%E5%AE%A4-%E6%AB%BB%E5%AD%90-efb02a.svg?style=flat-square +[backer-url]: #backers +[backer-badge]: https://opencollective.com/misskey/backers/badge.svg?color=blue +[backers-image]: https://opencollective.com/misskey/backers.svg + +[support-url]: https://opencollective.com/misskey#support + [syuilo-link]: https://syuilo.com [syuilo-icon]: https://avatars2.githubusercontent.com/u/4439005?v=3&s=70 From a2f4ed0f0934ed0831e75787fdba2af7d2fafc5c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Apr 2018 00:04:20 +0900 Subject: [PATCH 31/62] :v: --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 956e56336e..9d62cd93c0 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,6 @@ please see [Setup and installation guide](./docs/setup.en.md). :heart: Backers ---------------------------------------------------------------- -Support us with a monthly donation and help us continue our activities. - [![Backers][backers-image]][support-url] :mortar_board: Notable contributors From 554570cb0964f9eca6eb3d645a0a2ca0550d4733 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Apr 2018 01:04:40 +0900 Subject: [PATCH 32/62] wip --- src/build/i18n.ts | 15 ++++++- .../connect-failed.troubleshooter.vue | 18 ++++----- .../views/components/connect-failed.vue | 12 +++--- .../app/common/views/components/forkit.vue | 2 +- .../views/components/messaging-room.form.vue | 4 +- .../components/messaging-room.message.vue | 4 +- .../views/components/messaging-room.vue | 8 ++-- .../app/common/views/components/messaging.vue | 6 +-- .../app/common/views/components/nav.vue | 14 +++---- .../app/common/views/components/note-menu.vue | 2 +- .../common/views/components/poll-editor.vue | 10 ++--- .../app/common/views/components/poll.vue | 10 ++--- .../views/components/reaction-picker.vue | 2 +- .../app/common/views/components/signin.vue | 8 ++-- .../app/common/views/components/signup.vue | 40 +++++++++---------- .../views/components/special-message.vue | 4 +- .../views/components/stream-indicator.vue | 6 +-- .../views/components/twitter-setting.vue | 8 ++-- .../app/common/views/components/uploader.vue | 2 +- .../app/common/views/widgets/access-log.vue | 2 +- .../app/common/views/widgets/broadcast.vue | 8 ++-- .../app/common/views/widgets/donation.vue | 6 +-- .../app/common/views/widgets/photo-stream.vue | 4 +- .../app/common/views/widgets/server.vue | 4 +- .../app/desktop/views/components/activity.vue | 4 +- .../app/desktop/views/components/calendar.vue | 8 ++-- .../desktop/views/components/drive-window.vue | 4 +- .../desktop/views/components/drive.file.vue | 28 ++++++------- .../desktop/views/components/drive.folder.vue | 16 ++++---- .../views/components/drive.nav-folder.vue | 2 +- .../app/desktop/views/components/drive.vue | 36 ++++++++--------- .../desktop/views/components/notes.note.vue | 12 +++--- .../views/components/notifications.vue | 2 +- .../views/components/post-form-window.vue | 8 ++-- .../desktop/views/components/post-form.vue | 38 +++++++++--------- .../views/components/renote-form-window.vue | 2 +- .../desktop/views/components/renote-form.vue | 10 ++--- .../views/components/repost-form-window.vue | 2 +- .../desktop/views/components/repost-form.vue | 10 ++--- .../desktop/views/components/settings.2fa.vue | 30 +++++++------- .../desktop/views/components/settings.api.vue | 10 ++--- .../views/components/settings.mute.vue | 2 +- .../views/components/settings.password.vue | 12 +++--- .../views/components/settings.profile.vue | 14 +++---- .../app/desktop/views/components/settings.vue | 22 +++++----- .../views/components/ui.header.account.vue | 10 ++--- .../views/components/ui.header.nav.vue | 4 +- .../components/ui.header.notifications.vue | 2 +- .../views/components/ui.header.post.vue | 2 +- .../views/components/ui.header.search.vue | 2 +- src/client/app/desktop/views/pages/note.vue | 4 +- .../app/desktop/views/pages/selectdrive.vue | 8 ++-- .../pages/user/user.followers-you-know.vue | 6 +-- .../desktop/views/pages/user/user.friends.vue | 6 +-- .../desktop/views/pages/user/user.home.vue | 2 +- .../desktop/views/pages/user/user.photos.vue | 6 +-- .../desktop/views/pages/user/user.profile.vue | 6 +-- .../app/desktop/views/widgets/channel.vue | 6 +-- .../app/desktop/views/widgets/messaging.vue | 2 +- .../desktop/views/widgets/notifications.vue | 4 +- .../app/desktop/views/widgets/polls.vue | 6 +-- .../app/desktop/views/widgets/post-form.vue | 6 +-- .../app/desktop/views/widgets/trends.vue | 6 +-- .../app/desktop/views/widgets/users.vue | 6 +-- .../views/components/drive-file-chooser.vue | 2 +- .../views/components/drive-folder-chooser.vue | 2 +- .../views/components/drive.file-detail.vue | 10 ++--- .../app/mobile/views/components/drive.vue | 18 ++++----- .../mobile/views/components/follow-button.vue | 2 +- .../mobile/views/components/note-detail.vue | 4 +- .../app/mobile/views/components/note.vue | 4 +- .../mobile/views/components/notifications.vue | 4 +- .../app/mobile/views/components/post-form.vue | 4 +- .../views/components/sub-note-content.vue | 2 +- .../app/mobile/views/components/timeline.vue | 4 +- .../app/mobile/views/components/ui.nav.vue | 16 ++++---- .../mobile/views/components/user-timeline.vue | 4 +- .../mobile/views/components/users-list.vue | 6 +-- src/client/app/mobile/views/pages/drive.vue | 2 +- .../app/mobile/views/pages/followers.vue | 6 +-- .../app/mobile/views/pages/following.vue | 6 +-- .../app/mobile/views/pages/messaging-room.vue | 2 +- .../app/mobile/views/pages/messaging.vue | 4 +- src/client/app/mobile/views/pages/note.vue | 6 +-- .../app/mobile/views/pages/notifications.vue | 6 +-- .../mobile/views/pages/profile-setting.vue | 30 +++++++------- src/client/app/mobile/views/pages/search.vue | 6 +-- .../app/mobile/views/pages/selectdrive.vue | 4 +- .../app/mobile/views/pages/settings.vue | 16 ++++---- src/client/app/mobile/views/pages/user.vue | 14 +++---- .../pages/user/home.followers-you-know.vue | 4 +- .../mobile/views/pages/user/home.friends.vue | 4 +- .../mobile/views/pages/user/home.notes.vue | 4 +- .../mobile/views/pages/user/home.photos.vue | 4 +- .../app/mobile/views/pages/user/home.vue | 12 +++--- webpack/loaders/replace.js | 5 ++- 96 files changed, 398 insertions(+), 384 deletions(-) diff --git a/src/build/i18n.ts b/src/build/i18n.ts index b9b7403214..d9dacccd34 100644 --- a/src/build/i18n.ts +++ b/src/build/i18n.ts @@ -44,8 +44,19 @@ export default class Replacer { } } - public replacement(match, a, b, c) { - const key = a || b || c; + public replacement(ctx, match, a, b, c) { + const client = 'misskey/src/client/app/'; + const name = ctx.src.substr(ctx.src.indexOf(client) + client.length); + if (name == '') return match; + + let key = a || b || c; + if (key[0] == '@') { + const prefix = name.split('.')[0].replace(/\//g, '.') + '.'; + //if (name.startsWith('app/desktop/views/')) prefix = 'desktop.views.'; + //if (name.startsWith('app/mobile/views/')) prefix = 'mobile.views.'; + key = prefix + key.substr(1); + } + if (match[0] == '"') { return '"' + this.get(key).replace(/"/g, '\\"') + '"'; } else if (match[0] == "'") { diff --git a/src/client/app/common/views/components/connect-failed.troubleshooter.vue b/src/client/app/common/views/components/connect-failed.troubleshooter.vue index cadbd36ba4..b0a9c87e78 100644 --- a/src/client/app/common/views/components/connect-failed.troubleshooter.vue +++ b/src/client/app/common/views/components/connect-failed.troubleshooter.vue @@ -1,34 +1,34 @@ diff --git a/src/client/app/common/views/components/connect-failed.vue b/src/client/app/common/views/components/connect-failed.vue index 185250dbd8..d90c8756b8 100644 --- a/src/client/app/common/views/components/connect-failed.vue +++ b/src/client/app/common/views/components/connect-failed.vue @@ -1,15 +1,15 @@ diff --git a/src/client/app/common/views/components/forkit.vue b/src/client/app/common/views/components/forkit.vue index 6f334b965a..05971cbf15 100644 --- a/src/client/app/common/views/components/forkit.vue +++ b/src/client/app/common/views/components/forkit.vue @@ -1,5 +1,5 @@ diff --git a/src/client/app/common/views/components/nav.vue b/src/client/app/common/views/components/nav.vue index 8ce75d3529..2295957928 100644 --- a/src/client/app/common/views/components/nav.vue +++ b/src/client/app/common/views/components/nav.vue @@ -1,18 +1,18 @@ diff --git a/src/client/app/common/views/components/poll-editor.vue b/src/client/app/common/views/components/poll-editor.vue index 47d901d7b1..fa1897f435 100644 --- a/src/client/app/common/views/components/poll-editor.vue +++ b/src/client/app/common/views/components/poll-editor.vue @@ -1,18 +1,18 @@ diff --git a/src/client/app/common/views/components/twitter-setting.vue b/src/client/app/common/views/components/twitter-setting.vue index 00669cd833..77788290f6 100644 --- a/src/client/app/common/views/components/twitter-setting.vue +++ b/src/client/app/common/views/components/twitter-setting.vue @@ -1,11 +1,11 @@