diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-03-08 08:56:09 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-08 08:56:09 +0900 |
| commit | 4c2f7c64cc2b70bd7b686e9ece1ebbc30eeab511 (patch) | |
| tree | 0d1ce1e7b3cd567c98205343e1e550cc47c714fa /packages/backend/src/server/api/stream/index.ts | |
| parent | refactor(dev): separate test workflows (diff) | |
| download | sharkey-4c2f7c64cc2b70bd7b686e9ece1ebbc30eeab511.tar.gz sharkey-4c2f7c64cc2b70bd7b686e9ece1ebbc30eeab511.tar.bz2 sharkey-4c2f7c64cc2b70bd7b686e9ece1ebbc30eeab511.zip | |
feat: Per-user renote mute (#10249)
* feat: per-user renote muting
From FoundKey/c414f24a2c https://akkoma.dev/FoundKeyGang/FoundKey
* Update ja-JP.yml
* Delete renote-muting.ts
* rename
* fix ids
* lint
* fix
* Update CHANGELOG.md
* リノートをミュートしたユーザー一覧を見れるように
* :art:
* add test
* fix test
---------
Co-authored-by: Hélène <pleroma-dev@helene.moe>
Diffstat (limited to 'packages/backend/src/server/api/stream/index.ts')
| -rw-r--r-- | packages/backend/src/server/api/stream/index.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts index d3056aca57..0a4fd8393a 100644 --- a/packages/backend/src/server/api/stream/index.ts +++ b/packages/backend/src/server/api/stream/index.ts @@ -1,6 +1,6 @@ import type { User } from '@/models/entities/User.js'; import type { Channel as ChannelModel } from '@/models/entities/Channel.js'; -import type { FollowingsRepository, MutingsRepository, UserProfilesRepository, ChannelFollowingsRepository, BlockingsRepository } from '@/models/index.js'; +import type { FollowingsRepository, MutingsRepository, RenoteMutingsRepository, UserProfilesRepository, ChannelFollowingsRepository, BlockingsRepository } from '@/models/index.js'; import type { AccessToken } from '@/models/entities/AccessToken.js'; import type { UserProfile } from '@/models/entities/UserProfile.js'; import type { Packed } from '@/misc/schema.js'; @@ -22,6 +22,7 @@ export default class Connection { public userProfile?: UserProfile | null; public following: Set<User['id']> = new Set(); public muting: Set<User['id']> = new Set(); + public renoteMuting: Set<User['id']> = new Set(); public blocking: Set<User['id']> = new Set(); // "被"blocking public followingChannels: Set<ChannelModel['id']> = new Set(); public token?: AccessToken; @@ -34,6 +35,7 @@ export default class Connection { constructor( private followingsRepository: FollowingsRepository, private mutingsRepository: MutingsRepository, + private renoteMutingsRepository: RenoteMutingsRepository, private blockingsRepository: BlockingsRepository, private channelFollowingsRepository: ChannelFollowingsRepository, private userProfilesRepository: UserProfilesRepository, @@ -66,6 +68,7 @@ export default class Connection { if (this.user) { this.updateFollowing(); this.updateMuting(); + this.updateRenoteMuting(); this.updateBlocking(); this.updateFollowingChannels(); this.updateUserProfile(); @@ -93,6 +96,7 @@ export default class Connection { this.muting.delete(data.body.id); break; + // TODO: renote mute events // TODO: block events case 'followChannel': @@ -343,6 +347,18 @@ export default class Connection { } @bindThis + private async updateRenoteMuting() { + const renoteMutings = await this.renoteMutingsRepository.find({ + where: { + muterId: this.user!.id, + }, + select: ['muteeId'], + }); + + this.renoteMuting = new Set<string>(renoteMutings.map(x => x.muteeId)); + } + + @bindThis private async updateBlocking() { // ここでいうBlockingは被Blockingの意 const blockings = await this.blockingsRepository.find({ where: { |