From 924f4331ef21970844f55e2667108458d2475d39 Mon Sep 17 00:00:00 2001 From: danielailie Date: Wed, 18 Sep 2024 16:28:23 +0300 Subject: [PATCH 1/5] Add scam trigger --- schema.gql | 6 +++++ src/modules/admins/admin-operations.module.ts | 4 +++- .../admins/admin-operations.resolver.ts | 12 +++++++++- .../admins/models/scam-update.input.ts | 16 +++++++++++++ .../cache-invalidation/cache-events.module.ts | 4 +++- .../scam-trigger/markScamCollection.event.ts | 9 ++++++++ .../scam-update-events.consumer.ts | 23 +++++++++++++++++++ .../scam-update-publiser.module.ts | 19 +++++++++++++++ .../scam-update-publiser.service.ts | 14 +++++++++++ src/modules/rabbitmq/rabbit-config.ts | 2 ++ src/private.app.module.ts | 4 +++- 11 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 src/modules/admins/models/scam-update.input.ts create mode 100644 src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts create mode 100644 src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts create mode 100644 src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module.ts create mode 100644 src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.service.ts diff --git a/schema.gql b/schema.gql index 59098b0d0..c9f95ee41 100644 --- a/schema.gql +++ b/schema.gql @@ -1016,6 +1016,7 @@ type Mutation { stopNftCreate(input: StopNftCreateArgs!): TransactionNode! transferNft(input: TransferNftArgs!): TransactionNode! transferNftCreateRole(input: TransferNftCreateRoleArgs!): TransactionNode! + trigerScamUpdate(input: ScamUpdateInput!): Boolean! updateCollectionRarities(collectionTicker: String!): Boolean! updateCollectionTraits(collectionTicker: String!): Boolean! updateMarketplace(input: UpdateMarketplaceArgs!): Boolean! @@ -1342,6 +1343,11 @@ enum ScamInfoTypeEnum { scam } +input ScamUpdateInput { + collectionIdentifier: String! + type: ScamInfoTypeEnum! +} + input SearchFilter { searchTerm: String! } diff --git a/src/modules/admins/admin-operations.module.ts b/src/modules/admins/admin-operations.module.ts index af4919db0..f8ac966c7 100644 --- a/src/modules/admins/admin-operations.module.ts +++ b/src/modules/admins/admin-operations.module.ts @@ -13,11 +13,13 @@ import { NftTraitsModule } from '../nft-traits/nft-traits.module'; import { MarketplacesModuleGraph } from '../marketplaces/marketplaces.module'; import { AuthModule } from '../auth/auth.module'; import { ReportsModuleGraph } from '../reports/reports.module'; +import { ScamUpdatePublisherModule } from '../rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module'; @Module({ imports: [ CommonModule, CacheEventsPublisherModule, + ScamUpdatePublisherModule, MxCommunicationModule, NftRarityModuleGraph, NftTraitsModule, @@ -36,4 +38,4 @@ import { ReportsModuleGraph } from '../reports/reports.module'; ], exports: [FlagNftService], }) -export class AdminOperationsModuleGraph {} +export class AdminOperationsModuleGraph { } diff --git a/src/modules/admins/admin-operations.resolver.ts b/src/modules/admins/admin-operations.resolver.ts index 1955fdb35..3de04445d 100644 --- a/src/modules/admins/admin-operations.resolver.ts +++ b/src/modules/admins/admin-operations.resolver.ts @@ -17,6 +17,8 @@ import { ReportsService } from '../reports/reports.service'; import { ClearReportCollectionInput, ClearReportInput } from './models/clear-report.input'; import { MarketplaceReindexDataArgs } from '../marketplaces/models/MarketplaceReindexDataArgs'; import { GraphQLError } from 'graphql'; +import { ScamUpdatePublisherService } from '../rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.service'; +import { ScamUpdateInput } from './models/scam-update.input'; @Resolver(() => Boolean) export class AdminOperationsResolver { @@ -27,9 +29,10 @@ export class AdminOperationsResolver { private readonly nftRarityService: NftRarityService, private readonly nftTraitService: NftTraitsService, private readonly cacheEventsPublisherService: CacheEventsPublisherService, + private readonly scamUpdatePublisherService: ScamUpdatePublisherService, private readonly marketplaceEventsIndexingService: MarketplaceEventsIndexingService, private readonly marketplacesReindexService: MarketplacesReindexService, - ) {} + ) { } @Mutation(() => Boolean) @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard) @@ -157,4 +160,11 @@ export class AdminOperationsResolver { }); return true; } + + @Mutation(() => Boolean) + @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard) + async trigerScamUpdate(@Args('input', { type: () => ScamUpdateInput }) input: ScamUpdateInput): Promise { + this.scamUpdatePublisherService.publish({ collectionIdentifier: input.collectionIdentifier, type: input.type }); + return true; + } } diff --git a/src/modules/admins/models/scam-update.input.ts b/src/modules/admins/models/scam-update.input.ts new file mode 100644 index 000000000..cf7801cab --- /dev/null +++ b/src/modules/admins/models/scam-update.input.ts @@ -0,0 +1,16 @@ +import { InputType, Field } from '@nestjs/graphql'; +import { Matches } from 'class-validator'; +import { ScamInfoTypeEnum } from 'src/modules/assets/models'; +import { COLLECTION_IDENTIFIER_ERROR, COLLECTION_IDENTIFIER_RGX } from 'src/utils/constants'; + +@InputType() +export class ScamUpdateInput { + @Matches(RegExp(COLLECTION_IDENTIFIER_RGX), { + message: COLLECTION_IDENTIFIER_ERROR, + }) + @Field(() => String) + collectionIdentifier: string; + + @Field(() => ScamInfoTypeEnum) + type: ScamInfoTypeEnum; +} diff --git a/src/modules/rabbitmq/cache-invalidation/cache-events.module.ts b/src/modules/rabbitmq/cache-invalidation/cache-events.module.ts index 46db42104..008f9e93e 100644 --- a/src/modules/rabbitmq/cache-invalidation/cache-events.module.ts +++ b/src/modules/rabbitmq/cache-invalidation/cache-events.module.ts @@ -18,12 +18,14 @@ import { CampaignsCachingService } from 'src/modules/campaigns/campaigns-caching import { MarketplaceRedisHandler } from 'src/modules/marketplaces/loaders/marketplace.redis-handler'; import { AssetsSupplyRedisHandler } from 'src/modules/assets/loaders/assets-supply.redis-handler'; import { PubSubListenerModule } from 'src/pubsub/pub.sub.listener.module'; +import { ScamUpdatePublisherModule } from '../elastic-updates/scam-trigger/scam-update-publiser.module'; @Module({ imports: [ PubSubListenerModule, CommonModule, CacheInvalidationEventsModule, + ScamUpdatePublisherModule, CacheAdminEventsModule, CommonRabbitModule.register(() => { return { @@ -49,4 +51,4 @@ import { PubSubListenerModule } from 'src/pubsub/pub.sub.listener.module'; ], exports: [], }) -export class CacheEventsModule {} +export class CacheEventsModule { } diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts new file mode 100644 index 000000000..3d3f9e40e --- /dev/null +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts @@ -0,0 +1,9 @@ +import { ScamInfoTypeEnum } from "src/modules/assets/models"; + +export class MarkScamCollectionEvent { + collectionIdentifier: string; + type: ScamInfoTypeEnum + constructor(init?: Partial) { + Object.assign(this, init); + } +} diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts new file mode 100644 index 000000000..53ab90bac --- /dev/null +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts @@ -0,0 +1,23 @@ +import { Injectable } from '@nestjs/common'; +import { rabbitExchanges, rabbitQueues } from '../../rabbit-config'; +import { MarkScamCollectionEvent } from './markScamCollection.event'; +import { CompetingRabbitConsumer } from '../../rabbitmq.consumers'; +import { CollectionScamService } from 'src/modules/scam/collection-scam.service'; +import { ScamInfoTypeEnum } from 'src/modules/assets/models'; +@Injectable() +export class ScamUpdateEventsConsumer { + constructor(private readonly collectionScamService: CollectionScamService) { } + + @CompetingRabbitConsumer({ + connection: 'default', + queueName: rabbitQueues.SCAM_UPDATE, + exchange: rabbitExchanges.SCAM_UPDATE, + }) + async consumeScamEvents(event: MarkScamCollectionEvent) { + if (event.type === ScamInfoTypeEnum.none) { + await this.collectionScamService.manuallyClearCollectionScamInfo(event.collectionIdentifier) + } else { + await this.collectionScamService.manuallySetCollectionScamInfo(event.collectionIdentifier) + } + } +} diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module.ts new file mode 100644 index 000000000..cad00d2ed --- /dev/null +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module.ts @@ -0,0 +1,19 @@ +import { Global, Module } from '@nestjs/common'; +import { rabbitExchanges } from '../../rabbit-config'; +import { CommonRabbitModule } from '../../cache-invalidation/common-rabbitmq.module'; +import { ScamUpdatePublisherService } from './scam-update-publiser.service'; + +@Global() +@Module({ + imports: [ + CommonRabbitModule.register(() => { + return { + exchange: rabbitExchanges.SCAM_UPDATE, + uri: process.env.COMMON_RABBITMQ_URL, + }; + }), + ], + providers: [ScamUpdatePublisherService], + exports: [ScamUpdatePublisherService], +}) +export class ScamUpdatePublisherModule { } diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.service.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.service.ts new file mode 100644 index 000000000..584e69bf4 --- /dev/null +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.service.ts @@ -0,0 +1,14 @@ +import { Injectable } from '@nestjs/common'; +import { rabbitExchanges } from '../../rabbit-config'; +import { RabbitPublisherService } from '../../rabbit.publisher'; +import { MarkScamCollectionEvent } from './markScamCollection.event'; + + +@Injectable() +export class ScamUpdatePublisherService { + constructor(private readonly rabbitPublisherService: RabbitPublisherService) { } + + async publish(payload: MarkScamCollectionEvent) { + await this.rabbitPublisherService.publish(rabbitExchanges.SCAM_UPDATE, payload); + } +} diff --git a/src/modules/rabbitmq/rabbit-config.ts b/src/modules/rabbitmq/rabbit-config.ts index c6a5f890a..243712f68 100644 --- a/src/modules/rabbitmq/rabbit-config.ts +++ b/src/modules/rabbitmq/rabbit-config.ts @@ -14,8 +14,10 @@ export interface RabbitModuleConfig { export const rabbitExchanges = { CACHE_INVALIDATION: 'nft-cache-invalidation', NFT_LIKE: 'x_portal_gamification_nft_likes_exchange', + SCAM_UPDATE: 'nft-scam-update', }; export const rabbitQueues = { CACHE_INVALIDATION: 'nft-cache-invalidation', + SCAM_UPDATE: 'nft-scam-update', }; diff --git a/src/private.app.module.ts b/src/private.app.module.ts index aef270009..ee96127a0 100644 --- a/src/private.app.module.ts +++ b/src/private.app.module.ts @@ -14,6 +14,7 @@ import { ScamModule } from './modules/scam/scam.module'; import { NftTraitsModule } from './modules/nft-traits/nft-traits.module'; import { CacheEventsPublisherModule } from './modules/rabbitmq/cache-invalidation/cache-invalidation-publisher/change-events-publisher.module'; import * as ormconfig from './ormconfig'; +import { ScamUpdatePublisherModule } from './modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module'; @Module({ imports: [ @@ -22,6 +23,7 @@ import * as ormconfig from './ormconfig'; AdminOperationsModuleGraph, NftRarityModuleGraph, CacheEventsPublisherModule, + ScamUpdatePublisherModule, ScamModule, NftTraitsModule, MarketplacesModuleGraph, @@ -31,4 +33,4 @@ import * as ormconfig from './ormconfig'; controllers: [MetricsController, ReindexController, CachingController], exports: [NsfwUpdaterService, RarityUpdaterService], }) -export class PrivateAppModule {} +export class PrivateAppModule { } From 23927e16b3abdf24cb14fd0285491645540da647 Mon Sep 17 00:00:00 2001 From: danielailie Date: Thu, 19 Sep 2024 11:24:22 +0300 Subject: [PATCH 2/5] Add scam consumer --- .../blockchain-events/nft-events.module.ts | 3 +-- .../change-events-publisher.module.ts | 2 +- .../scam-update-consumer.module.ts | 21 +++++++++++++++++++ .../scam-update-events.consumer.ts | 2 +- src/modules/scam/scam.module.ts | 4 ++-- src/private.app.module.ts | 6 ++---- 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-consumer.module.ts diff --git a/src/modules/rabbitmq/blockchain-events/nft-events.module.ts b/src/modules/rabbitmq/blockchain-events/nft-events.module.ts index e9f4d5f50..2be513663 100644 --- a/src/modules/rabbitmq/blockchain-events/nft-events.module.ts +++ b/src/modules/rabbitmq/blockchain-events/nft-events.module.ts @@ -45,7 +45,6 @@ import { PluginModule } from 'src/plugins/plugin.module'; import { AnalyticsEventsService } from './analytics-events.service'; import { AnalyticsModule } from 'src/modules/analytics/analytics.module'; import { MintersModuleGraph } from 'src/modules/minters/minters.module'; -import { DisabledMarketplaceEventsService } from './disable-marketplace/disable-marketplace-events.service'; import { DisabledMarketplaceEventsModule } from './disable-marketplace/disable-marketplace-events.module'; @Module({ imports: [ @@ -102,4 +101,4 @@ import { DisabledMarketplaceEventsModule } from './disable-marketplace/disable-m ], exports: [NftEventsService, NftEventsConsumer], }) -export class NftEventsModule {} +export class NftEventsModule { } diff --git a/src/modules/rabbitmq/cache-invalidation/cache-invalidation-publisher/change-events-publisher.module.ts b/src/modules/rabbitmq/cache-invalidation/cache-invalidation-publisher/change-events-publisher.module.ts index f3714f555..acbec483d 100644 --- a/src/modules/rabbitmq/cache-invalidation/cache-invalidation-publisher/change-events-publisher.module.ts +++ b/src/modules/rabbitmq/cache-invalidation/cache-invalidation-publisher/change-events-publisher.module.ts @@ -16,4 +16,4 @@ import { CacheEventsPublisherService, NftLikePublisherService } from './change-e providers: [CacheEventsPublisherService, NftLikePublisherService], exports: [CacheEventsPublisherService, NftLikePublisherService], }) -export class CacheEventsPublisherModule {} +export class CacheEventsPublisherModule { } diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-consumer.module.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-consumer.module.ts new file mode 100644 index 000000000..90ca4a494 --- /dev/null +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-consumer.module.ts @@ -0,0 +1,21 @@ +import { forwardRef, Global, Module } from '@nestjs/common'; +import { rabbitExchanges } from '../../rabbit-config'; +import { CommonRabbitModule } from '../../cache-invalidation/common-rabbitmq.module'; +import { ScamUpdateEventsConsumer } from './scam-update-events.consumer'; +import { ScamModule } from 'src/modules/scam/scam.module'; + +@Global() +@Module({ + imports: [ + CommonRabbitModule.register(() => { + return { + exchange: rabbitExchanges.SCAM_UPDATE, + uri: process.env.COMMON_RABBITMQ_URL, + }; + }), + forwardRef(() => ScamModule) + ], + providers: [ScamUpdateEventsConsumer], + exports: [ScamUpdateEventsConsumer], +}) +export class ScamUpdateConsumerModule { } diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts index 53ab90bac..ad9fa4717 100644 --- a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts @@ -9,7 +9,7 @@ export class ScamUpdateEventsConsumer { constructor(private readonly collectionScamService: CollectionScamService) { } @CompetingRabbitConsumer({ - connection: 'default', + connection: 'common', queueName: rabbitQueues.SCAM_UPDATE, exchange: rabbitExchanges.SCAM_UPDATE, }) diff --git a/src/modules/scam/scam.module.ts b/src/modules/scam/scam.module.ts index 466c49fef..7cdcd398f 100644 --- a/src/modules/scam/scam.module.ts +++ b/src/modules/scam/scam.module.ts @@ -22,6 +22,6 @@ import { NftScamService } from './nft-scam.service'; CollectionScamResolver, AssetByIdentifierService, ], - exports: [NftScamService, NftScamElasticService, AssetByIdentifierService], + exports: [NftScamService, NftScamElasticService, AssetByIdentifierService, CollectionScamService], }) -export class ScamModule {} +export class ScamModule { } diff --git a/src/private.app.module.ts b/src/private.app.module.ts index ee96127a0..043d10d38 100644 --- a/src/private.app.module.ts +++ b/src/private.app.module.ts @@ -12,9 +12,8 @@ import { MetricsController } from './modules/metrics/metrics.controller'; import { NftRarityModuleGraph } from './modules/nft-rarity/nft-rarity.module'; import { ScamModule } from './modules/scam/scam.module'; import { NftTraitsModule } from './modules/nft-traits/nft-traits.module'; -import { CacheEventsPublisherModule } from './modules/rabbitmq/cache-invalidation/cache-invalidation-publisher/change-events-publisher.module'; import * as ormconfig from './ormconfig'; -import { ScamUpdatePublisherModule } from './modules/rabbitmq/elastic-updates/scam-trigger/scam-update-publiser.module'; +import { ScamUpdateConsumerModule } from './modules/rabbitmq/elastic-updates/scam-trigger/scam-update-consumer.module'; @Module({ imports: [ @@ -22,8 +21,7 @@ import { ScamUpdatePublisherModule } from './modules/rabbitmq/elastic-updates/sc CommonModule, AdminOperationsModuleGraph, NftRarityModuleGraph, - CacheEventsPublisherModule, - ScamUpdatePublisherModule, + ScamUpdateConsumerModule, ScamModule, NftTraitsModule, MarketplacesModuleGraph, From 7e2437477ad9363a87b4def2ae44e23b19ad07e4 Mon Sep 17 00:00:00 2001 From: danielailie Date: Wed, 25 Sep 2024 14:07:08 +0300 Subject: [PATCH 3/5] Update trigger scam endpoint --- schema.gql | 7 ++++++- src/modules/admins/admin-operations.resolver.ts | 2 +- src/modules/admins/models/scam-update.input.ts | 16 ++++++++++++---- .../scam-trigger/markScamCollection.event.ts | 4 ++-- .../scam-trigger/scam-update-events.consumer.ts | 12 ++++++------ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/schema.gql b/schema.gql index c9f95ee41..3bac9d41f 100644 --- a/schema.gql +++ b/schema.gql @@ -1343,9 +1343,14 @@ enum ScamInfoTypeEnum { scam } +enum ScamInputEnum { + allow + deny +} + input ScamUpdateInput { collectionIdentifier: String! - type: ScamInfoTypeEnum! + type: ScamInputEnum! } input SearchFilter { diff --git a/src/modules/admins/admin-operations.resolver.ts b/src/modules/admins/admin-operations.resolver.ts index 3de04445d..65e84a30a 100644 --- a/src/modules/admins/admin-operations.resolver.ts +++ b/src/modules/admins/admin-operations.resolver.ts @@ -162,7 +162,7 @@ export class AdminOperationsResolver { } @Mutation(() => Boolean) - @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard) + // @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard) async trigerScamUpdate(@Args('input', { type: () => ScamUpdateInput }) input: ScamUpdateInput): Promise { this.scamUpdatePublisherService.publish({ collectionIdentifier: input.collectionIdentifier, type: input.type }); return true; diff --git a/src/modules/admins/models/scam-update.input.ts b/src/modules/admins/models/scam-update.input.ts index cf7801cab..c43ccf131 100644 --- a/src/modules/admins/models/scam-update.input.ts +++ b/src/modules/admins/models/scam-update.input.ts @@ -1,6 +1,5 @@ -import { InputType, Field } from '@nestjs/graphql'; +import { InputType, Field, registerEnumType } from '@nestjs/graphql'; import { Matches } from 'class-validator'; -import { ScamInfoTypeEnum } from 'src/modules/assets/models'; import { COLLECTION_IDENTIFIER_ERROR, COLLECTION_IDENTIFIER_RGX } from 'src/utils/constants'; @InputType() @@ -11,6 +10,15 @@ export class ScamUpdateInput { @Field(() => String) collectionIdentifier: string; - @Field(() => ScamInfoTypeEnum) - type: ScamInfoTypeEnum; + @Field(() => ScamInputEnum) + type: ScamInputEnum; } + +export enum ScamInputEnum { + deny = 'deny', + allow = 'allow' +} + +registerEnumType(ScamInputEnum, { + name: 'ScamInputEnum', +}); diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts index 3d3f9e40e..77a802390 100644 --- a/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/markScamCollection.event.ts @@ -1,8 +1,8 @@ -import { ScamInfoTypeEnum } from "src/modules/assets/models"; +import { ScamInputEnum } from "src/modules/admins/models/scam-update.input"; export class MarkScamCollectionEvent { collectionIdentifier: string; - type: ScamInfoTypeEnum + type: ScamInputEnum constructor(init?: Partial) { Object.assign(this, init); } diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts index ad9fa4717..5b613acdc 100644 --- a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts @@ -3,7 +3,6 @@ import { rabbitExchanges, rabbitQueues } from '../../rabbit-config'; import { MarkScamCollectionEvent } from './markScamCollection.event'; import { CompetingRabbitConsumer } from '../../rabbitmq.consumers'; import { CollectionScamService } from 'src/modules/scam/collection-scam.service'; -import { ScamInfoTypeEnum } from 'src/modules/assets/models'; @Injectable() export class ScamUpdateEventsConsumer { constructor(private readonly collectionScamService: CollectionScamService) { } @@ -14,10 +13,11 @@ export class ScamUpdateEventsConsumer { exchange: rabbitExchanges.SCAM_UPDATE, }) async consumeScamEvents(event: MarkScamCollectionEvent) { - if (event.type === ScamInfoTypeEnum.none) { - await this.collectionScamService.manuallyClearCollectionScamInfo(event.collectionIdentifier) - } else { - await this.collectionScamService.manuallySetCollectionScamInfo(event.collectionIdentifier) - } + console.log({ event }) + // if (event.type === ScamInfoTypeEnum.none) { + // await this.collectionScamService.manuallyClearCollectionScamInfo(event.collectionIdentifier) + // } else { + // await this.collectionScamService.manuallySetCollectionScamInfo(event.collectionIdentifier) + // } } } From b3189d9d386d08fdf0d8a35c2a362a806f9c57bf Mon Sep 17 00:00:00 2001 From: danielailie Date: Wed, 25 Sep 2024 14:43:42 +0300 Subject: [PATCH 4/5] uncomment code for trigger scam --- .../scam-trigger/scam-update-events.consumer.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts index 5b613acdc..748d8411a 100644 --- a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts @@ -3,6 +3,7 @@ import { rabbitExchanges, rabbitQueues } from '../../rabbit-config'; import { MarkScamCollectionEvent } from './markScamCollection.event'; import { CompetingRabbitConsumer } from '../../rabbitmq.consumers'; import { CollectionScamService } from 'src/modules/scam/collection-scam.service'; +import { ScamInputEnum } from 'src/modules/admins/models/scam-update.input'; @Injectable() export class ScamUpdateEventsConsumer { constructor(private readonly collectionScamService: CollectionScamService) { } @@ -14,10 +15,10 @@ export class ScamUpdateEventsConsumer { }) async consumeScamEvents(event: MarkScamCollectionEvent) { console.log({ event }) - // if (event.type === ScamInfoTypeEnum.none) { - // await this.collectionScamService.manuallyClearCollectionScamInfo(event.collectionIdentifier) - // } else { - // await this.collectionScamService.manuallySetCollectionScamInfo(event.collectionIdentifier) - // } + if (event.type === ScamInputEnum.allow) { + await this.collectionScamService.manuallyClearCollectionScamInfo(event.collectionIdentifier) + } else { + await this.collectionScamService.manuallySetCollectionScamInfo(event.collectionIdentifier) + } } } From 5ab356e7b9ecd0219a0250fe2885da5396c14109 Mon Sep 17 00:00:00 2001 From: danielailie Date: Wed, 25 Sep 2024 15:47:55 +0300 Subject: [PATCH 5/5] Remove console logs --- src/modules/admins/admin-operations.resolver.ts | 2 +- .../elastic-updates/scam-trigger/scam-update-events.consumer.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/admins/admin-operations.resolver.ts b/src/modules/admins/admin-operations.resolver.ts index 65e84a30a..3de04445d 100644 --- a/src/modules/admins/admin-operations.resolver.ts +++ b/src/modules/admins/admin-operations.resolver.ts @@ -162,7 +162,7 @@ export class AdminOperationsResolver { } @Mutation(() => Boolean) - // @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard) + @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard) async trigerScamUpdate(@Args('input', { type: () => ScamUpdateInput }) input: ScamUpdateInput): Promise { this.scamUpdatePublisherService.publish({ collectionIdentifier: input.collectionIdentifier, type: input.type }); return true; diff --git a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts index 748d8411a..cf4d84e9f 100644 --- a/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts +++ b/src/modules/rabbitmq/elastic-updates/scam-trigger/scam-update-events.consumer.ts @@ -14,7 +14,6 @@ export class ScamUpdateEventsConsumer { exchange: rabbitExchanges.SCAM_UPDATE, }) async consumeScamEvents(event: MarkScamCollectionEvent) { - console.log({ event }) if (event.type === ScamInputEnum.allow) { await this.collectionScamService.manuallyClearCollectionScamInfo(event.collectionIdentifier) } else {