-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(backend): リノートミュートがキャッシュが切れるまで効かない問題を修正 (#14242)
* Fix: RenoteMuteがキャッシュが切れるまで効かない問題を修正 (cherry picked from commit e960102) * update changelog * 🎨 * remove unused import * 消したときもキャッシュを飛ばすように * lint --------- Co-authored-by: mattyatea <mattyacocacora0@gmail.com>
- Loading branch information
1 parent
c3a6da1
commit de166a8
Showing
5 changed files
with
74 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project , Type4ny-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { In } from 'typeorm'; | ||
import type { RenoteMutingsRepository } from '@/models/_.js'; | ||
import type { MiRenoteMuting } from '@/models/RenoteMuting.js'; | ||
|
||
import { IdService } from '@/core/IdService.js'; | ||
import type { MiUser } from '@/models/User.js'; | ||
import { DI } from '@/di-symbols.js'; | ||
import { bindThis } from '@/decorators.js'; | ||
import { CacheService } from '@/core/CacheService.js'; | ||
|
||
@Injectable() | ||
export class UserRenoteMutingService { | ||
constructor( | ||
@Inject(DI.renoteMutingsRepository) | ||
private renoteMutingsRepository: RenoteMutingsRepository, | ||
|
||
private idService: IdService, | ||
private cacheService: CacheService, | ||
) { | ||
} | ||
|
||
@bindThis | ||
public async mute(user: MiUser, target: MiUser, expiresAt: Date | null = null): Promise<void> { | ||
await this.renoteMutingsRepository.insert({ | ||
id: this.idService.gen(), | ||
muterId: user.id, | ||
muteeId: target.id, | ||
}); | ||
|
||
await this.cacheService.renoteMutingsCache.refresh(user.id); | ||
} | ||
|
||
@bindThis | ||
public async unmute(mutings: MiRenoteMuting[]): Promise<void> { | ||
if (mutings.length === 0) return; | ||
|
||
await this.renoteMutingsRepository.delete({ | ||
id: In(mutings.map(m => m.id)), | ||
}); | ||
|
||
const muterIds = [...new Set(mutings.map(m => m.muterId))]; | ||
for (const muterId of muterIds) { | ||
await this.cacheService.renoteMutingsCache.refresh(muterId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters