Skip to content

Commit

Permalink
feat: add attributes to SNS message
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed Dec 9, 2024
1 parent 3897837 commit b43e10b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 23 additions & 2 deletions src/logic/sns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -11,7 +12,17 @@ export async function snsPublish(
): Promise<PublishCommandOutput> {
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)
Expand All @@ -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
}
}
}))
})

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b43e10b

Please sign in to comment.