Skip to content

Commit

Permalink
Update trigger scam endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Sep 25, 2024
1 parent 23927e1 commit 7e24374
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
7 changes: 6 additions & 1 deletion schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -1343,9 +1343,14 @@ enum ScamInfoTypeEnum {
scam
}

enum ScamInputEnum {
allow
deny
}

input ScamUpdateInput {
collectionIdentifier: String!
type: ScamInfoTypeEnum!
type: ScamInputEnum!
}

input SearchFilter {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/admins/admin-operations.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class AdminOperationsResolver {
}

@Mutation(() => Boolean)
@UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard)
// @UseGuards(JwtOrNativeAuthGuard, GqlAdminAuthGuard)
async trigerScamUpdate(@Args('input', { type: () => ScamUpdateInput }) input: ScamUpdateInput): Promise<boolean> {
this.scamUpdatePublisherService.publish({ collectionIdentifier: input.collectionIdentifier, type: input.type });
return true;
Expand Down
16 changes: 12 additions & 4 deletions src/modules/admins/models/scam-update.input.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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',
});
Original file line number Diff line number Diff line change
@@ -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<MarkScamCollectionEvent>) {
Object.assign(this, init);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand All @@ -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)
// }
}
}

0 comments on commit 7e24374

Please sign in to comment.