mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-03-24 04:53:33 +00:00
enhance(server): Improve user block (#7640)
* enhance(server): Improve user block
* Update CHANGELOG.md
* ユーザーリスト対応
* 相手から見れなくなるように
* Update 1629004542760-chart-reindex.ts
2365761ba5 (commitcomment-54919821)
* update test
* add test
* add todos
* Update 1629004542760-chart-reindex.ts
This commit is contained in:
@@ -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;
|
||||
@@ -375,6 +379,18 @@ export default class Connection {
|
||||
this.muting = new Set<string>(mutings.map(x => x.muteeId));
|
||||
}
|
||||
|
||||
@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({
|
||||
|
||||
Reference in New Issue
Block a user