fix(backend): リノートミュートがキャッシュが切れるまで効かない問題を修正 (#14242)
* Fix: RenoteMuteがキャッシュが切れるまで効かない問題を修正
(cherry picked from commit e9601029b5)
* update changelog
* 🎨
* remove unused import
* 消したときもキャッシュを飛ばすように
* lint
---------
Co-authored-by: mattyatea <mattyacocacora0@gmail.com>
			
			
This commit is contained in:
		| @@ -6,12 +6,11 @@ | ||||
| import { Inject, Injectable } from '@nestjs/common'; | ||||
| import ms from 'ms'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import { IdService } from '@/core/IdService.js'; | ||||
| import type { RenoteMutingsRepository } from '@/models/_.js'; | ||||
| import type { MiRenoteMuting } from '@/models/RenoteMuting.js'; | ||||
| import { DI } from '@/di-symbols.js'; | ||||
| import { GetterService } from '@/server/api/GetterService.js'; | ||||
| import { ApiError } from '../../error.js'; | ||||
| import { UserRenoteMutingService } from "@/core/UserRenoteMutingService.js"; | ||||
| import type { RenoteMutingsRepository } from '@/models/_.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['account'], | ||||
| @@ -62,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 		private renoteMutingsRepository: RenoteMutingsRepository, | ||||
|  | ||||
| 		private getterService: GetterService, | ||||
| 		private idService: IdService, | ||||
| 		private userRenoteMutingService: UserRenoteMutingService, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 			const muter = me; | ||||
| @@ -79,21 +78,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 			}); | ||||
|  | ||||
| 			// Check if already muting | ||||
| 			const exist = await this.renoteMutingsRepository.findOneBy({ | ||||
| 				muterId: muter.id, | ||||
| 				muteeId: mutee.id, | ||||
| 			const exist = await this.renoteMutingsRepository.exists({ | ||||
| 				where: { | ||||
| 					muterId: muter.id, | ||||
| 					muteeId: mutee.id, | ||||
| 				}, | ||||
| 			}); | ||||
|  | ||||
| 			if (exist != null) { | ||||
| 			if (exist === true) { | ||||
| 				throw new ApiError(meta.errors.alreadyMuting); | ||||
| 			} | ||||
|  | ||||
| 			// Create mute | ||||
| 			await this.renoteMutingsRepository.insert({ | ||||
| 				id: this.idService.gen(), | ||||
| 				muterId: muter.id, | ||||
| 				muteeId: mutee.id, | ||||
| 			} as MiRenoteMuting); | ||||
| 			await this.userRenoteMutingService.mute(muter, mutee); | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -5,10 +5,11 @@ | ||||
|  | ||||
| import { Inject, Injectable } from '@nestjs/common'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import type { RenoteMutingsRepository } from '@/models/_.js'; | ||||
| import { DI } from '@/di-symbols.js'; | ||||
| import { GetterService } from '@/server/api/GetterService.js'; | ||||
| import { ApiError } from '../../error.js'; | ||||
| import { UserRenoteMutingService } from "@/core/UserRenoteMutingService.js"; | ||||
| import type { RenoteMutingsRepository } from '@/models/_.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['account'], | ||||
| @@ -53,6 +54,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 		private renoteMutingsRepository: RenoteMutingsRepository, | ||||
|  | ||||
| 		private getterService: GetterService, | ||||
| 		private userRenoteMutingService: UserRenoteMutingService, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 			const muter = me; | ||||
| @@ -79,9 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 			} | ||||
|  | ||||
| 			// Delete mute | ||||
| 			await this.renoteMutingsRepository.delete({ | ||||
| 				id: exist.id, | ||||
| 			}); | ||||
| 			await this.userRenoteMutingService.unmute([exist]); | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 かっこかり
					かっこかり