From de6d77d0cbd2905e021a075b667b6688cd5e06f6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 21 Feb 2018 15:30:03 +0900 Subject: wip --- src/web/app/common/scripts/streaming/home-stream.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (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 11ad754ef0..a92b61caed 100644 --- a/src/web/app/common/scripts/streaming/home-stream.ts +++ b/src/web/app/common/scripts/streaming/home-stream.ts @@ -16,7 +16,9 @@ export default class Connection extends Stream { }, 1000 * 60); // 自分の情報が更新されたとき - this.on('i_updated', me.update); + this.on('i_updated', i => { + Object.assign(me, i); + }); // トークンが再生成されたとき // このままではAPIが利用できないので強制的にサインアウトさせる -- cgit v1.2.3-freya From 37e5a9d06a492832e8e04f6029be58edb45bab5e Mon Sep 17 00:00:00 2001 From: こぴなたみぽ Date: Mon, 26 Feb 2018 18:31:55 +0900 Subject: Fix bug --- src/web/app/common/scripts/streaming/home-stream.ts | 1 + src/web/app/common/views/components/twitter-setting.vue | 8 +++++--- src/web/app/desktop/views/components/home.vue | 2 +- src/web/app/mobile/views/components/ui.header.vue | 1 + src/web/app/mobile/views/pages/home.vue | 2 +- 5 files changed, 9 insertions(+), 5 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 a92b61caed..b8e417b6d4 100644 --- a/src/web/app/common/scripts/streaming/home-stream.ts +++ b/src/web/app/common/scripts/streaming/home-stream.ts @@ -13,6 +13,7 @@ export default class Connection extends Stream { // 最終利用日時を更新するため定期的にaliveメッセージを送信 setInterval(() => { this.send({ type: 'alive' }); + me.last_used_at = new Date(); }, 1000 * 60); // 自分の情報が更新されたとき diff --git a/src/web/app/common/views/components/twitter-setting.vue b/src/web/app/common/views/components/twitter-setting.vue index aaca6ccddd..a0de27085f 100644 --- a/src/web/app/common/views/components/twitter-setting.vue +++ b/src/web/app/common/views/components/twitter-setting.vue @@ -23,12 +23,14 @@ export default Vue.extend({ docsUrl }; }, - watch: { - 'os.i'() { + mounted() { + this.$watch('os.i', () => { if ((this as any).os.i.twitter) { if (this.form) this.form.close(); } - } + }, { + deep: true + }); }, methods: { connect() { diff --git a/src/web/app/desktop/views/components/home.vue b/src/web/app/desktop/views/components/home.vue index 69f06fbf37..a7c61f4c57 100644 --- a/src/web/app/desktop/views/components/home.vue +++ b/src/web/app/desktop/views/components/home.vue @@ -126,7 +126,7 @@ export default Vue.extend({ created() { this.widgets.left = this.left; this.widgets.right = this.right; - this.$watch('os.i', i => { + this.$watch('os.i.client_settings', i => { this.widgets.left = this.left; this.widgets.right = this.right; }, { diff --git a/src/web/app/mobile/views/components/ui.header.vue b/src/web/app/mobile/views/components/ui.header.vue index 4962c5b0b4..f4b98d36f2 100644 --- a/src/web/app/mobile/views/components/ui.header.vue +++ b/src/web/app/mobile/views/components/ui.header.vue @@ -56,6 +56,7 @@ export default Vue.extend({ const ago = (new Date().getTime() - new Date((this as any).os.i.last_used_at).getTime()) / 1000 const isHisasiburi = ago >= 3600; + (this as any).os.i.last_used_at = new Date(); if (isHisasiburi) { (this.$refs.welcomeback as any).style.display = 'block'; (this.$refs.main as any).style.overflow = 'hidden'; diff --git a/src/web/app/mobile/views/pages/home.vue b/src/web/app/mobile/views/pages/home.vue index 2aa650ec53..44b0724915 100644 --- a/src/web/app/mobile/views/pages/home.vue +++ b/src/web/app/mobile/views/pages/home.vue @@ -111,7 +111,7 @@ export default Vue.extend({ this.widgets = (this as any).os.i.client_settings.mobile_home; } - this.$watch('os.i', i => { + this.$watch('os.i.client_settings', i => { this.widgets = (this as any).os.i.client_settings.mobile_home; }, { deep: true -- cgit v1.2.3-freya From d939e552f3b42a3f38981c9e650001f01a73bfad Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 26 Feb 2018 19:23:53 +0900 Subject: Fix bugs --- src/web/app/common/mios.ts | 13 ++++++++---- src/web/app/common/scripts/signout.ts | 7 ------- .../scripts/streaming/home-stream-manager.ts | 7 +++++-- .../app/common/scripts/streaming/home-stream.ts | 6 +++--- .../app/common/scripts/streaming/stream-manager.ts | 13 ++++++++++++ src/web/app/common/scripts/streaming/stream.ts | 9 ++++---- .../common/views/components/stream-indicator.vue | 24 ++++++++-------------- .../desktop/views/components/ui.header.account.vue | 7 ++++--- 8 files changed, 47 insertions(+), 39 deletions(-) delete mode 100644 src/web/app/common/scripts/signout.ts (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index 6c95e5b9b5..6cc441cd1d 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -1,9 +1,8 @@ import Vue from 'vue'; import { EventEmitter } from 'eventemitter3'; -import { apiUrl, swPublickey, version, lang } from '../config'; +import { host, apiUrl, swPublickey, version, lang } from '../config'; import api from './scripts/api'; -import signout from './scripts/signout'; import Progress from './scripts/loading'; import HomeStreamManager from './scripts/streaming/home-stream-manager'; import DriveStreamManager from './scripts/streaming/drive-stream-manager'; @@ -153,7 +152,7 @@ export default class MiOS extends EventEmitter { this.once('signedin', () => { // Init home stream manager - this.stream = new HomeStreamManager(this.i); + this.stream = new HomeStreamManager(this, this.i); // Init other stream manager this.streams.driveStream = new DriveStreamManager(this.i); @@ -184,6 +183,12 @@ export default class MiOS extends EventEmitter { console.error.apply(null, args); } + public signout() { + localStorage.removeItem('me'); + document.cookie = `i=; domain=.${host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; + location.href = '/'; + } + /** * Initialize MiOS (boot) * @param callback A function that call when initialized @@ -209,7 +214,7 @@ export default class MiOS extends EventEmitter { .then(res => { // When failed to authenticate user if (res.status !== 200) { - return signout(); + return this.signout(); } // Parse response diff --git a/src/web/app/common/scripts/signout.ts b/src/web/app/common/scripts/signout.ts deleted file mode 100644 index 2923196549..0000000000 --- a/src/web/app/common/scripts/signout.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare const _HOST_: string; - -export default () => { - localStorage.removeItem('me'); - document.cookie = `i=; domain=.${_HOST_}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`; - location.href = '/'; -}; diff --git a/src/web/app/common/scripts/streaming/home-stream-manager.ts b/src/web/app/common/scripts/streaming/home-stream-manager.ts index ad1dc870eb..ab56d5a73a 100644 --- a/src/web/app/common/scripts/streaming/home-stream-manager.ts +++ b/src/web/app/common/scripts/streaming/home-stream-manager.ts @@ -1,18 +1,21 @@ import StreamManager from './stream-manager'; import Connection from './home-stream'; +import MiOS from '../../mios'; export default class HomeStreamManager extends StreamManager { private me; + private os: MiOS; - constructor(me) { + constructor(os: MiOS, me) { super(); this.me = me; + this.os = os; } public getConnection() { if (this.connection == null) { - this.connection = new Connection(this.me); + this.connection = new Connection(this.os, 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 index b8e417b6d4..57bf0ec2a6 100644 --- a/src/web/app/common/scripts/streaming/home-stream.ts +++ b/src/web/app/common/scripts/streaming/home-stream.ts @@ -1,11 +1,11 @@ import Stream from './stream'; -import signout from '../signout'; +import MiOS from '../../mios'; /** * Home stream connection */ export default class Connection extends Stream { - constructor(me) { + constructor(os: MiOS, me) { super('', { i: me.token }); @@ -25,7 +25,7 @@ export default class Connection extends Stream { // このままではAPIが利用できないので強制的にサインアウトさせる this.on('my_token_regenerated', () => { alert('%i18n:common.my-token-regenerated%'); - signout(); + os.signout(); }); } } diff --git a/src/web/app/common/scripts/streaming/stream-manager.ts b/src/web/app/common/scripts/streaming/stream-manager.ts index 5bb0dc701c..a4a73c561f 100644 --- a/src/web/app/common/scripts/streaming/stream-manager.ts +++ b/src/web/app/common/scripts/streaming/stream-manager.ts @@ -23,6 +23,14 @@ export default abstract class StreamManager extends EventE this.emit('disconnected'); } else { this.emit('connected', this._connection); + + this._connection.on('_connected_', () => { + this.emit('_connected_'); + }); + + this._connection.on('_disconnected_', () => { + this.emit('_disconnected_'); + }); } } @@ -37,6 +45,11 @@ export default abstract class StreamManager extends EventE return this._connection != null; } + public get state(): string { + if (!this.hasConnection) return 'no-connection'; + return this._connection.state; + } + /** * コネクションを要求します */ diff --git a/src/web/app/common/scripts/streaming/stream.ts b/src/web/app/common/scripts/streaming/stream.ts index 770d77510f..8799f6fe6b 100644 --- a/src/web/app/common/scripts/streaming/stream.ts +++ b/src/web/app/common/scripts/streaming/stream.ts @@ -1,13 +1,12 @@ -declare const _API_URL_: string; - import { EventEmitter } from 'eventemitter3'; import * as ReconnectingWebsocket from 'reconnecting-websocket'; +import { apiUrl } from '../../../config'; /** * Misskey stream connection */ export default class Connection extends EventEmitter { - private state: string; + public state: string; private buffer: any[]; private socket: ReconnectingWebsocket; @@ -25,7 +24,7 @@ export default class Connection extends EventEmitter { this.state = 'initializing'; this.buffer = []; - const host = _API_URL_.replace('http', 'ws'); + const host = apiUrl.replace('http', 'ws'); const query = params ? Object.keys(params) .map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k])) @@ -58,7 +57,7 @@ export default class Connection extends EventEmitter { */ private onClose() { this.state = 'reconnecting'; - this.emit('_closed_'); + this.emit('_disconnected_'); } /** diff --git a/src/web/app/common/views/components/stream-indicator.vue b/src/web/app/common/views/components/stream-indicator.vue index c1c0672e48..1f18fa76ed 100644 --- a/src/web/app/common/views/components/stream-indicator.vue +++ b/src/web/app/common/views/components/stream-indicator.vue @@ -1,5 +1,5 @@ @@ -36,11 +37,13 @@ import Vue from 'vue'; import { chUrl } from '../../../config'; import MkMessagingWindow from './messaging-window.vue'; +import MkGameWindow from './game-window.vue'; export default Vue.extend({ data() { return { hasUnreadMessagingMessages: false, + hasGameInvitations: false, connection: null, connectionId: null, chUrl @@ -80,6 +83,10 @@ export default Vue.extend({ messaging() { (this as any).os.new(MkMessagingWindow); + }, + + game() { + (this as any).os.new(MkGameWindow); } } }); diff --git a/src/web/app/desktop/views/widgets/channel.channel.vue b/src/web/app/desktop/views/widgets/channel.channel.vue index 70dac316cf..02cdf6de13 100644 --- a/src/web/app/desktop/views/widgets/channel.channel.vue +++ b/src/web/app/desktop/views/widgets/channel.channel.vue @@ -11,7 +11,7 @@ diff --git a/src/web/app/desktop/views/components/settings.vue b/src/web/app/desktop/views/components/settings.vue index f0cd69f372..950e60fb3b 100644 --- a/src/web/app/desktop/views/components/settings.vue +++ b/src/web/app/desktop/views/components/settings.vue @@ -173,6 +173,10 @@ 実験的機能を有効にするとMisskeyの動作が不安定になる可能性があります。この設定はブラウザに記憶されます。 +
+ ツール + +
@@ -196,6 +200,7 @@ import XSignins from './settings.signins.vue'; import XDrive from './settings.drive.vue'; import { url, docsUrl, license, lang, version } from '../../../config'; import checkForUpdate from '../../../common/scripts/check-for-update'; +import MkTaskManager from './taskmanager.vue'; export default Vue.extend({ components: { @@ -226,6 +231,11 @@ export default Vue.extend({ enableExperimental: localStorage.getItem('enableExperimental') == 'true' }; }, + computed: { + licenseUrl(): string { + return `${docsUrl}/${lang}/license`; + } + }, watch: { autoPopout() { localStorage.setItem('autoPopout', this.autoPopout ? 'true' : 'false'); @@ -252,17 +262,15 @@ export default Vue.extend({ localStorage.setItem('enableExperimental', this.enableExperimental ? 'true' : 'false'); } }, - computed: { - licenseUrl(): string { - return `${docsUrl}/${lang}/license`; - } - }, created() { (this as any).os.getMeta().then(meta => { this.meta = meta; }); }, methods: { + taskmngr() { + (this as any).os.new(MkTaskManager); + }, customizeHome() { this.$router.push('/i/customize-home'); this.$emit('done'); diff --git a/src/web/app/desktop/views/components/taskmanager.vue b/src/web/app/desktop/views/components/taskmanager.vue new file mode 100644 index 0000000000..c0a8b2e9ab --- /dev/null +++ b/src/web/app/desktop/views/components/taskmanager.vue @@ -0,0 +1,204 @@ + + + + + + + diff --git a/src/web/app/desktop/views/components/window.vue b/src/web/app/desktop/views/components/window.vue index 42b2600dc4..0f89aa3e4b 100644 --- a/src/web/app/desktop/views/components/window.vue +++ b/src/web/app/desktop/views/components/window.vue @@ -68,7 +68,12 @@ export default Vue.extend({ default: 'auto' }, popoutUrl: { - type: [String, Function] + type: [String, Function], + default: null + }, + name: { + type: String, + default: null } }, diff --git a/src/web/app/desktop/views/widgets/channel.channel.vue b/src/web/app/desktop/views/widgets/channel.channel.vue index 02cdf6de13..de5885bfc1 100644 --- a/src/web/app/desktop/views/widgets/channel.channel.vue +++ b/src/web/app/desktop/views/widgets/channel.channel.vue @@ -54,7 +54,7 @@ export default Vue.extend({ }); this.disconnect(); - this.connection = new ChannelStream(this.channel.id); + this.connection = new ChannelStream((this as any).os, this.channel.id); this.connection.on('post', this.onPost); }); }, diff --git a/webpack.config.ts b/webpack.config.ts index a0e03043fa..da8b37564b 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -243,8 +243,12 @@ module.exports = entries.map(x => { cache: true, devtool: 'source-map', optimization: { - minimize: doMinify + minimize: isProduction && doMinify }, - mode: doMinify ? 'production' : 'development' + mode: isProduction + ? doMinify + ? 'production' + : 'development' + : 'development' }; }); -- cgit v1.2.3-freya From 56a1deb9d5ea7e3fb2beedbbc218ebf1d1fc719b Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 16 Mar 2018 06:05:39 +0900 Subject: :v: --- src/web/app/common/scripts/streaming/stream.ts | 5 +++++ src/web/app/desktop/views/components/taskmanager.vue | 15 +++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/web/app/common/scripts/streaming/stream.ts b/src/web/app/common/scripts/streaming/stream.ts index 189af0ab30..cb4041fd89 100644 --- a/src/web/app/common/scripts/streaming/stream.ts +++ b/src/web/app/common/scripts/streaming/stream.ts @@ -22,6 +22,7 @@ export default class Connection extends EventEmitter { data: string }> = []; public id: string; + public isSuspended = false; private os: MiOS; constructor(os: MiOS, endpoint, params?) { @@ -91,6 +92,8 @@ export default class Connection extends EventEmitter { * Callback of when received a message from connection */ private onMessage(message) { + if (this.isSuspended) return; + if (this.os.debug) { this.in++; this.inout.push({ type: 'in', at: new Date(), data: message.data }); @@ -108,6 +111,8 @@ export default class Connection extends EventEmitter { * Send a message to connection */ public send(data) { + if (this.isSuspended) return; + // まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する if (this.state != 'connected') { this.buffer.push(data); diff --git a/src/web/app/desktop/views/components/taskmanager.vue b/src/web/app/desktop/views/components/taskmanager.vue index c0a8b2e9ab..a00fabb047 100644 --- a/src/web/app/desktop/views/components/taskmanager.vue +++ b/src/web/app/desktop/views/components/taskmanager.vue @@ -94,6 +94,13 @@ +
+ Send + Suspend + Resume + Disconnect +
+ { + c.send(JSON.parse(json)); + }); } } }); -- cgit v1.2.3-freya From 19b9cb105d49e2a00ae19e3dc1f2d36dc394f148 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Mon, 26 Mar 2018 00:19:07 +0900 Subject: Introduce account document to user document An account document is attached to a user document if an account of the user is on the server. It may be missing if the user is on a remote server. --- src/api/authenticate.ts | 2 +- src/api/bot/core.ts | 2 +- src/api/bot/interfaces/line.ts | 10 +-- src/api/common/signin.ts | 2 +- src/api/endpoints/auth/accept.ts | 2 +- src/api/endpoints/following/create.ts | 2 +- src/api/endpoints/following/delete.ts | 2 +- src/api/endpoints/i.ts | 2 +- src/api/endpoints/i/2fa/done.ts | 4 +- src/api/endpoints/i/2fa/register.ts | 2 +- src/api/endpoints/i/2fa/unregister.ts | 6 +- src/api/endpoints/i/change_password.ts | 4 +- src/api/endpoints/i/regenerate_token.ts | 4 +- src/api/endpoints/i/update.ts | 14 ++-- src/api/endpoints/i/update_client_setting.ts | 4 +- src/api/endpoints/i/update_home.ts | 6 +- src/api/endpoints/i/update_mobile_home.ts | 6 +- src/api/endpoints/mute/create.ts | 2 +- src/api/endpoints/mute/delete.ts | 2 +- src/api/endpoints/posts/categorize.ts | 2 +- src/api/endpoints/posts/create.ts | 2 +- src/api/endpoints/posts/polls/vote.ts | 2 +- src/api/endpoints/posts/reactions/create.ts | 2 +- src/api/endpoints/users/recommendation.ts | 2 +- src/api/models/user.ts | 88 ++++++++++---------- src/api/private/signin.ts | 8 +- src/api/private/signup.ts | 40 ++++----- src/api/service/twitter.ts | 10 +-- src/api/stream/home.ts | 2 +- src/api/streaming.ts | 2 +- src/common/get-user-summary.ts | 2 +- src/web/app/common/define-widget.ts | 4 +- src/web/app/common/mios.ts | 10 +-- src/web/app/common/scripts/streaming/drive.ts | 2 +- src/web/app/common/scripts/streaming/home.ts | 4 +- .../common/scripts/streaming/messaging-index.ts | 2 +- src/web/app/common/scripts/streaming/messaging.ts | 4 +- .../app/common/scripts/streaming/othello-game.ts | 2 +- src/web/app/common/scripts/streaming/othello.ts | 2 +- src/web/app/common/views/components/signin.vue | 4 +- .../common/views/components/twitter-setting.vue | 12 +-- src/web/app/common/views/components/uploader.vue | 2 +- src/web/app/desktop/api/update-avatar.ts | 2 +- src/web/app/desktop/api/update-banner.ts | 2 +- src/web/app/desktop/views/components/home.vue | 20 ++--- .../app/desktop/views/components/post-detail.vue | 2 +- .../app/desktop/views/components/posts.post.vue | 4 +- .../app/desktop/views/components/settings.2fa.vue | 8 +- .../app/desktop/views/components/settings.api.vue | 2 +- .../desktop/views/components/settings.profile.vue | 8 +- src/web/app/desktop/views/components/settings.vue | 12 +-- src/web/app/desktop/views/components/timeline.vue | 2 +- src/web/app/desktop/views/components/ui.header.vue | 4 +- .../desktop/views/components/widget-container.vue | 4 +- src/web/app/desktop/views/components/window.vue | 4 +- .../app/desktop/views/pages/user/user.header.vue | 2 +- src/web/app/desktop/views/pages/user/user.home.vue | 2 +- .../app/desktop/views/pages/user/user.profile.vue | 10 +-- .../app/mobile/views/components/post-detail.vue | 2 +- src/web/app/mobile/views/components/post-form.vue | 2 +- src/web/app/mobile/views/components/post.vue | 4 +- src/web/app/mobile/views/components/ui.header.vue | 4 +- src/web/app/mobile/views/pages/home.vue | 20 ++--- src/web/app/mobile/views/pages/profile-setting.vue | 4 +- src/web/app/mobile/views/pages/user.vue | 10 +-- src/web/app/mobile/views/pages/user/home.vue | 2 +- src/web/app/mobile/views/pages/welcome.vue | 4 +- src/web/docs/api/entities/user.yaml | 94 ++++++++++++---------- test/api.js | 70 ++++++++++------ tools/migration/shell.1522038492.user-account.js | 41 ++++++++++ 70 files changed, 354 insertions(+), 279 deletions(-) create mode 100644 tools/migration/shell.1522038492.user-account.js (limited to 'src/web/app/common/scripts/streaming') diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts index b289959ac1..537c3d1e1f 100644 --- a/src/api/authenticate.ts +++ b/src/api/authenticate.ts @@ -34,7 +34,7 @@ export default (req: express.Request) => new Promise(async (resolv if (isNativeToken(token)) { const user: IUser = await User - .findOne({ token: token }); + .findOne({ 'account.token': token }); if (user === null) { return reject('user not found'); diff --git a/src/api/bot/core.ts b/src/api/bot/core.ts index 1f07d4eee9..ad29f1003e 100644 --- a/src/api/bot/core.ts +++ b/src/api/bot/core.ts @@ -225,7 +225,7 @@ class SigninContext extends Context { } } else { // Compare password - const same = await bcrypt.compare(query, this.temporaryUser.password); + const same = await bcrypt.compare(query, this.temporaryUser.account.password); if (same) { this.bot.signin(this.temporaryUser); diff --git a/src/api/bot/interfaces/line.ts b/src/api/bot/interfaces/line.ts index 43c25f8032..bf08821594 100644 --- a/src/api/bot/interfaces/line.ts +++ b/src/api/bot/interfaces/line.ts @@ -110,11 +110,11 @@ class LineBot extends BotCore { data: `showtl|${user.id}` }); - if (user.twitter) { + if (user.account.twitter) { actions.push({ type: 'uri', label: 'Twitterアカウントを見る', - uri: `https://twitter.com/${user.twitter.screen_name}` + uri: `https://twitter.com/${user.account.twitter.screen_name}` }); } @@ -171,7 +171,7 @@ module.exports = async (app: express.Application) => { if (session == null) { const user = await User.findOne({ - line: { + 'account.line': { user_id: sourceId } }); @@ -181,7 +181,7 @@ module.exports = async (app: express.Application) => { bot.on('signin', user => { User.update(user._id, { $set: { - line: { + 'account.line': { user_id: sourceId } } @@ -191,7 +191,7 @@ module.exports = async (app: express.Application) => { bot.on('signout', user => { User.update(user._id, { $set: { - line: { + 'account.line': { user_id: null } } diff --git a/src/api/common/signin.ts b/src/api/common/signin.ts index 693e62f39f..c069fa4ec8 100644 --- a/src/api/common/signin.ts +++ b/src/api/common/signin.ts @@ -2,7 +2,7 @@ import config from '../../conf'; export default function(res, user, redirect: boolean) { const expires = 1000 * 60 * 60 * 24 * 365; // One Year - res.cookie('i', user.token, { + res.cookie('i', user.account.token, { path: '/', domain: `.${config.host}`, secure: config.url.substr(0, 5) === 'https', diff --git a/src/api/endpoints/auth/accept.ts b/src/api/endpoints/auth/accept.ts index 4ee20a6d25..8955738ebf 100644 --- a/src/api/endpoints/auth/accept.ts +++ b/src/api/endpoints/auth/accept.ts @@ -45,7 +45,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { // Fetch token const session = await AuthSess - .findOne({ token: token }); + .findOne({ 'account.token': token }); if (session === null) { return rej('session not found'); diff --git a/src/api/endpoints/following/create.ts b/src/api/endpoints/following/create.ts index 8e1aa34713..767b837b35 100644 --- a/src/api/endpoints/following/create.ts +++ b/src/api/endpoints/following/create.ts @@ -32,7 +32,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }, { fields: { data: false, - profile: false + 'account.profile': false } }); diff --git a/src/api/endpoints/following/delete.ts b/src/api/endpoints/following/delete.ts index b68cec09dd..64b9a8cecb 100644 --- a/src/api/endpoints/following/delete.ts +++ b/src/api/endpoints/following/delete.ts @@ -31,7 +31,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }, { fields: { data: false, - profile: false + 'account.profile': false } }); diff --git a/src/api/endpoints/i.ts b/src/api/endpoints/i.ts index 7efdbcd7c9..32b0382faf 100644 --- a/src/api/endpoints/i.ts +++ b/src/api/endpoints/i.ts @@ -22,7 +22,7 @@ module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => // Update lastUsedAt User.update({ _id: user._id }, { $set: { - last_used_at: new Date() + 'account.last_used_at': new Date() } }); }); diff --git a/src/api/endpoints/i/2fa/done.ts b/src/api/endpoints/i/2fa/done.ts index 0b36033bb6..0f1db73829 100644 --- a/src/api/endpoints/i/2fa/done.ts +++ b/src/api/endpoints/i/2fa/done.ts @@ -28,8 +28,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { await User.update(user._id, { $set: { - two_factor_secret: user.two_factor_temp_secret, - two_factor_enabled: true + 'account.two_factor_secret': user.two_factor_temp_secret, + 'account.two_factor_enabled': true } }); diff --git a/src/api/endpoints/i/2fa/register.ts b/src/api/endpoints/i/2fa/register.ts index c2b5037a29..24abfcdfc5 100644 --- a/src/api/endpoints/i/2fa/register.ts +++ b/src/api/endpoints/i/2fa/register.ts @@ -14,7 +14,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (passwordErr) return rej('invalid password param'); // Compare password - const same = await bcrypt.compare(password, user.password); + const same = await bcrypt.compare(password, user.account.password); if (!same) { return rej('incorrect password'); diff --git a/src/api/endpoints/i/2fa/unregister.ts b/src/api/endpoints/i/2fa/unregister.ts index 6bee6a26f2..c43f9ccc44 100644 --- a/src/api/endpoints/i/2fa/unregister.ts +++ b/src/api/endpoints/i/2fa/unregister.ts @@ -11,7 +11,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (passwordErr) return rej('invalid password param'); // Compare password - const same = await bcrypt.compare(password, user.password); + const same = await bcrypt.compare(password, user.account.password); if (!same) { return rej('incorrect password'); @@ -19,8 +19,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { await User.update(user._id, { $set: { - two_factor_secret: null, - two_factor_enabled: false + 'account.two_factor_secret': null, + 'account.two_factor_enabled': false } }); diff --git a/src/api/endpoints/i/change_password.ts b/src/api/endpoints/i/change_password.ts index 16f1a2e4ec..88fb36b1fb 100644 --- a/src/api/endpoints/i/change_password.ts +++ b/src/api/endpoints/i/change_password.ts @@ -22,7 +22,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (newPasswordErr) return rej('invalid new_password param'); // Compare password - const same = await bcrypt.compare(currentPassword, user.password); + const same = await bcrypt.compare(currentPassword, user.account.password); if (!same) { return rej('incorrect password'); @@ -34,7 +34,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { await User.update(user._id, { $set: { - password: hash + 'account.password': hash } }); diff --git a/src/api/endpoints/i/regenerate_token.ts b/src/api/endpoints/i/regenerate_token.ts index 653468330f..9ac7b55071 100644 --- a/src/api/endpoints/i/regenerate_token.ts +++ b/src/api/endpoints/i/regenerate_token.ts @@ -20,7 +20,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (passwordErr) return rej('invalid password param'); // Compare password - const same = await bcrypt.compare(password, user.password); + const same = await bcrypt.compare(password, user.account.password); if (!same) { return rej('incorrect password'); @@ -31,7 +31,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { await User.update(user._id, { $set: { - token: secret + 'account.token': secret } }); diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts index 76bad2d156..db8a3f25bd 100644 --- a/src/api/endpoints/i/update.ts +++ b/src/api/endpoints/i/update.ts @@ -29,12 +29,12 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re // Get 'location' parameter const [location, locationErr] = $(params.location).optional.nullable.string().pipe(isValidLocation).$; if (locationErr) return rej('invalid location param'); - if (location !== undefined) user.profile.location = location; + if (location !== undefined) user.account.profile.location = location; // Get 'birthday' parameter const [birthday, birthdayErr] = $(params.birthday).optional.nullable.string().pipe(isValidBirthday).$; if (birthdayErr) return rej('invalid birthday param'); - if (birthday !== undefined) user.profile.birthday = birthday; + if (birthday !== undefined) user.account.profile.birthday = birthday; // Get 'avatar_id' parameter const [avatarId, avatarIdErr] = $(params.avatar_id).optional.id().$; @@ -49,12 +49,12 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re // Get 'is_bot' parameter const [isBot, isBotErr] = $(params.is_bot).optional.boolean().$; if (isBotErr) return rej('invalid is_bot param'); - if (isBot != null) user.is_bot = isBot; + if (isBot != null) user.account.is_bot = isBot; // Get 'auto_watch' parameter const [autoWatch, autoWatchErr] = $(params.auto_watch).optional.boolean().$; if (autoWatchErr) return rej('invalid auto_watch param'); - if (autoWatch != null) user.settings.auto_watch = autoWatch; + if (autoWatch != null) user.account.settings.auto_watch = autoWatch; await User.update(user._id, { $set: { @@ -62,9 +62,9 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re description: user.description, avatar_id: user.avatar_id, banner_id: user.banner_id, - profile: user.profile, - is_bot: user.is_bot, - settings: user.settings + 'account.profile': user.account.profile, + 'account.is_bot': user.account.is_bot, + 'account.settings': user.account.settings } }); diff --git a/src/api/endpoints/i/update_client_setting.ts b/src/api/endpoints/i/update_client_setting.ts index b817ff354c..c772ed5dc3 100644 --- a/src/api/endpoints/i/update_client_setting.ts +++ b/src/api/endpoints/i/update_client_setting.ts @@ -22,14 +22,14 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (valueErr) return rej('invalid value param'); const x = {}; - x[`client_settings.${name}`] = value; + x[`account.client_settings.${name}`] = value; await User.update(user._id, { $set: x }); // Serialize - user.client_settings[name] = value; + user.account.client_settings[name] = value; const iObj = await pack(user, user, { detail: true, includeSecrets: true diff --git a/src/api/endpoints/i/update_home.ts b/src/api/endpoints/i/update_home.ts index 394686cbd1..9ce44e25ee 100644 --- a/src/api/endpoints/i/update_home.ts +++ b/src/api/endpoints/i/update_home.ts @@ -26,7 +26,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (home) { await User.update(user._id, { $set: { - 'client_settings.home': home + 'account.client_settings.home': home } }); @@ -38,7 +38,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { } else { if (id == null && data == null) return rej('you need to set id and data params if home param unset'); - const _home = user.client_settings.home; + const _home = user.account.client_settings.home; const widget = _home.find(w => w.id == id); if (widget == null) return rej('widget not found'); @@ -47,7 +47,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { await User.update(user._id, { $set: { - 'client_settings.home': _home + 'account.client_settings.home': _home } }); diff --git a/src/api/endpoints/i/update_mobile_home.ts b/src/api/endpoints/i/update_mobile_home.ts index 70181431a2..1daddf42b9 100644 --- a/src/api/endpoints/i/update_mobile_home.ts +++ b/src/api/endpoints/i/update_mobile_home.ts @@ -25,7 +25,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { if (home) { await User.update(user._id, { $set: { - 'client_settings.mobile_home': home + 'account.client_settings.mobile_home': home } }); @@ -37,7 +37,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { } else { if (id == null && data == null) return rej('you need to set id and data params if home param unset'); - const _home = user.client_settings.mobile_home || []; + const _home = user.account.client_settings.mobile_home || []; const widget = _home.find(w => w.id == id); if (widget == null) return rej('widget not found'); @@ -46,7 +46,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => { await User.update(user._id, { $set: { - 'client_settings.mobile_home': _home + 'account.client_settings.mobile_home': _home } }); diff --git a/src/api/endpoints/mute/create.ts b/src/api/endpoints/mute/create.ts index f44854ab52..f99b40d32e 100644 --- a/src/api/endpoints/mute/create.ts +++ b/src/api/endpoints/mute/create.ts @@ -30,7 +30,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }, { fields: { data: false, - profile: false + 'account.profile': false } }); diff --git a/src/api/endpoints/mute/delete.ts b/src/api/endpoints/mute/delete.ts index d6bff3353a..36e2fd101a 100644 --- a/src/api/endpoints/mute/delete.ts +++ b/src/api/endpoints/mute/delete.ts @@ -30,7 +30,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }, { fields: { data: false, - profile: false + 'account.profile': false } }); diff --git a/src/api/endpoints/posts/categorize.ts b/src/api/endpoints/posts/categorize.ts index 3530ba6bc4..0c85c2b4e0 100644 --- a/src/api/endpoints/posts/categorize.ts +++ b/src/api/endpoints/posts/categorize.ts @@ -12,7 +12,7 @@ import Post from '../../models/post'; * @return {Promise} */ module.exports = (params, user) => new Promise(async (res, rej) => { - if (!user.is_pro) { + if (!user.account.is_pro) { return rej('This endpoint is available only from a Pro account'); } diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index 1c3ab53457..f46a84e1f1 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -390,7 +390,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { }); // この投稿をWatchする - if (user.settings.auto_watch !== false) { + if (user.account.settings.auto_watch !== false) { watch(user._id, reply); } diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts index 8222fe5326..16ce76a6fa 100644 --- a/src/api/endpoints/posts/polls/vote.ts +++ b/src/api/endpoints/posts/polls/vote.ts @@ -100,7 +100,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }); // この投稿をWatchする - if (user.settings.auto_watch !== false) { + if (user.account.settings.auto_watch !== false) { watch(user._id, post); } }); diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts index 93d9756d02..f77afed40c 100644 --- a/src/api/endpoints/posts/reactions/create.ts +++ b/src/api/endpoints/posts/reactions/create.ts @@ -116,7 +116,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }); // この投稿をWatchする - if (user.settings.auto_watch !== false) { + if (user.account.settings.auto_watch !== false) { watch(user._id, post); } }); diff --git a/src/api/endpoints/users/recommendation.ts b/src/api/endpoints/users/recommendation.ts index 736233b340..f1f5bcd0ac 100644 --- a/src/api/endpoints/users/recommendation.ts +++ b/src/api/endpoints/users/recommendation.ts @@ -30,7 +30,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => { _id: { $nin: followingIds }, - last_used_at: { + 'account.last_used_at': { $gte: new Date(Date.now() - ms('7days')) } }, { diff --git a/src/api/models/user.ts b/src/api/models/user.ts index ba2765c793..372e2c5dac 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -11,7 +11,7 @@ import config from '../../conf'; const User = db.get('users'); User.createIndex('username'); -User.createIndex('token'); +User.createIndex('account.token'); export default User; @@ -43,46 +43,48 @@ export type IUser = { _id: mongo.ObjectID; created_at: Date; deleted_at: Date; - email: string; followers_count: number; following_count: number; - links: string[]; name: string; - password: string; posts_count: number; drive_capacity: number; username: string; username_lower: string; - token: string; avatar_id: mongo.ObjectID; banner_id: mongo.ObjectID; data: any; - twitter: { - access_token: string; - access_token_secret: string; - user_id: string; - screen_name: string; - }; - line: { - user_id: string; - }; description: string; - profile: { - location: string; - birthday: string; // 'YYYY-MM-DD' - tags: string[]; - }; - last_used_at: Date; latest_post: IPost; pinned_post_id: mongo.ObjectID; - is_bot: boolean; - is_pro: boolean; is_suspended: boolean; keywords: string[]; - two_factor_secret: string; - two_factor_enabled: boolean; - client_settings: any; - settings: any; + account: { + email: string; + links: string[]; + password: string; + token: string; + twitter: { + access_token: string; + access_token_secret: string; + user_id: string; + screen_name: string; + }; + line: { + user_id: string; + }; + profile: { + location: string; + birthday: string; // 'YYYY-MM-DD' + tags: string[]; + }; + last_used_at: Date; + is_bot: boolean; + is_pro: boolean; + two_factor_secret: string; + two_factor_enabled: boolean; + client_settings: any; + settings: any; + }; }; export function init(user): IUser { @@ -119,11 +121,11 @@ export const pack = ( const fields = opts.detail ? { } : { - settings: false, - client_settings: false, - profile: false, - keywords: false, - domains: false + 'account.settings': false, + 'account.client_settings': false, + 'account.profile': false, + 'account.keywords': false, + 'account.domains': false }; // Populate the user if 'user' is ID @@ -158,26 +160,26 @@ export const pack = ( delete _user.latest_post; // Remove private properties - delete _user.password; - delete _user.token; - delete _user.two_factor_temp_secret; - delete _user.two_factor_secret; + delete _user.account.password; + delete _user.account.token; + delete _user.account.two_factor_temp_secret; + delete _user.account.two_factor_secret; delete _user.username_lower; - if (_user.twitter) { - delete _user.twitter.access_token; - delete _user.twitter.access_token_secret; + if (_user.account.twitter) { + delete _user.account.twitter.access_token; + delete _user.account.twitter.access_token_secret; } - delete _user.line; + delete _user.account.line; // Visible via only the official client if (!opts.includeSecrets) { - delete _user.email; - delete _user.settings; - delete _user.client_settings; + delete _user.account.email; + delete _user.account.settings; + delete _user.account.client_settings; } if (!opts.detail) { - delete _user.two_factor_enabled; + delete _user.account.two_factor_enabled; } _user.avatar_url = _user.avatar_id != null diff --git a/src/api/private/signin.ts b/src/api/private/signin.ts index b49d25d99a..ae0be03c73 100644 --- a/src/api/private/signin.ts +++ b/src/api/private/signin.ts @@ -36,7 +36,7 @@ export default async (req: express.Request, res: express.Response) => { }, { fields: { data: false, - profile: false + 'account.profile': false } }); @@ -48,12 +48,12 @@ export default async (req: express.Request, res: express.Response) => { } // Compare password - const same = await bcrypt.compare(password, user.password); + const same = await bcrypt.compare(password, user.account.password); if (same) { - if (user.two_factor_enabled) { + if (user.account.two_factor_enabled) { const verified = (speakeasy as any).totp.verify({ - secret: user.two_factor_secret, + secret: user.account.two_factor_secret, encoding: 'base32', token: token }); diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index 3df00ae426..902642425c 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -105,38 +105,40 @@ export default async (req: express.Request, res: express.Response) => { // Create account const account: IUser = await User.insert({ - token: secret, avatar_id: null, banner_id: null, created_at: new Date(), description: null, - email: null, followers_count: 0, following_count: 0, - links: null, name: name, - password: hash, posts_count: 0, likes_count: 0, liked_count: 0, drive_capacity: 1073741824, // 1GB username: username, username_lower: username.toLowerCase(), - profile: { - bio: null, - birthday: null, - blood: null, - gender: null, - handedness: null, - height: null, - location: null, - weight: null - }, - settings: { - auto_watch: true - }, - client_settings: { - home: homeData + account: { + token: secret, + email: null, + links: null, + password: hash, + profile: { + bio: null, + birthday: null, + blood: null, + gender: null, + handedness: null, + height: null, + location: null, + weight: null + }, + settings: { + auto_watch: true + }, + client_settings: { + home: homeData + } } }); diff --git a/src/api/service/twitter.ts b/src/api/service/twitter.ts index adcd5ac49b..02b613454c 100644 --- a/src/api/service/twitter.ts +++ b/src/api/service/twitter.ts @@ -39,10 +39,10 @@ module.exports = (app: express.Application) => { if (userToken == null) return res.send('plz signin'); const user = await User.findOneAndUpdate({ - token: userToken + 'account.token': userToken }, { $set: { - twitter: null + 'account.twitter': null } }); @@ -126,7 +126,7 @@ module.exports = (app: express.Application) => { const result = await twAuth.done(JSON.parse(ctx), req.query.oauth_verifier); const user = await User.findOne({ - 'twitter.user_id': result.userId + 'account.twitter.user_id': result.userId }); if (user == null) { @@ -148,10 +148,10 @@ module.exports = (app: express.Application) => { const result = await twAuth.done(JSON.parse(ctx), verifier); const user = await User.findOneAndUpdate({ - token: userToken + 'account.token': userToken }, { $set: { - twitter: { + 'account.twitter': { access_token: result.accessToken, access_token_secret: result.accessTokenSecret, user_id: result.userId, diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts index cc3fb885e4..1ef0f33b4b 100644 --- a/src/api/stream/home.ts +++ b/src/api/stream/home.ts @@ -74,7 +74,7 @@ export default async function(request: websocket.request, connection: websocket. // Update lastUsedAt User.update({ _id: user._id }, { $set: { - last_used_at: new Date() + 'account.last_used_at': new Date() } }); break; diff --git a/src/api/streaming.ts b/src/api/streaming.ts index f56c08092c..427e01afdd 100644 --- a/src/api/streaming.ts +++ b/src/api/streaming.ts @@ -94,7 +94,7 @@ function authenticate(token: string): Promise { // Fetch user const user: IUser = await User .findOne({ - token: token + 'account.token': token }); resolve(user); diff --git a/src/common/get-user-summary.ts b/src/common/get-user-summary.ts index 1bec2f9a26..619814e8a8 100644 --- a/src/common/get-user-summary.ts +++ b/src/common/get-user-summary.ts @@ -7,6 +7,6 @@ import { IUser } from '../api/models/user'; export default function(user: IUser): string { return `${user.name} (@${user.username})\n` + `${user.posts_count}投稿、${user.following_count}フォロー、${user.followers_count}フォロワー\n` + - `場所: ${user.profile.location}、誕生日: ${user.profile.birthday}\n` + + `場所: ${user.account.profile.location}、誕生日: ${user.account.profile.birthday}\n` + `「${user.description}」`; } diff --git a/src/web/app/common/define-widget.ts b/src/web/app/common/define-widget.ts index efce7e813c..d8d29873a4 100644 --- a/src/web/app/common/define-widget.ts +++ b/src/web/app/common/define-widget.ts @@ -56,14 +56,14 @@ export default function(data: { id: this.id, data: newProps }).then(() => { - (this as any).os.i.client_settings.mobile_home.find(w => w.id == this.id).data = newProps; + (this as any).os.i.account.client_settings.mobile_home.find(w => w.id == this.id).data = newProps; }); } else { (this as any).api('i/update_home', { id: this.id, data: newProps }).then(() => { - (this as any).os.i.client_settings.home.find(w => w.id == this.id).data = newProps; + (this as any).os.i.account.client_settings.home.find(w => w.id == this.id).data = newProps; }); } }, { diff --git a/src/web/app/common/mios.ts b/src/web/app/common/mios.ts index 986630da20..1c950c3e79 100644 --- a/src/web/app/common/mios.ts +++ b/src/web/app/common/mios.ts @@ -270,7 +270,7 @@ export default class MiOS extends EventEmitter { // Parse response res.json().then(i => { me = i; - me.token = token; + me.account.token = token; done(); }); }) @@ -294,12 +294,12 @@ export default class MiOS extends EventEmitter { const fetched = me => { if (me) { // デフォルトの設定をマージ - me.client_settings = Object.assign({ + me.account.client_settings = Object.assign({ fetchOnScroll: true, showMaps: true, showPostFormOnTopOfTl: false, gradientWindowHeader: false - }, me.client_settings); + }, me.account.client_settings); // ローカルストレージにキャッシュ localStorage.setItem('me', JSON.stringify(me)); @@ -329,7 +329,7 @@ export default class MiOS extends EventEmitter { fetched(cachedMe); // 後から新鮮なデータをフェッチ - fetchme(cachedMe.token, freshData => { + fetchme(cachedMe.account.token, freshData => { merge(cachedMe, freshData); }); } else { @@ -437,7 +437,7 @@ export default class MiOS extends EventEmitter { } // Append a credential - if (this.isSignedIn) (data as any).i = this.i.token; + if (this.isSignedIn) (data as any).i = this.i.account.token; // TODO //const viaStream = localStorage.getItem('enableExperimental') == 'true'; diff --git a/src/web/app/common/scripts/streaming/drive.ts b/src/web/app/common/scripts/streaming/drive.ts index 7ff85b5946..f11573685e 100644 --- a/src/web/app/common/scripts/streaming/drive.ts +++ b/src/web/app/common/scripts/streaming/drive.ts @@ -8,7 +8,7 @@ import MiOS from '../../mios'; export class DriveStream extends Stream { constructor(os: MiOS, me) { super(os, 'drive', { - i: me.token + i: me.account.token }); } } diff --git a/src/web/app/common/scripts/streaming/home.ts b/src/web/app/common/scripts/streaming/home.ts index 533c232449..ffcf6e5360 100644 --- a/src/web/app/common/scripts/streaming/home.ts +++ b/src/web/app/common/scripts/streaming/home.ts @@ -10,13 +10,13 @@ import MiOS from '../../mios'; export class HomeStream extends Stream { constructor(os: MiOS, me) { super(os, '', { - i: me.token + i: me.account.token }); // 最終利用日時を更新するため定期的にaliveメッセージを送信 setInterval(() => { this.send({ type: 'alive' }); - me.last_used_at = new Date(); + me.account.last_used_at = new Date(); }, 1000 * 60); // 自分の情報が更新されたとき diff --git a/src/web/app/common/scripts/streaming/messaging-index.ts b/src/web/app/common/scripts/streaming/messaging-index.ts index 84e2174ec4..24f0ce0c9f 100644 --- a/src/web/app/common/scripts/streaming/messaging-index.ts +++ b/src/web/app/common/scripts/streaming/messaging-index.ts @@ -8,7 +8,7 @@ import MiOS from '../../mios'; export class MessagingIndexStream extends Stream { constructor(os: MiOS, me) { super(os, 'messaging-index', { - i: me.token + i: me.account.token }); } } diff --git a/src/web/app/common/scripts/streaming/messaging.ts b/src/web/app/common/scripts/streaming/messaging.ts index c1b5875cfb..4c593deb31 100644 --- a/src/web/app/common/scripts/streaming/messaging.ts +++ b/src/web/app/common/scripts/streaming/messaging.ts @@ -7,13 +7,13 @@ import MiOS from '../../mios'; export class MessagingStream extends Stream { constructor(os: MiOS, me, otherparty) { super(os, 'messaging', { - i: me.token, + i: me.account.token, otherparty }); (this as any).on('_connected_', () => { this.send({ - i: me.token + i: me.account.token }); }); } diff --git a/src/web/app/common/scripts/streaming/othello-game.ts b/src/web/app/common/scripts/streaming/othello-game.ts index b85af8f72b..f34ef35147 100644 --- a/src/web/app/common/scripts/streaming/othello-game.ts +++ b/src/web/app/common/scripts/streaming/othello-game.ts @@ -4,7 +4,7 @@ import MiOS from '../../mios'; export class OthelloGameStream extends Stream { constructor(os: MiOS, me, game) { super(os, 'othello-game', { - i: me ? me.token : null, + i: me ? me.account.token : null, game: game.id }); } diff --git a/src/web/app/common/scripts/streaming/othello.ts b/src/web/app/common/scripts/streaming/othello.ts index f5d47431cd..8c6f4b9c3c 100644 --- a/src/web/app/common/scripts/streaming/othello.ts +++ b/src/web/app/common/scripts/streaming/othello.ts @@ -5,7 +5,7 @@ import MiOS from '../../mios'; export class OthelloStream extends Stream { constructor(os: MiOS, me) { super(os, 'othello', { - i: me.token + i: me.account.token }); } } diff --git a/src/web/app/common/views/components/signin.vue b/src/web/app/common/views/components/signin.vue index 1738d0df7d..d8b1357764 100644 --- a/src/web/app/common/views/components/signin.vue +++ b/src/web/app/common/views/components/signin.vue @@ -6,7 +6,7 @@ -