diff --git a/api-gateway/src/api/service/notifications.ts b/api-gateway/src/api/service/notifications.ts index 4339460bca..f2851aaa89 100644 --- a/api-gateway/src/api/service/notifications.ts +++ b/api-gateway/src/api/service/notifications.ts @@ -42,7 +42,7 @@ export class NotificationsApi { @ApiExtraModels(NotificationDTO, InternalServerErrorDTO) @ApiOkResponse({ description: - 'Successful operation. Suggested next and nested block types respectively.', + 'Successful operation. Returns notifications and count.', schema: { type: 'array', items: { @@ -96,7 +96,7 @@ export class NotificationsApi { @ApiExtraModels(NotificationDTO, InternalServerErrorDTO) @ApiOkResponse({ description: - 'Successful operation. Suggested next and nested block types respectively.', + 'Successful operation. Returns new notifications.', schema: { type: 'array', items: { @@ -139,7 +139,7 @@ export class NotificationsApi { @ApiExtraModels(ProgressDTO, InternalServerErrorDTO) @ApiOkResponse({ description: - 'Successful operation. Suggested next and nested block types respectively.', + 'Successful operation. Returns progresses.', schema: { type: 'array', items: { @@ -180,7 +180,7 @@ export class NotificationsApi { @ApiExtraModels(NotificationDTO, InternalServerErrorDTO) @ApiOkResponse({ description: - 'Successful operation. Suggested next and nested block types respectively.', + 'Successful operation. Returns notifications.', schema: { type: 'array', items: { @@ -215,7 +215,7 @@ export class NotificationsApi { @ApiOperation({ summary: 'Delete notifications up to this point', - description: 'Returns deleted count.', + description: 'Returns deleted notifications count.', }) @ApiSecurity('bearerAuth') @ApiExtraModels(InternalServerErrorDTO) @@ -225,7 +225,7 @@ export class NotificationsApi { }) @ApiOkResponse({ description: - 'Successful operation. Suggested next and nested block types respectively.', + 'Successful operation. Returns deleted notifications count.', schema: { type: 'number', }, diff --git a/auth-service/src/app.ts b/auth-service/src/app.ts index cc9321aa5b..cc0e00e9c5 100644 --- a/auth-service/src/app.ts +++ b/auth-service/src/app.ts @@ -31,6 +31,7 @@ Promise.all([ NestFactory.createMicroservice(AppModule,{ transport: Transport.NATS, options: { + queue: 'auth-service', name: `${process.env.SERVICE_CHANNEL}`, servers: [ `nats://${process.env.MQ_ADDRESS}:4222` diff --git a/frontend/src/app/components/notification/notification.component.ts b/frontend/src/app/components/notification/notification.component.ts index 83a8cab827..6d0f0eb2fa 100644 --- a/frontend/src/app/components/notification/notification.component.ts +++ b/frontend/src/app/components/notification/notification.component.ts @@ -175,7 +175,9 @@ export class NotificationComponent implements OnInit { } viewProgress(taskId: string) { - this.router.navigate(['task', taskId]); + this.router.navigate(['task', taskId], { + replaceUrl: this.router.url.startsWith('/task'), + }); } onScrollNotifications(event: any) { diff --git a/frontend/src/app/modules/common/async-progress/async-progress.component.ts b/frontend/src/app/modules/common/async-progress/async-progress.component.ts index 0a855b4e31..0e1b419a27 100644 --- a/frontend/src/app/modules/common/async-progress/async-progress.component.ts +++ b/frontend/src/app/modules/common/async-progress/async-progress.component.ts @@ -143,12 +143,16 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { this.wsService.updateProfile(); this.router.navigate([ this.userRole === UserRole.USER ? 'user-profile' : 'config', - ]); + ], { + replaceUrl: true, + }); return; case TaskAction.DELETE_TOKEN: case TaskAction.UPDATE_TOKEN: case TaskAction.CREATE_TOKEN: - this.router.navigate(['tokens']); + this.router.navigate(['tokens'], { + replaceUrl: true, + }); break; case TaskAction.CLONE_POLICY: case TaskAction.CREATE_POLICY: @@ -156,6 +160,7 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { queryParams: { policyId: result, }, + replaceUrl: true, }); break; case TaskAction.IMPORT_POLICY_FILE: @@ -164,6 +169,7 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { queryParams: { policyId: result.policyId, }, + replaceUrl: true, }); break; case TaskAction.WIZARD_CREATE_POLICY: @@ -177,6 +183,7 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { queryParams: { policyId, }, + replaceUrl: true, }); break; case TaskAction.PUBLISH_POLICY: @@ -205,26 +212,32 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { text.join(''), 'The policy is invalid' ); - return; } this.router.navigate(['policy-configuration'], { queryParams: { policyId, }, + replaceUrl: true, }); } break; case TaskAction.DELETE_POLICY: - this.router.navigate(['policies']); + this.router.navigate(['policies'], { + replaceUrl: true, + }); break; case TaskAction.CREATE_SCHEMA: localStorage.removeItem('restoreSchemaData'); - this.router.navigate(['schemas']); + this.router.navigate(['schemas'], { + replaceUrl: true, + }); break; case TaskAction.PUBLISH_SCHEMA: case TaskAction.IMPORT_SCHEMA_FILE: case TaskAction.IMPORT_SCHEMA_MESSAGE: - this.router.navigate(['schemas']); + this.router.navigate(['schemas'], { + replaceUrl: true, + }); break; } } @@ -240,12 +253,16 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { case TaskAction.CONNECT_USER: this.router.navigate([ this.userRole === UserRole.USER ? 'user-profile' : 'config', - ]); + ], { + replaceUrl: true, + }); break; case TaskAction.DELETE_TOKEN: case TaskAction.UPDATE_TOKEN: case TaskAction.CREATE_TOKEN: - this.router.navigate(['tokens']); + this.router.navigate(['tokens'], { + replaceUrl: true, + }); break; case TaskAction.CLONE_POLICY: case TaskAction.CREATE_POLICY: @@ -254,13 +271,17 @@ export class AsyncProgressComponent implements OnInit, OnDestroy { case TaskAction.WIZARD_CREATE_POLICY: case TaskAction.PUBLISH_POLICY: case TaskAction.DELETE_POLICY: - this.router.navigate(['policies']); + this.router.navigate(['policies'], { + replaceUrl: true, + }); break; case TaskAction.CREATE_SCHEMA: case TaskAction.PUBLISH_SCHEMA: case TaskAction.IMPORT_SCHEMA_FILE: case TaskAction.IMPORT_SCHEMA_MESSAGE: - this.router.navigate(['schemas']); + this.router.navigate(['schemas'], { + replaceUrl: true, + }); break; } } diff --git a/guardian-service/src/app.ts b/guardian-service/src/app.ts index b580601a41..365c0fdf82 100644 --- a/guardian-service/src/app.ts +++ b/guardian-service/src/app.ts @@ -92,6 +92,7 @@ Promise.all([ NestFactory.createMicroservice(AppModule,{ transport: Transport.NATS, options: { + queue: 'guardian-service', name: `${process.env.SERVICE_CHANNEL}`, servers: [ `nats://${process.env.MQ_ADDRESS}:4222` diff --git a/guardian-service/src/helpers/notifier.ts b/guardian-service/src/helpers/notifier.ts index 60504569bc..602a4f89f0 100644 --- a/guardian-service/src/helpers/notifier.ts +++ b/guardian-service/src/helpers/notifier.ts @@ -137,7 +137,7 @@ function getNotificationResultMessage(action: TaskAction, result: any) { function getNotificationResultTitle(action: TaskAction, result: any) { switch (action) { case TaskAction.PUBLISH_POLICY: - if (result.errors && result.errors.length > 0) { + if (!result.isValid) { return; } default: diff --git a/guardian-service/src/policy-engine/helpers/policy-import-export-helper.ts b/guardian-service/src/policy-engine/helpers/policy-import-export-helper.ts index c6ee99d845..0738570bca 100644 --- a/guardian-service/src/policy-engine/helpers/policy-import-export-helper.ts +++ b/guardian-service/src/policy-engine/helpers/policy-import-export-helper.ts @@ -249,23 +249,32 @@ export class PolicyImportExportHelper { await DatabaseServer.saveTopic(topicRow.toObject()); } - notifier.completed(); policy.topicId = topicRow.topicId; - notifier.start('Publish Policy in Hedera'); - const messageServer = new MessageServer(root.hederaAccountId, root.hederaAccountKey); - const message = new PolicyMessage(MessageType.Policy, MessageAction.CreatePolicy); - message.setDocument(policy); - const messageStatus = await messageServer - .setTopicObject(parent) - .sendMessage(message); - notifier.completedAndStart('Link topic and policy'); - await topicHelper.twoWayLink(topicRow, parent, messageStatus.getId()); - notifier.completedAndStart('Publishing schemas'); - const systemSchemas = await PolicyImportExportHelper.getSystemSchemas(); - notifier.info(`Found ${systemSchemas.length} schemas`); - messageServer.setTopicObject(topicRow); - - await publishSystemSchemas(systemSchemas, messageServer, policyOwner, notifier); + + if (!versionOfTopicId) { + notifier.completedAndStart('Publish Policy in Hedera'); + const messageServer = new MessageServer(root.hederaAccountId, root.hederaAccountKey); + const message = new PolicyMessage(MessageType.Policy, MessageAction.CreatePolicy); + message.setDocument(policy); + const messageStatus = await messageServer + .setTopicObject(parent) + .sendMessage(message); + notifier.completedAndStart('Link topic and policy'); + await topicHelper.twoWayLink( + topicRow, + parent, + messageStatus.getId() + ); + + notifier.completedAndStart('Publishing schemas'); + const systemSchemas = await PolicyImportExportHelper.getSystemSchemas(); + notifier.info(`Found ${systemSchemas.length} schemas`); + messageServer.setTopicObject(topicRow); + await publishSystemSchemas(systemSchemas, messageServer, policyOwner, notifier); + } else { + notifier.completedAndStart('Skip publishing policy in Hedera'); + notifier.completedAndStart('Skip publishing schemas'); + } notifier.completed(); diff --git a/logger-service/src/app.ts b/logger-service/src/app.ts index 6197b3ce94..fa91f75168 100644 --- a/logger-service/src/app.ts +++ b/logger-service/src/app.ts @@ -26,6 +26,7 @@ Promise.all([ NestFactory.createMicroservice(AppModule,{ transport: Transport.NATS, options: { + queue: 'logger-service', name: `${process.env.SERVICE_CHANNEL}`, servers: [ `nats://${process.env.MQ_ADDRESS}:4222` diff --git a/swagger.yaml b/swagger.yaml index 5c058ecad4..c22d2b9a66 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -6523,9 +6523,7 @@ paths: parameters: [] responses: '200': - description: >- - Successful operation. Suggested next and nested block types - respectively. + description: Successful operation. Returns notifications and count. headers: X-Total-Count: description: Count of notifications @@ -6556,9 +6554,7 @@ paths: parameters: [] responses: '200': - description: >- - Successful operation. Suggested next and nested block types - respectively. + description: Successful operation. Returns new notifications. content: application/json: schema: @@ -6585,9 +6581,7 @@ paths: parameters: [] responses: '200': - description: >- - Successful operation. Suggested next and nested block types - respectively. + description: Successful operation. Returns progresses. content: application/json: schema: @@ -6614,9 +6608,7 @@ paths: parameters: [] responses: '200': - description: >- - Successful operation. Suggested next and nested block types - respectively. + description: Successful operation. Returns notifications. content: application/json: schema: @@ -6639,7 +6631,7 @@ paths: delete: operationId: NotificationsApi_delete summary: Delete notifications up to this point - description: Returns deleted count. + description: Returns deleted notifications count. parameters: - name: notificationId required: true @@ -6648,9 +6640,7 @@ paths: type: string responses: '200': - description: >- - Successful operation. Suggested next and nested block types - respectively. + description: Successful operation. Returns deleted notifications count. content: application/json: schema: