mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-12 11:29:38 -06:00
feat/force MessageGroupId
This commit is contained in:
parent
17120e91a4
commit
edb4fa3b3e
@ -103,6 +103,7 @@ export class SqsController extends EventController implements EventControllerInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.sqs) {
|
if (this.sqs) {
|
||||||
|
const serverConfig = configService.get<HttpServer>('SERVER');
|
||||||
const sqsConfig = configService.get<Sqs>('SQS');
|
const sqsConfig = configService.get<Sqs>('SQS');
|
||||||
|
|
||||||
const we = event.replace(/[.-]/gm, '_').toUpperCase();
|
const we = event.replace(/[.-]/gm, '_').toUpperCase();
|
||||||
@ -118,7 +119,6 @@ export class SqsController extends EventController implements EventControllerInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(sqsEvents) && sqsEvents.includes(we)) {
|
if (Array.isArray(sqsEvents) && sqsEvents.includes(we)) {
|
||||||
const serverName = sqsConfig.GLOBAL_ENABLED ? configService.get<HttpServer>('SERVER').NAME : 'evolution';
|
|
||||||
const prefixName = sqsConfig.GLOBAL_ENABLED ? sqsConfig.GLOBAL_PREFIX_NAME : instanceName;
|
const prefixName = sqsConfig.GLOBAL_ENABLED ? sqsConfig.GLOBAL_PREFIX_NAME : instanceName;
|
||||||
const eventFormatted =
|
const eventFormatted =
|
||||||
sqsConfig.GLOBAL_ENABLED && sqsConfig.GLOBAL_FORCE_SINGLE_QUEUE
|
sqsConfig.GLOBAL_ENABLED && sqsConfig.GLOBAL_FORCE_SINGLE_QUEUE
|
||||||
@ -132,7 +132,7 @@ export class SqsController extends EventController implements EventControllerInt
|
|||||||
instance: instanceName,
|
instance: instanceName,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data,
|
data,
|
||||||
server: serverName,
|
server: serverConfig.NAME,
|
||||||
server_url: serverUrl,
|
server_url: serverUrl,
|
||||||
date_time: dateTime,
|
date_time: dateTime,
|
||||||
sender,
|
sender,
|
||||||
@ -163,10 +163,11 @@ export class SqsController extends EventController implements EventControllerInt
|
|||||||
message.dataType = 's3';
|
message.dataType = 's3';
|
||||||
}
|
}
|
||||||
|
|
||||||
const isGlobalEnabled = configService.get<Sqs>('SQS').GLOBAL_ENABLED;
|
const messageGroupId = sqsConfig.GLOBAL_ENABLED ? `${serverConfig.NAME}-${instanceName}` : 'evolution';
|
||||||
|
const isGlobalEnabled = sqsConfig.GLOBAL_ENABLED;
|
||||||
const params = {
|
const params = {
|
||||||
MessageBody: JSON.stringify(message),
|
MessageBody: JSON.stringify(message),
|
||||||
MessageGroupId: serverName,
|
MessageGroupId: messageGroupId,
|
||||||
QueueUrl: sqsUrl,
|
QueueUrl: sqsUrl,
|
||||||
...(!isGlobalEnabled && {
|
...(!isGlobalEnabled && {
|
||||||
MessageDeduplicationId: `${instanceName}_${eventFormatted}_${Date.now()}`,
|
MessageDeduplicationId: `${instanceName}_${eventFormatted}_${Date.now()}`,
|
||||||
@ -208,9 +209,7 @@ export class SqsController extends EventController implements EventControllerInt
|
|||||||
|
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
const normalizedEvent =
|
const normalizedEvent =
|
||||||
sqsConfig.GLOBAL_ENABLED && sqsConfig.GLOBAL_FORCE_SINGLE_QUEUE
|
sqsConfig.GLOBAL_ENABLED && sqsConfig.GLOBAL_FORCE_SINGLE_QUEUE ? 'singlequeue' : event.toLowerCase();
|
||||||
? 'singlequeue'
|
|
||||||
: event.toLowerCase();
|
|
||||||
if (eventsFinded.includes(normalizedEvent)) {
|
if (eventsFinded.includes(normalizedEvent)) {
|
||||||
this.logger.info(`A queue para o evento "${normalizedEvent}" já existe. Ignorando criação.`);
|
this.logger.info(`A queue para o evento "${normalizedEvent}" já existe. Ignorando criação.`);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user