From b43e10b3530c7918ea032d449ee6ef5b010bac53 Mon Sep 17 00:00:00 2001 From: Alejo Thomas Ortega Date: Mon, 9 Dec 2024 08:57:31 -0300 Subject: [PATCH] feat: add attributes to SNS message --- package.json | 2 +- src/logic/sns.ts | 25 +++++++++++++++++++++++-- yarn.lock | 8 ++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c5f3204c..eb86c482 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@dcl/hashing": "^3.0.4", "@dcl/platform-crypto-middleware": "^1.1.0", "@dcl/platform-server-commons": "^0.0.4", - "@dcl/schemas": "^15.1.2", + "@dcl/schemas": "^15.3.0", "@ensdomains/eth-ens-namehash": "^2.0.15", "@types/busboy": "^1.5.3", "@well-known-components/env-config-provider": "^1.2.0", diff --git a/src/logic/sns.ts b/src/logic/sns.ts index 7e4443a7..350eccf2 100644 --- a/src/logic/sns.ts +++ b/src/logic/sns.ts @@ -3,6 +3,7 @@ import { DeploymentToSqs } from '@dcl/schemas/dist/misc/deployments-to-sqs' import { SnsClient } from '../types' import { chunks } from './utils' import { PublishBatchResponse } from '@aws-sdk/client-sns/dist-types/models/models_0' +import { Events } from '@dcl/schemas' export async function snsPublish( client: SnsClient, @@ -11,7 +12,17 @@ export async function snsPublish( ): Promise { const sendCommand = new PublishCommand({ TopicArn: snsArn, - Message: JSON.stringify(deploymentToSqs) + Message: JSON.stringify(deploymentToSqs), + MessageAttributes: { + type: { + DataType: 'String', + StringValue: Events.Type.WORLD + }, + subType: { + DataType: 'String', + StringValue: Events.SubType.Worlds.DEPLOYMENT + } + } }) return await client.publish(sendCommand) @@ -33,7 +44,17 @@ export async function snsPublishBatch( TopicArn: snsArn, PublishBatchRequestEntries: batch.map((world) => ({ Id: world.entity.entityId, - Message: JSON.stringify(world) + Message: JSON.stringify(world), + MessageAttributes: { + type: { + DataType: 'String', + StringValue: Events.Type.WORLD + }, + subType: { + DataType: 'String', + StringValue: Events.SubType.Worlds.DEPLOYMENT + } + } })) }) diff --git a/yarn.lock b/yarn.lock index 78fede5b..abc3ba4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -824,10 +824,10 @@ ajv-keywords "^5.1.0" mitt "^3.0.1" -"@dcl/schemas@^15.1.2": - version "15.1.2" - resolved "https://registry.yarnpkg.com/@dcl/schemas/-/schemas-15.1.2.tgz#f68512fec27951e7708368df2b420659b64a2213" - integrity sha512-RD7ML7gpQiIbSHSF1xquYfOZgq1KlYO+TvKPVmeI+X6wfj6cbC1A46NPj+Hm39lKsPqvVXivfrfhcZskGATjfA== +"@dcl/schemas@^15.3.0": + version "15.3.0" + resolved "https://registry.yarnpkg.com/@dcl/schemas/-/schemas-15.3.0.tgz#58b50477fb237e0ef9b612b7e07b1ebb59f05644" + integrity sha512-aJoa8XN0V6ZOoXiD4CJQrV1ENnE70Y1D4soGtqQYuNGy0QuLT4y9GsLNB2v3QOVPLDaO1EpJu92qFjeVnQEWVA== dependencies: ajv "^8.11.0" ajv-errors "^3.0.0"