summaryrefslogtreecommitdiff
path: root/src/server/api/stream/index.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-08-18 22:44:21 +0900
committerGitHub <noreply@github.com>2020-08-18 22:44:21 +0900
commit9855405b8989713b81709fc1700e2ead97423467 (patch)
tree54254d2159378d1903e962f0fb37c799bb0f4464 /src/server/api/stream/index.ts
parentSign (request-target) Fix #6652 (#6656) (diff)
downloadmisskey-9855405b8989713b81709fc1700e2ead97423467.tar.gz
misskey-9855405b8989713b81709fc1700e2ead97423467.tar.bz2
misskey-9855405b8989713b81709fc1700e2ead97423467.zip
Channel (#6621)
* wip * wip * wip * wip * wip * wip * wip * wip * wop * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * add notes * wip * wip * wip * wip * sound * wip * add kick_gaba2 * wip
Diffstat (limited to '')
-rw-r--r--src/server/api/stream/index.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts
index bebf88a7cd..d420c6e794 100644
--- a/src/server/api/stream/index.ts
+++ b/src/server/api/stream/index.ts
@@ -7,7 +7,8 @@ import Channel from './channel';
import channels from './channels';
import { EventEmitter } from 'events';
import { User } from '../../../models/entities/user';
-import { Users, Followings, Mutings, UserProfiles } from '../../../models';
+import { Channel as ChannelModel } from '../../../models/entities/channel';
+import { Users, Followings, Mutings, UserProfiles, ChannelFollowings } from '../../../models';
import { ApiError } from '../error';
import { AccessToken } from '../../../models/entities/access-token';
import { UserProfile } from '../../../models/entities/user-profile';
@@ -20,6 +21,7 @@ export default class Connection {
public userProfile?: UserProfile;
public following: User['id'][] = [];
public muting: User['id'][] = [];
+ public followingChannels: ChannelModel['id'][] = [];
public token?: AccessToken;
private wsConnection: websocket.connection;
public subscriber: EventEmitter;
@@ -27,6 +29,7 @@ export default class Connection {
private subscribingNotes: any = {};
private followingClock: NodeJS.Timer;
private mutingClock: NodeJS.Timer;
+ private followingChannelsClock: NodeJS.Timer;
private userProfileClock: NodeJS.Timer;
constructor(
@@ -53,6 +56,9 @@ export default class Connection {
this.updateMuting();
this.mutingClock = setInterval(this.updateMuting, 5000);
+ this.updateFollowingChannels();
+ this.followingChannelsClock = setInterval(this.updateFollowingChannels, 5000);
+
this.updateUserProfile();
this.userProfileClock = setInterval(this.updateUserProfile, 5000);
}
@@ -269,6 +275,18 @@ export default class Connection {
}
@autobind
+ private async updateFollowingChannels() {
+ const followings = await ChannelFollowings.find({
+ where: {
+ followerId: this.user!.id
+ },
+ select: ['followeeId']
+ });
+
+ this.followingChannels = followings.map(x => x.followeeId);
+ }
+
+ @autobind
private async updateUserProfile() {
this.userProfile = await UserProfiles.findOne({
userId: this.user!.id
@@ -286,6 +304,7 @@ export default class Connection {
if (this.followingClock) clearInterval(this.followingClock);
if (this.mutingClock) clearInterval(this.mutingClock);
+ if (this.followingChannelsClock) clearInterval(this.followingChannelsClock);
if (this.userProfileClock) clearInterval(this.userProfileClock);
}
}