From c614e6f5d73b3b4314c7f6abf52260e58cc176ad Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2017 01:24:44 +0900 Subject: #925, #926, and refactoring --- .../app/common/scripts/streaming/channel-stream.ts | 12 +++ .../scripts/streaming/drive-stream-manager.ts | 20 +++++ .../app/common/scripts/streaming/drive-stream.ts | 12 +++ .../scripts/streaming/home-stream-manager.ts | 20 +++++ .../app/common/scripts/streaming/home-stream.ts | 28 +++++++ .../streaming/messaging-index-stream-manager.ts | 20 +++++ .../scripts/streaming/messaging-index-stream.ts | 12 +++ .../common/scripts/streaming/messaging-stream.ts | 19 +++++ .../scripts/streaming/requests-stream-manager.ts | 12 +++ .../common/scripts/streaming/requests-stream.ts | 10 +++ .../scripts/streaming/server-stream-manager.ts | 12 +++ .../app/common/scripts/streaming/server-stream.ts | 10 +++ .../app/common/scripts/streaming/stream-manager.ts | 73 +++++++++++++++++ src/web/app/common/scripts/streaming/stream.ts | 95 ++++++++++++++++++++++ 14 files changed, 355 insertions(+) create mode 100644 src/web/app/common/scripts/streaming/channel-stream.ts create mode 100644 src/web/app/common/scripts/streaming/drive-stream-manager.ts create mode 100644 src/web/app/common/scripts/streaming/drive-stream.ts create mode 100644 src/web/app/common/scripts/streaming/home-stream-manager.ts create mode 100644 src/web/app/common/scripts/streaming/home-stream.ts create mode 100644 src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts create mode 100644 src/web/app/common/scripts/streaming/messaging-index-stream.ts create mode 100644 src/web/app/common/scripts/streaming/messaging-stream.ts create mode 100644 src/web/app/common/scripts/streaming/requests-stream-manager.ts create mode 100644 src/web/app/common/scripts/streaming/requests-stream.ts create mode 100644 src/web/app/common/scripts/streaming/server-stream-manager.ts create mode 100644 src/web/app/common/scripts/streaming/server-stream.ts create mode 100644 src/web/app/common/scripts/streaming/stream-manager.ts create mode 100644 src/web/app/common/scripts/streaming/stream.ts (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/channel-stream.ts b/src/web/app/common/scripts/streaming/channel-stream.ts new file mode 100644 index 0000000000..434b108b9e --- /dev/null +++ b/src/web/app/common/scripts/streaming/channel-stream.ts @@ -0,0 +1,12 @@ +import Stream from './stream'; + +/** + * Channel stream connection + */ +export default class Connection extends Stream { + constructor(channelId) { + super('channel', { + channel: channelId + }); + } +} diff --git a/src/web/app/common/scripts/streaming/drive-stream-manager.ts b/src/web/app/common/scripts/streaming/drive-stream-manager.ts new file mode 100644 index 0000000000..8acdd7cbba --- /dev/null +++ b/src/web/app/common/scripts/streaming/drive-stream-manager.ts @@ -0,0 +1,20 @@ +import StreamManager from './stream-manager'; +import Connection from './drive-stream'; + +export default class DriveStreamManager extends StreamManager { + private me; + + constructor(me) { + super(); + + this.me = me; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new Connection(this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/drive-stream.ts b/src/web/app/common/scripts/streaming/drive-stream.ts new file mode 100644 index 0000000000..0da3f12554 --- /dev/null +++ b/src/web/app/common/scripts/streaming/drive-stream.ts @@ -0,0 +1,12 @@ +import Stream from './stream'; + +/** + * Drive stream connection + */ +export default class Connection extends Stream { + constructor(me) { + super('drive', { + i: me.token + }); + } +} diff --git a/src/web/app/common/scripts/streaming/home-stream-manager.ts b/src/web/app/common/scripts/streaming/home-stream-manager.ts new file mode 100644 index 0000000000..ad1dc870eb --- /dev/null +++ b/src/web/app/common/scripts/streaming/home-stream-manager.ts @@ -0,0 +1,20 @@ +import StreamManager from './stream-manager'; +import Connection from './home-stream'; + +export default class HomeStreamManager extends StreamManager { + private me; + + constructor(me) { + super(); + + this.me = me; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new Connection(this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/home-stream.ts b/src/web/app/common/scripts/streaming/home-stream.ts new file mode 100644 index 0000000000..a78f4acdbe --- /dev/null +++ b/src/web/app/common/scripts/streaming/home-stream.ts @@ -0,0 +1,28 @@ +import Stream from './stream'; +import signout from '../signout'; + +/** + * Home stream connection + */ +export default class Connection extends Stream { + constructor(me) { + super('', { + i: me.token + }); + + // 最終利用日時を更新するため定期的にaliveメッセージを送信 + setInterval(() => { + this.send({ type: 'alive' }); + }, 1000 * 60); + + // 自分の情報が更新されたとき + (this as any).on('i_updated', me.update); + + // トークンが再生成されたとき + // このままではAPIが利用できないので強制的にサインアウトさせる + (this as any).on('my_token_regenerated', () => { + alert('%i18n:common.my-token-regenerated%'); + signout(); + }); + } +} diff --git a/src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts b/src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts new file mode 100644 index 0000000000..0f08b01481 --- /dev/null +++ b/src/web/app/common/scripts/streaming/messaging-index-stream-manager.ts @@ -0,0 +1,20 @@ +import StreamManager from './stream-manager'; +import Connection from './messaging-index-stream'; + +export default class MessagingIndexStreamManager extends StreamManager { + private me; + + constructor(me) { + super(); + + this.me = me; + } + + public getConnection() { + if (this.connection == null) { + this.connection = new Connection(this.me); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/messaging-index-stream.ts b/src/web/app/common/scripts/streaming/messaging-index-stream.ts new file mode 100644 index 0000000000..8015c840b4 --- /dev/null +++ b/src/web/app/common/scripts/streaming/messaging-index-stream.ts @@ -0,0 +1,12 @@ +import Stream from './stream'; + +/** + * Messaging index stream connection + */ +export default class Connection extends Stream { + constructor(me) { + super('messaging-index', { + i: me.token + }); + } +} diff --git a/src/web/app/common/scripts/streaming/messaging-stream.ts b/src/web/app/common/scripts/streaming/messaging-stream.ts new file mode 100644 index 0000000000..68dfc5ec09 --- /dev/null +++ b/src/web/app/common/scripts/streaming/messaging-stream.ts @@ -0,0 +1,19 @@ +import Stream from './stream'; + +/** + * Messaging stream connection + */ +export default class Connection extends Stream { + constructor(me, otherparty) { + super('messaging', { + i: me.token, + otherparty + }); + + (this as any).on('_connected_', () => { + this.send({ + i: me.token + }); + }); + } +} diff --git a/src/web/app/common/scripts/streaming/requests-stream-manager.ts b/src/web/app/common/scripts/streaming/requests-stream-manager.ts new file mode 100644 index 0000000000..44db913e78 --- /dev/null +++ b/src/web/app/common/scripts/streaming/requests-stream-manager.ts @@ -0,0 +1,12 @@ +import StreamManager from './stream-manager'; +import Connection from './requests-stream'; + +export default class RequestsStreamManager extends StreamManager { + public getConnection() { + if (this.connection == null) { + this.connection = new Connection(); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/requests-stream.ts b/src/web/app/common/scripts/streaming/requests-stream.ts new file mode 100644 index 0000000000..22ecea6c07 --- /dev/null +++ b/src/web/app/common/scripts/streaming/requests-stream.ts @@ -0,0 +1,10 @@ +import Stream from './stream'; + +/** + * Requests stream connection + */ +export default class Connection extends Stream { + constructor() { + super('requests'); + } +} diff --git a/src/web/app/common/scripts/streaming/server-stream-manager.ts b/src/web/app/common/scripts/streaming/server-stream-manager.ts new file mode 100644 index 0000000000..a170daebb9 --- /dev/null +++ b/src/web/app/common/scripts/streaming/server-stream-manager.ts @@ -0,0 +1,12 @@ +import StreamManager from './stream-manager'; +import Connection from './server-stream'; + +export default class ServerStreamManager extends StreamManager { + public getConnection() { + if (this.connection == null) { + this.connection = new Connection(); + } + + return this.connection; + } +} diff --git a/src/web/app/common/scripts/streaming/server-stream.ts b/src/web/app/common/scripts/streaming/server-stream.ts new file mode 100644 index 0000000000..b9e0684465 --- /dev/null +++ b/src/web/app/common/scripts/streaming/server-stream.ts @@ -0,0 +1,10 @@ +import Stream from './stream'; + +/** + * Server stream connection + */ +export default class Connection extends Stream { + constructor() { + super('server'); + } +} diff --git a/src/web/app/common/scripts/streaming/stream-manager.ts b/src/web/app/common/scripts/streaming/stream-manager.ts new file mode 100644 index 0000000000..de27235426 --- /dev/null +++ b/src/web/app/common/scripts/streaming/stream-manager.ts @@ -0,0 +1,73 @@ +import { EventEmitter } from 'eventemitter3'; +import * as uuid from 'uuid'; +import Connection from './stream'; + +/** + * ストリーム接続を管理するクラス + * 複数の場所から同じストリームを利用する際、接続をまとめたりする + */ +export default abstract class StreamManager extends EventEmitter { + protected _connection: T = null; + + /** + * コネクションを必要としているユーザー + */ + private users = []; + + protected set connection(connection: T) { + this._connection = connection; + + if (this._connection == null) { + this.emit('disconnected'); + } else { + this.emit('connected', this._connection); + } + } + + protected get connection() { + return this._connection; + } + + /** + * コネクションを持っているか否か + */ + public get hasConnection() { + return this._connection != null; + } + + /** + * コネクションを要求します + */ + public abstract getConnection(): T; + + public borrow() { + return this._connection; + } + + /** + * コネクションを要求するためのユーザーIDを発行します + */ + public use() { + // ユーザーID生成 + const userId = uuid(); + + this.users.push(userId); + + return userId; + } + + /** + * コネクションを利用し終わってもう必要ないことを通知します + * @param userId use で発行したユーザーID + */ + public dispose(userId) { + this.users = this.users.filter(id => id != userId); + + // 誰もコネクションの利用者がいなくなったら + if (this.users.length == 0) { + // コネクションを切断する + this.connection.close(); + this.connection = null; + } + } +} diff --git a/src/web/app/common/scripts/streaming/stream.ts b/src/web/app/common/scripts/streaming/stream.ts new file mode 100644 index 0000000000..97ebdcdd74 --- /dev/null +++ b/src/web/app/common/scripts/streaming/stream.ts @@ -0,0 +1,95 @@ +import { EventEmitter } from 'eventemitter3'; +import * as ReconnectingWebsocket from 'reconnecting-websocket'; +import CONFIG from '../config'; + +/** + * Misskey stream connection + */ +export default class Connection extends EventEmitter { + private state: string; + private buffer: any[]; + private socket: ReconnectingWebsocket; + + constructor(endpoint, params?) { + super(); + + //#region BIND + this.onOpen = this.onOpen.bind(this); + this.onClose = this.onClose.bind(this); + this.onMessage = this.onMessage.bind(this); + this.send = this.send.bind(this); + this.close = this.close.bind(this); + //#endregion + + this.state = 'initializing'; + this.buffer = []; + + const host = CONFIG.apiUrl.replace('http', 'ws'); + const query = params + ? Object.keys(params) + .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) + .join('&') + : null; + + this.socket = new ReconnectingWebsocket(`${host}/${endpoint}${query ? '?' + query : ''}`); + this.socket.addEventListener('open', this.onOpen); + this.socket.addEventListener('close', this.onClose); + this.socket.addEventListener('message', this.onMessage); + } + + /** + * Callback of when open connection + */ + private onOpen() { + this.state = 'connected'; + this.emit('_connected_'); + + // バッファーを処理 + const _buffer = [].concat(this.buffer); // Shallow copy + this.buffer = []; // Clear buffer + _buffer.forEach(message => { + this.send(message); // Resend each buffered messages + }); + } + + /** + * Callback of when close connection + */ + private onClose() { + this.state = 'reconnecting'; + this.emit('_closed_'); + } + + /** + * Callback of when received a message from connection + */ + private onMessage(message) { + try { + const msg = JSON.parse(message.data); + if (msg.type) this.emit(msg.type, msg.body); + } catch (e) { + // noop + } + } + + /** + * Send a message to connection + */ + public send(message) { + // まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する + if (this.state != 'connected') { + this.buffer.push(message); + return; + } + + this.socket.send(JSON.stringify(message)); + } + + /** + * Close this connection + */ + public close() { + this.socket.removeEventListener('open', this.onOpen); + this.socket.removeEventListener('message', this.onMessage); + } +} -- cgit v1.2.3-freya From bb0f9d5de9298d7629aeb091cfe737080e2cfd4f Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2017 01:30:15 +0900 Subject: Fix access level --- src/web/app/common/scripts/streaming/stream-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/stream-manager.ts b/src/web/app/common/scripts/streaming/stream-manager.ts index de27235426..98dbcf9d8d 100644 --- a/src/web/app/common/scripts/streaming/stream-manager.ts +++ b/src/web/app/common/scripts/streaming/stream-manager.ts @@ -7,7 +7,7 @@ import Connection from './stream'; * 複数の場所から同じストリームを利用する際、接続をまとめたりする */ export default abstract class StreamManager extends EventEmitter { - protected _connection: T = null; + private _connection: T = null; /** * コネクションを必要としているユーザー -- cgit v1.2.3-freya From 96d2aadd703ec5db6dba1323b22ae37f338e0a93 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2017 01:30:47 +0900 Subject: Add note --- src/web/app/common/scripts/streaming/stream-manager.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/stream-manager.ts b/src/web/app/common/scripts/streaming/stream-manager.ts index 98dbcf9d8d..1383b97828 100644 --- a/src/web/app/common/scripts/streaming/stream-manager.ts +++ b/src/web/app/common/scripts/streaming/stream-manager.ts @@ -40,6 +40,9 @@ export default abstract class StreamManager extends EventE */ public abstract getConnection(): T; + /** + * 現在接続しているコネクションを取得します + */ public borrow() { return this._connection; } -- cgit v1.2.3-freya From 842b5e878fc3162f73a58a95efcdb2cf22b1178d Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2017 03:28:37 +0900 Subject: Update home-stream.ts --- src/web/app/common/scripts/streaming/home-stream.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/home-stream.ts b/src/web/app/common/scripts/streaming/home-stream.ts index a78f4acdbe..11ad754ef0 100644 --- a/src/web/app/common/scripts/streaming/home-stream.ts +++ b/src/web/app/common/scripts/streaming/home-stream.ts @@ -16,11 +16,11 @@ export default class Connection extends Stream { }, 1000 * 60); // 自分の情報が更新されたとき - (this as any).on('i_updated', me.update); + this.on('i_updated', me.update); // トークンが再生成されたとき // このままではAPIが利用できないので強制的にサインアウトさせる - (this as any).on('my_token_regenerated', () => { + this.on('my_token_regenerated', () => { alert('%i18n:common.my-token-regenerated%'); signout(); }); -- cgit v1.2.3-freya From 3ca3cd8d650a690a314feaf18373c0fce48aad90 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2017 21:14:03 +0900 Subject: #928 --- src/web/app/common/scripts/streaming/stream-manager.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/stream-manager.ts b/src/web/app/common/scripts/streaming/stream-manager.ts index 1383b97828..23ad48970e 100644 --- a/src/web/app/common/scripts/streaming/stream-manager.ts +++ b/src/web/app/common/scripts/streaming/stream-manager.ts @@ -9,6 +9,8 @@ import Connection from './stream'; export default abstract class StreamManager extends EventEmitter { private _connection: T = null; + private disposeTimerId: any; + /** * コネクションを必要としているユーザー */ @@ -51,6 +53,12 @@ export default abstract class StreamManager extends EventE * コネクションを要求するためのユーザーIDを発行します */ public use() { + // タイマー解除 + if (this.disposeTimerId) { + clearTimeout(this.disposeTimerId); + this.disposeTimerId = null; + } + // ユーザーID生成 const userId = uuid(); @@ -68,9 +76,12 @@ export default abstract class StreamManager extends EventE // 誰もコネクションの利用者がいなくなったら if (this.users.length == 0) { - // コネクションを切断する - this.connection.close(); - this.connection = null; + // また直ぐに再利用される可能性があるので、一定時間待ち、 + // 新たな利用者が現れなければコネクションを切断する + this.disposeTimerId = setTimeout(() => { + this.connection.close(); + this.connection = null; + }, 3000); } } } -- cgit v1.2.3-freya From 918f2cf6cf64663048ab78af349818b0f33d5455 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2017 21:17:30 +0900 Subject: :v: --- src/web/app/common/scripts/streaming/stream-manager.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/stream-manager.ts b/src/web/app/common/scripts/streaming/stream-manager.ts index 23ad48970e..5bb0dc701c 100644 --- a/src/web/app/common/scripts/streaming/stream-manager.ts +++ b/src/web/app/common/scripts/streaming/stream-manager.ts @@ -79,6 +79,8 @@ export default abstract class StreamManager extends EventE // また直ぐに再利用される可能性があるので、一定時間待ち、 // 新たな利用者が現れなければコネクションを切断する this.disposeTimerId = setTimeout(() => { + this.disposeTimerId = null; + this.connection.close(); this.connection = null; }, 3000); -- cgit v1.2.3-freya From 3f8ebac466ece8e9598432f3f574ec44e420c03b Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Nov 2017 05:43:00 +0900 Subject: なんかもうめっちゃ変えた MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #940 --- .travis/default.yml | 4 +- .travis/test.yml | 4 +- docs/config.md | 55 ++++++++++++++++++++++ docs/setup.en.md | 27 ++++------- docs/setup.ja.md | 29 ++++-------- src/api/common/push-sw.ts | 6 ++- src/api/private/signup.ts | 2 +- src/config.ts | 31 ++++++------ src/web/app/ch/tags/channel.tag | 13 ++--- src/web/app/ch/tags/header.tag | 6 +-- src/web/app/common/mios.ts | 37 ++++++++++++--- src/web/app/common/scripts/api.ts | 4 +- src/web/app/common/scripts/check-for-update.ts | 6 +-- src/web/app/common/scripts/config.ts | 27 ----------- src/web/app/common/scripts/signout.ts | 4 +- src/web/app/common/scripts/streaming/stream.ts | 5 +- src/web/app/common/scripts/text-compiler.ts | 5 +- src/web/app/common/tags/error.tag | 4 +- src/web/app/common/tags/introduction.tag | 2 +- src/web/app/common/tags/nav-links.tag | 2 +- src/web/app/common/tags/signup.tag | 26 +++++----- src/web/app/common/tags/twitter-setting.tag | 12 ++--- src/web/app/common/tags/uploader.tag | 2 +- src/web/app/desktop/scripts/fuck-ad-block.ts | 2 +- src/web/app/desktop/scripts/update-avatar.ts | 5 +- src/web/app/desktop/scripts/update-banner.ts | 5 +- src/web/app/desktop/tags/analog-clock.tag | 2 +- src/web/app/desktop/tags/drive/browser-window.tag | 6 +-- .../app/desktop/tags/home-widgets/broadcast.tag | 4 +- src/web/app/desktop/tags/home-widgets/channel.tag | 2 +- src/web/app/desktop/tags/home-widgets/version.tag | 4 +- src/web/app/desktop/tags/messaging/room-window.tag | 4 +- src/web/app/desktop/tags/pages/entrance.tag | 2 +- src/web/app/desktop/tags/timeline.tag | 2 +- src/web/app/desktop/tags/ui.tag | 4 +- src/web/app/init.ts | 20 ++++---- src/web/app/mobile/tags/page/settings.tag | 4 +- src/web/app/mobile/tags/timeline.tag | 2 +- src/web/app/mobile/tags/ui.tag | 4 +- src/web/app/stats/tags/index.tag | 2 +- src/web/app/status/tags/index.tag | 2 +- src/web/server.ts | 26 +--------- webpack/module/rules/consts.ts | 36 ++++++++++++++ webpack/module/rules/index.ts | 2 + webpack/plugins/const.ts | 14 ------ webpack/plugins/index.ts | 2 - 46 files changed, 244 insertions(+), 225 deletions(-) create mode 100644 docs/config.md delete mode 100644 src/web/app/common/scripts/config.ts create mode 100644 webpack/module/rules/consts.ts delete mode 100644 webpack/plugins/const.ts (limited to 'src/web/app/common/scripts/streaming') diff --git a/.travis/default.yml b/.travis/default.yml index 1875748d68..471a2a7c46 100644 --- a/.travis/default.yml +++ b/.travis/default.yml @@ -22,5 +22,5 @@ elasticsearch: port: 9200 pass: '' recaptcha: - siteKey: hima - secretKey: saku + site_key: hima + secret_key: saku diff --git a/.travis/test.yml b/.travis/test.yml index f311310c7c..6a115d6ab8 100644 --- a/.travis/test.yml +++ b/.travis/test.yml @@ -22,5 +22,5 @@ elasticsearch: port: 9200 pass: '' recaptcha: - siteKey: hima - secretKey: saku + site_key: hima + secret_key: saku diff --git a/docs/config.md b/docs/config.md new file mode 100644 index 0000000000..0e23e09ae8 --- /dev/null +++ b/docs/config.md @@ -0,0 +1,55 @@ +``` yaml +# サーバーのメンテナ情報 +maintainer: + # メンテナの名前 + name: + + # メンテナの連絡先(URLかmailto形式のURL) + url: + +# プライマリURL +url: + +# セカンダリURL +secondary_url: + +# 待受ポート +port: + +# TLSの設定 +https: + # TLSを有効にするか否か + enable: false + + key: null + cert: null + ca: null + +# MongoDBの設定 +mongodb: + host: localhost + port: 27017 + db: misskey + user: + pass: + +# Redisの設定 +redis: + host: localhost + port: 6379 + pass: + +# reCAPTCHAの設定 +recaptcha: + site_key: + secret_key: + +# ServiceWrokerの設定 +sw: + # VAPIDの公開鍵 + public_key: + + # VAPIDの秘密鍵 + private_key: + +``` diff --git a/docs/setup.en.md b/docs/setup.en.md index 5ad57d5abd..9c31e4f177 100644 --- a/docs/setup.en.md +++ b/docs/setup.en.md @@ -36,6 +36,15 @@ Note that Misskey uses following subdomains: Misskey requires reCAPTCHA tokens. Please visit https://www.google.com/recaptcha/intro/ and generate keys. +*(optional)* Generating VAPID keys +---------------------------------------------------------------- +If you want to enable ServiceWroker, you need to generate VAPID keys: + +``` shell +npm install web-push -g +web-push generate-vapid-keys +``` + *3.* Install dependencies ---------------------------------------------------------------- Please install and setup these softwares: @@ -51,24 +60,6 @@ Please install and setup these softwares: *4.* Install Misskey ---------------------------------------------------------------- -There is **two ways** to install Misskey: - -### WAY 1) Using built code (recommended) -We have the official release of Misskey. -The built code is automatically pushed to https://github.com/syuilo/misskey/tree/release after the CI test succeeds. - -1. `git clone -b release git://github.com/syuilo/misskey.git` -2. `cd misskey` -3. `npm install` - -#### Update -1. `git fetch` -2. `git reset --hard origin/release` -3. `npm install` - -### WAY 2) Using source code -If you want to build Misskey manually, you can do it via the -`build` command after download the source code of Misskey and install dependencies: 1. `git clone -b master git://github.com/syuilo/misskey.git` 2. `cd misskey` diff --git a/docs/setup.ja.md b/docs/setup.ja.md index 602fd9b6a1..1e8bb553fa 100644 --- a/docs/setup.ja.md +++ b/docs/setup.ja.md @@ -37,6 +37,15 @@ Misskeyは以下のサブドメインを使います: MisskeyはreCAPTCHAトークンを必要とします。 https://www.google.com/recaptcha/intro/ にアクセスしてトークンを生成してください。 +*(オプション)* VAPIDキーペアの生成 +---------------------------------------------------------------- +ServiceWorkerを有効にする場合、VAPIDキーペアを生成する必要があります: + +``` shell +npm install web-push -g +web-push generate-vapid-keys +``` + *3.* 依存関係をインストールする ---------------------------------------------------------------- これらのソフトウェアをインストール・設定してください: @@ -52,26 +61,6 @@ https://www.google.com/recaptcha/intro/ にアクセスしてトークンを生 *4.* Misskeyのインストール ---------------------------------------------------------------- -Misskeyをインストールするには**2つの方法**があります: - -### 方法 1) ビルドされたコードを利用する (推奨) -Misskeyには公式のリリースがあります。 -ビルドされたコードはCIテストに合格した後、自動で https://github.com/syuilo/misskey/tree/release にpushされています。 - -1. `git clone -b release git://github.com/syuilo/misskey.git` -2. `cd misskey` -3. `npm install` - -#### アップデートするには: -1. `git fetch` -2. `git reset --hard origin/release` -3. `npm install` - -### 方法 2) ソースコードを利用する -> 注: この方法では正しくビルド・動作できることは保証されません。 - -Misskeyを手動でビルドしたい場合は、Misskeyのソースコードと依存関係をインストールした後、 -`build`コマンドを用いることができます: 1. `git clone -b master git://github.com/syuilo/misskey.git` 2. `cd misskey` diff --git a/src/api/common/push-sw.ts b/src/api/common/push-sw.ts index 782a4a6a6c..2993c760ee 100644 --- a/src/api/common/push-sw.ts +++ b/src/api/common/push-sw.ts @@ -4,7 +4,11 @@ import Subscription from '../models/sw-subscription'; import config from '../../conf'; if (config.sw) { - push.setGCMAPIKey(config.sw.gcm_api_key); + // アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録 + push.setVapidDetails( + config.maintainer.url, + config.sw.public_key, + config.sw.private_key); } export default async function(userId: mongo.ObjectID | string, type, body?) { diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index e24734f80c..466c6a489f 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -9,7 +9,7 @@ import generateUserToken from '../common/generate-native-user-token'; import config from '../../conf'; recaptcha.init({ - secret_key: config.recaptcha.secretKey + secret_key: config.recaptcha.secret_key }); const home = { diff --git a/src/config.ts b/src/config.ts index e8322d8333..7237b666f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,7 +3,6 @@ */ import * as fs from 'fs'; -import * as URL from 'url'; import * as yaml from 'js-yaml'; import isUrl = require('is-url'); @@ -23,7 +22,19 @@ export const path = process.env.NODE_ENV == 'test' * ユーザーが設定する必要のある情報 */ type Source = { - maintainer: string; + /** + * メンテナ情報 + */ + maintainer: { + /** + * メンテナの名前 + */ + name: string; + /** + * メンテナの連絡先(URLかmailto形式のURL) + */ + url: string; + }; url: string; secondary_url: string; port: number; @@ -52,8 +63,8 @@ type Source = { pass: string; }; recaptcha: { - siteKey: string; - secretKey: string; + site_key: string; + secret_key: string; }; accesslog?: string; accesses?: { @@ -80,8 +91,8 @@ type Source = { * Service Worker */ sw?: { - gcm_sender_id: string; - gcm_api_key: string; + public_key: string; + private_key: string; }; }; @@ -114,14 +125,6 @@ export default function load() { if (!isUrl(config.url)) urlError(config.url); if (!isUrl(config.secondary_url)) urlError(config.secondary_url); - const url = URL.parse(config.url); - const head = url.host.split('.')[0]; - - if (head != 'misskey' && head != 'localhost') { - console.error(`プライマリドメインは、必ず「misskey」ドメインで始まっていなければなりません(現在の設定では「${head}」で始まっています)。例えば「https://misskey.xyz」「http://misskey.my.app.example.com」などが正しいプライマリURLです。`); - process.exit(); - } - config.url = normalizeUrl(config.url); config.secondary_url = normalizeUrl(config.secondary_url); diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index 8300bd5715..716d61cde4 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -26,11 +26,11 @@
-

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

+

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


- Misskey ver { version } (葵 aoi) + Misskey ver { _VERSION_ } (葵 aoi)
diff --git a/src/web/app/desktop/tags/messaging/room-window.tag b/src/web/app/desktop/tags/messaging/room-window.tag index dca0172be3..1c6ff7c4bc 100644 --- a/src/web/app/desktop/tags/messaging/room-window.tag +++ b/src/web/app/desktop/tags/messaging/room-window.tag @@ -19,11 +19,9 @@ diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag index 1d6ce23598..074422a20e 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 0c969d3902..bad6bf73fe 100644 --- a/src/web/app/mobile/tags/ui.tag +++ b/src/web/app/mobile/tags/ui.tag @@ -239,7 +239,7 @@
  • %i18n:mobile.tags.mk-ui-nav.messaging%
  • -

    %i18n:mobile.tags.mk-ui-nav.about%

    +

    %i18n:mobile.tags.mk-ui-nav.about%