From e49f7f40bc15814bdcab84d9fece281ccd257c43 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 13 Apr 2018 23:04:22 +0900 Subject: Update index.ts --- src/server/index.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'src') 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()); -- cgit v1.2.3-freya From fde2782a9eb5dcd7a706bee2401ce44c891c3653 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:45:44 +0900 Subject: Cache url preview --- src/server/web/url-preview.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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; }; -- cgit v1.2.3-freya From 8260464090aefce364ca5ce5d116f12f0b84e617 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:46:03 +0900 Subject: Add note --- src/server/file/index.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'src') 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(); }); -- cgit v1.2.3-freya From 39feb54aab62ec39c94f546c13fe353d8bc9e4c1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:50:43 +0900 Subject: Fix: Add missing semicolon --- src/server/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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()); -- cgit v1.2.3-freya From ec6300f5aee265a6d7051794a1b8111347f4f96d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:54:54 +0900 Subject: :v: --- src/server/index.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') 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); }); -- cgit v1.2.3-freya From 79475f6856d757eb60389f54b2f028bd03c8e747 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 01:56:10 +0900 Subject: set ja as default --- src/client/app/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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'; -- cgit v1.2.3-freya From 3cdb32048849be82757c5641ff46b25993ce1bcc Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:04:55 +0900 Subject: Use require to avoid warning --- src/server/activitypub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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'; -- cgit v1.2.3-freya From 04285c9498859edca86f2f70f7bddda204ecee9d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:23:06 +0900 Subject: Fix bug --- package.json | 1 + src/server/activitypub.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.2.3-freya From 10abe03ed7a5b9c5732d8db2e5c486b6bbad767c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 03:40:12 +0900 Subject: Fix bug --- src/client/app/common/mios.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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; } /** -- cgit v1.2.3-freya From a42b8606245db4ce0f6e775d5ddc84e179cc7af4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 05:16:15 +0900 Subject: 一時的に日本語のみに 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(-) (limited to 'src') 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(); -- cgit v1.2.3-freya From 7eac0bb1d66dbc10f09d1d43f7a997d2c2e0710f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 05:23:13 +0900 Subject: wait 3 sec --- src/client/app/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3-freya From f0be021d851bfca0df4ab71dbbc56edf82134f50 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:18:18 +0900 Subject: Fix bug --- src/client/app/common/mios.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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); -- cgit v1.2.3-freya From 8bf05e47df91f9e15fb30ca8468389a459b8edb7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:27:17 +0900 Subject: Fix bug --- src/server/api/service/twitter.ts | 50 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src') 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); }); + }); + + const twCtx = await get; - ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`; + const result = await twAuth.done(JSON.parse(twCtx), verifier); - // Publish i updated event - event(user._id, 'i_updated', await pack(user, user, { - detail: true, - includeSecrets: true - })); + 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 + })); } }); } -- cgit v1.2.3-freya From bf57b2ad1362e2ea619c3a23aba337e6ac54e738 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:41:33 +0900 Subject: Fix bug --- src/server/api/service/twitter.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src') 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 get = new Promise((res, rej) => { + redis.get(sessid, async (_, twCtx) => { + res(twCtx); + }); + }); - const user = await User.findOne({ - host: null, - 'twitter.userId': result.userId - }) as ILocalUser; + const twCtx = await get; - if (user == null) { - ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`); - return; - } + const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier); - signin(ctx, user, true); - }); + 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; -- cgit v1.2.3-freya From bcc5449e47956e9786646abf688a3161aa89912a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:22:58 +0900 Subject: リモートユーザーはおすすめユーザーに含めないように 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(-) (limited to 'src') 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, -- cgit v1.2.3-freya From 26c979bcece39a81133eb42c3d043c8be9c028f1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:29:18 +0900 Subject: Better indexes --- src/models/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-freya From d81c20f163f0884d04cd11e46221bfefc0ac9f22 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:39:07 +0900 Subject: hostLowerは廃止してhostにlowerしたものを入れるように 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(-) (limited to 'src') 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 } }; -- cgit v1.2.3-freya From 08531e800251609515025b0f544d98e9145e6e0b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 14:42:18 +0900 Subject: Add some indexes --- src/models/user.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') 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 }); -- cgit v1.2.3-freya From 101492bb8077cb4878812dc51fb1dcbdda611dc2 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sat, 14 Apr 2018 23:34:40 +0900 Subject: nameId → name_id 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(-) (limited to 'src') 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'; -- cgit v1.2.3-freya From 93b0fe821b88624177b03438708aa56c41e85adc Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 23:41:25 +0900 Subject: Fix bug --- src/client/app/dev/views/new-app.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.2.3-freya From 554570cb0964f9eca6eb3d645a0a2ca0550d4733 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Apr 2018 01:04:40 +0900 Subject: wip --- src/build/i18n.ts | 15 ++++++-- .../components/connect-failed.troubleshooter.vue | 18 +++++----- .../app/common/views/components/connect-failed.vue | 12 +++---- src/client/app/common/views/components/forkit.vue | 2 +- .../views/components/messaging-room.form.vue | 4 +-- .../views/components/messaging-room.message.vue | 4 +-- .../app/common/views/components/messaging-room.vue | 8 ++--- .../app/common/views/components/messaging.vue | 6 ++-- src/client/app/common/views/components/nav.vue | 14 ++++---- .../app/common/views/components/note-menu.vue | 2 +- .../app/common/views/components/poll-editor.vue | 10 +++--- src/client/app/common/views/components/poll.vue | 10 +++--- .../common/views/components/reaction-picker.vue | 2 +- src/client/app/common/views/components/signin.vue | 8 ++--- src/client/app/common/views/components/signup.vue | 40 +++++++++++----------- .../common/views/components/special-message.vue | 4 +-- .../common/views/components/stream-indicator.vue | 6 ++-- .../common/views/components/twitter-setting.vue | 8 ++--- .../app/common/views/components/uploader.vue | 2 +- src/client/app/common/views/widgets/access-log.vue | 2 +- src/client/app/common/views/widgets/broadcast.vue | 8 ++--- src/client/app/common/views/widgets/donation.vue | 6 ++-- .../app/common/views/widgets/photo-stream.vue | 4 +-- src/client/app/common/views/widgets/server.vue | 4 +-- .../app/desktop/views/components/activity.vue | 4 +-- .../app/desktop/views/components/calendar.vue | 8 ++--- .../app/desktop/views/components/drive-window.vue | 4 +-- .../app/desktop/views/components/drive.file.vue | 28 +++++++-------- .../app/desktop/views/components/drive.folder.vue | 16 ++++----- .../desktop/views/components/drive.nav-folder.vue | 2 +- src/client/app/desktop/views/components/drive.vue | 36 +++++++++---------- .../app/desktop/views/components/notes.note.vue | 12 +++---- .../app/desktop/views/components/notifications.vue | 2 +- .../desktop/views/components/post-form-window.vue | 8 ++--- .../app/desktop/views/components/post-form.vue | 38 ++++++++++---------- .../views/components/renote-form-window.vue | 2 +- .../app/desktop/views/components/renote-form.vue | 10 +++--- .../views/components/repost-form-window.vue | 2 +- .../app/desktop/views/components/repost-form.vue | 10 +++--- .../app/desktop/views/components/settings.2fa.vue | 30 ++++++++-------- .../app/desktop/views/components/settings.api.vue | 10 +++--- .../app/desktop/views/components/settings.mute.vue | 2 +- .../desktop/views/components/settings.password.vue | 12 +++---- .../desktop/views/components/settings.profile.vue | 14 ++++---- .../app/desktop/views/components/settings.vue | 22 ++++++------ .../desktop/views/components/ui.header.account.vue | 10 +++--- .../app/desktop/views/components/ui.header.nav.vue | 4 +-- .../views/components/ui.header.notifications.vue | 2 +- .../desktop/views/components/ui.header.post.vue | 2 +- .../desktop/views/components/ui.header.search.vue | 2 +- src/client/app/desktop/views/pages/note.vue | 4 +-- src/client/app/desktop/views/pages/selectdrive.vue | 8 ++--- .../views/pages/user/user.followers-you-know.vue | 6 ++-- .../app/desktop/views/pages/user/user.friends.vue | 6 ++-- .../app/desktop/views/pages/user/user.home.vue | 2 +- .../app/desktop/views/pages/user/user.photos.vue | 6 ++-- .../app/desktop/views/pages/user/user.profile.vue | 6 ++-- src/client/app/desktop/views/widgets/channel.vue | 6 ++-- src/client/app/desktop/views/widgets/messaging.vue | 2 +- .../app/desktop/views/widgets/notifications.vue | 4 +-- src/client/app/desktop/views/widgets/polls.vue | 6 ++-- src/client/app/desktop/views/widgets/post-form.vue | 6 ++-- src/client/app/desktop/views/widgets/trends.vue | 6 ++-- src/client/app/desktop/views/widgets/users.vue | 6 ++-- .../mobile/views/components/drive-file-chooser.vue | 2 +- .../views/components/drive-folder-chooser.vue | 2 +- .../mobile/views/components/drive.file-detail.vue | 10 +++--- src/client/app/mobile/views/components/drive.vue | 18 +++++----- .../app/mobile/views/components/follow-button.vue | 2 +- .../app/mobile/views/components/note-detail.vue | 4 +-- src/client/app/mobile/views/components/note.vue | 4 +-- .../app/mobile/views/components/notifications.vue | 4 +-- .../app/mobile/views/components/post-form.vue | 4 +-- .../mobile/views/components/sub-note-content.vue | 2 +- .../app/mobile/views/components/timeline.vue | 4 +-- src/client/app/mobile/views/components/ui.nav.vue | 16 ++++----- .../app/mobile/views/components/user-timeline.vue | 4 +-- .../app/mobile/views/components/users-list.vue | 6 ++-- src/client/app/mobile/views/pages/drive.vue | 2 +- src/client/app/mobile/views/pages/followers.vue | 6 ++-- src/client/app/mobile/views/pages/following.vue | 6 ++-- .../app/mobile/views/pages/messaging-room.vue | 2 +- src/client/app/mobile/views/pages/messaging.vue | 4 +-- src/client/app/mobile/views/pages/note.vue | 6 ++-- .../app/mobile/views/pages/notifications.vue | 6 ++-- .../app/mobile/views/pages/profile-setting.vue | 30 ++++++++-------- src/client/app/mobile/views/pages/search.vue | 6 ++-- src/client/app/mobile/views/pages/selectdrive.vue | 4 +-- src/client/app/mobile/views/pages/settings.vue | 16 ++++----- src/client/app/mobile/views/pages/user.vue | 14 ++++---- .../views/pages/user/home.followers-you-know.vue | 4 +-- .../app/mobile/views/pages/user/home.friends.vue | 4 +-- .../app/mobile/views/pages/user/home.notes.vue | 4 +-- .../app/mobile/views/pages/user/home.photos.vue | 4 +-- src/client/app/mobile/views/pages/user/home.vue | 12 +++---- webpack/loaders/replace.js | 5 ++- 96 files changed, 398 insertions(+), 384 deletions(-) (limited to 'src') 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 @@