summaryrefslogtreecommitdiff
path: root/src/server/api/stream/index.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-08-17 21:48:59 +0900
committerGitHub <noreply@github.com>2021-08-17 21:48:59 +0900
commit7015df37e3545d835ecd71cdcd1910fbb16e80da (patch)
tree58fe6dd4352444302dbdadb8a31d540604437495 /src/server/api/stream/index.ts
parentFix truncate (#7642) (diff)
downloadsharkey-7015df37e3545d835ecd71cdcd1910fbb16e80da.tar.gz
sharkey-7015df37e3545d835ecd71cdcd1910fbb16e80da.tar.bz2
sharkey-7015df37e3545d835ecd71cdcd1910fbb16e80da.zip
enhance(server): Improve user block (#7640)
* enhance(server): Improve user block * Update CHANGELOG.md * ユーザーリスト対応 * 相手から見れなくなるように * Update 1629004542760-chart-reindex.ts https://github.com/misskey-dev/misskey/commit/2365761ba5445f26c8b66b3b20ef4be44e70d549#commitcomment-54919821 * update test * add test * add todos * Update 1629004542760-chart-reindex.ts
Diffstat (limited to 'src/server/api/stream/index.ts')
-rw-r--r--src/server/api/stream/index.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts
index 75d82cfe66..96d4194a7d 100644
--- a/src/server/api/stream/index.ts
+++ b/src/server/api/stream/index.ts
@@ -8,7 +8,7 @@ import channels from './channels';
import { EventEmitter } from 'events';
import { User } from '../../../models/entities/user';
import { Channel as ChannelModel } from '../../../models/entities/channel';
-import { Users, Followings, Mutings, UserProfiles, ChannelFollowings } from '../../../models';
+import { Users, Followings, Mutings, UserProfiles, ChannelFollowings, Blockings } from '../../../models';
import { ApiError } from '../error';
import { AccessToken } from '../../../models/entities/access-token';
import { UserProfile } from '../../../models/entities/user-profile';
@@ -24,6 +24,7 @@ export default class Connection {
public userProfile?: UserProfile;
public following: Set<User['id']> = new Set();
public muting: Set<User['id']> = new Set();
+ public blocking: Set<User['id']> = new Set(); // "被"blocking
public followingChannels: Set<ChannelModel['id']> = new Set();
public token?: AccessToken;
private wsConnection: websocket.connection;
@@ -52,6 +53,7 @@ export default class Connection {
if (this.user) {
this.updateFollowing();
this.updateMuting();
+ this.updateBlocking();
this.updateFollowingChannels();
this.updateUserProfile();
@@ -80,6 +82,8 @@ export default class Connection {
this.muting.delete(body.id);
break;
+ // TODO: block events
+
case 'followChannel':
this.followingChannels.add(body.id);
break;
@@ -376,6 +380,18 @@ export default class Connection {
}
@autobind
+ private async updateBlocking() { // ここでいうBlockingは被Blockingの意
+ const blockings = await Blockings.find({
+ where: {
+ blockeeId: this.user!.id
+ },
+ select: ['blockerId']
+ });
+
+ this.blocking = new Set<string>(blockings.map(x => x.blockerId));
+ }
+
+ @autobind
private async updateFollowingChannels() {
const followings = await ChannelFollowings.find({
where: {