Fix(backend): Limit antenna/webhook/list to exact amount (#14036)
... not +1 * Update antennas/clips e2e test
This commit is contained in:
		| @@ -93,7 +93,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 			const currentAntennasCount = await this.antennasRepository.countBy({ | ||||
| 				userId: me.id, | ||||
| 			}); | ||||
| 			if (currentAntennasCount > (await this.roleService.getUserPolicies(me.id)).antennaLimit) { | ||||
| 			if (currentAntennasCount >= (await this.roleService.getUserPolicies(me.id)).antennaLimit) { | ||||
| 				throw new ApiError(meta.errors.tooManyAntennas); | ||||
| 			} | ||||
|  | ||||
|   | ||||
| @@ -78,7 +78,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { | ||||
| 			if (file.size === 0) throw new ApiError(meta.errors.emptyFile); | ||||
| 			const antennas: (_Antenna & { userListAccts: string[] | null })[] = JSON.parse(await this.downloadService.downloadTextFile(file.url)); | ||||
| 			const currentAntennasCount = await this.antennasRepository.countBy({ userId: me.id }); | ||||
| 			if (currentAntennasCount + antennas.length > (await this.roleService.getUserPolicies(me.id)).antennaLimit) { | ||||
| 			if (currentAntennasCount + antennas.length >= (await this.roleService.getUserPolicies(me.id)).antennaLimit) { | ||||
| 				throw new ApiError(meta.errors.tooManyAntennas); | ||||
| 			} | ||||
| 			this.queueService.createImportAntennasJob(me, antennas); | ||||
|   | ||||
| @@ -85,7 +85,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 			const currentWebhooksCount = await this.webhooksRepository.countBy({ | ||||
| 				userId: me.id, | ||||
| 			}); | ||||
| 			if (currentWebhooksCount > (await this.roleService.getUserPolicies(me.id)).webhookLimit) { | ||||
| 			if (currentWebhooksCount >= (await this.roleService.getUserPolicies(me.id)).webhookLimit) { | ||||
| 				throw new ApiError(meta.errors.tooManyWebhooks); | ||||
| 			} | ||||
|  | ||||
|   | ||||
| @@ -100,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 			const currentCount = await this.userListsRepository.countBy({ | ||||
| 				userId: me.id, | ||||
| 			}); | ||||
| 			if (currentCount > (await this.roleService.getUserPolicies(me.id)).userListLimit) { | ||||
| 			if (currentCount >= (await this.roleService.getUserPolicies(me.id)).userListLimit) { | ||||
| 				throw new ApiError(meta.errors.tooManyUserLists); | ||||
| 			} | ||||
|  | ||||
|   | ||||
| @@ -61,7 +61,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | ||||
| 			const currentCount = await this.userListsRepository.countBy({ | ||||
| 				userId: me.id, | ||||
| 			}); | ||||
| 			if (currentCount > (await this.roleService.getUserPolicies(me.id)).userListLimit) { | ||||
| 			if (currentCount >= (await this.roleService.getUserPolicies(me.id)).userListLimit) { | ||||
| 				throw new ApiError(meta.errors.tooManyUserLists); | ||||
| 			} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ryu jongheon
					Ryu jongheon