From cf43dd6ec530ba4a3f589ae917e89533b352f6a3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 27 Jul 2020 13:34:20 +0900 Subject: ワードミュート (#6594) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wip * wip * wip * wip * wip * wip * wip * wip * wip --- src/server/api/stream/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/server/api/stream/index.ts') diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts index b7cefcf5ab..bebf88a7cd 100644 --- a/src/server/api/stream/index.ts +++ b/src/server/api/stream/index.ts @@ -7,15 +7,17 @@ import Channel from './channel'; import channels from './channels'; import { EventEmitter } from 'events'; import { User } from '../../../models/entities/user'; -import { Users, Followings, Mutings } from '../../../models'; +import { Users, Followings, Mutings, UserProfiles } from '../../../models'; import { ApiError } from '../error'; import { AccessToken } from '../../../models/entities/access-token'; +import { UserProfile } from '../../../models/entities/user-profile'; /** * Main stream connection */ export default class Connection { public user?: User; + public userProfile?: UserProfile; public following: User['id'][] = []; public muting: User['id'][] = []; public token?: AccessToken; @@ -25,6 +27,7 @@ export default class Connection { private subscribingNotes: any = {}; private followingClock: NodeJS.Timer; private mutingClock: NodeJS.Timer; + private userProfileClock: NodeJS.Timer; constructor( wsConnection: websocket.connection, @@ -49,6 +52,9 @@ export default class Connection { this.updateMuting(); this.mutingClock = setInterval(this.updateMuting, 5000); + + this.updateUserProfile(); + this.userProfileClock = setInterval(this.updateUserProfile, 5000); } } @@ -262,6 +268,13 @@ export default class Connection { this.muting = mutings.map(x => x.muteeId); } + @autobind + private async updateUserProfile() { + this.userProfile = await UserProfiles.findOne({ + userId: this.user!.id + }); + } + /** * ストリームが切れたとき */ @@ -273,5 +286,6 @@ export default class Connection { if (this.followingClock) clearInterval(this.followingClock); if (this.mutingClock) clearInterval(this.mutingClock); + if (this.userProfileClock) clearInterval(this.userProfileClock); } } -- cgit v1.2.3-freya