Skip to content

Commit

Permalink
fix: add invalidation importPolicyFromXlsx importPolicyFromXlsxAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
Ihar committed Oct 3, 2024
1 parent 560c583 commit f4b3241
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions api-gateway/src/api/service/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,8 @@ export class SchemaApi {
@AuthUser() user: IAuthUser,
@Param('topicId') topicId: string,
@Body() file: ArrayBuffer,
@Response() res: any
@Response() res: any,
@Req() req
): Promise<any> {
if (!file) {
throw new HttpException('File in body is empty', HttpStatus.UNPROCESSABLE_ENTITY)
Expand All @@ -2306,6 +2307,11 @@ export class SchemaApi {
category: SchemaCategory.POLICY
}, owner);
SchemaHelper.updatePermission(items, owner);

const invalidedCacheKeys = [`${PREFIXES.SCHEMES}schema-with-sub-schemas`];

await this.cacheService.invalidate(getCacheKey([req.url, ...invalidedCacheKeys], user))

return res.status(201).header('X-Total-Count', count).send(SchemaUtils.toOld(items));
} catch (error) {
await InternalException(error, this.logger);
Expand Down Expand Up @@ -2352,7 +2358,8 @@ export class SchemaApi {
@AuthUser() user: IAuthUser,
@Param('topicId') topicId: string,
@Body() file: ArrayBuffer,
@Response() res: any
@Response() res: any,
@Req() req
): Promise<any> {
if (!file) {
throw new HttpException('File in body is empty', HttpStatus.UNPROCESSABLE_ENTITY)
Expand All @@ -2367,6 +2374,10 @@ export class SchemaApi {
await this.logger.error(error, ['API_GATEWAY']);
taskManager.addError(task.taskId, { code: 500, message: 'Unknown error: ' + error.message });
});
const invalidedCacheKeys = [`${PREFIXES.SCHEMES}schema-with-sub-schemas`];

await this.cacheService.invalidate(getCacheKey([req.url, ...invalidedCacheKeys], user))

return res.status(202).send(task);
}

Expand Down

0 comments on commit f4b3241

Please sign in to comment.