summaryrefslogtreecommitdiff
path: root/src/server/api/stream/index.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-07-27 13:34:20 +0900
committerGitHub <noreply@github.com>2020-07-27 13:34:20 +0900
commitcf43dd6ec530ba4a3f589ae917e89533b352f6a3 (patch)
tree76f35d06299b40370ec061ee5ed58182847d2e6e /src/server/api/stream/index.ts
parentrefactor(client): Do not mutate prop directly (diff)
downloadmisskey-cf43dd6ec530ba4a3f589ae917e89533b352f6a3.tar.gz
misskey-cf43dd6ec530ba4a3f589ae917e89533b352f6a3.tar.bz2
misskey-cf43dd6ec530ba4a3f589ae917e89533b352f6a3.zip
ワードミュート (#6594)
* wip * wip * wip * wip * wip * wip * wip * wip * wip
Diffstat (limited to 'src/server/api/stream/index.ts')
-rw-r--r--src/server/api/stream/index.ts16
1 files changed, 15 insertions, 1 deletions
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);
}
}