fix: removed link preview endpoint, now it's done automatically from sending conventional text

This commit is contained in:
Davidson Gomes 2023-07-16 17:57:37 -03:00
parent ec7ad70458
commit b9eb8d45b2
6 changed files with 6 additions and 70 deletions

View File

@ -6,6 +6,7 @@
* Docker files adjusted * Docker files adjusted
* Fixed in the postman collection the webhookByEvent parameter by webhook_by_events * Fixed in the postman collection the webhookByEvent parameter by webhook_by_events
* Now it's getting the API URL directly in the request, no longer need the variable in the env file * Now it's getting the API URL directly in the request, no longer need the variable in the env file
* Removed link preview endpoint, now it's done automatically from sending conventional text
# 1.2.2 (2023-07-15 09:36) # 1.2.2 (2023-07-15 09:36)

View File

@ -144,24 +144,6 @@ export const textMessageSchema: JSONSchema7 = {
required: ['textMessage', 'number'], required: ['textMessage', 'number'],
}; };
export const linkPreviewSchema: JSONSchema7 = {
$id: v4(),
type: 'object',
properties: {
number: { ...numberDefinition },
options: { ...optionsSchema },
linkPreview: {
type: 'object',
properties: {
text: { type: 'string' },
},
required: ['text'],
...isNotEmpty('text'),
},
},
required: ['linkPreview', 'number'],
};
export const pollMessageSchema: JSONSchema7 = { export const pollMessageSchema: JSONSchema7 = {
$id: v4(), $id: v4(),
type: 'object', type: 'object',

View File

@ -119,9 +119,4 @@ export class SendMessageController {
logger.verbose('requested sendStatus from ' + instanceName + ' instance'); logger.verbose('requested sendStatus from ' + instanceName + ' instance');
return await this.waMonitor.waInstances[instanceName].statusMessage(data); return await this.waMonitor.waInstances[instanceName].statusMessage(data);
} }
public async sendLinkPreview({ instanceName }: InstanceDto, data: SendLinkPreviewDto) {
logger.verbose('requested sendLinkPreview from ' + instanceName + ' instance');
return await this.waMonitor.waInstances[instanceName].linkPreview(data);
}
} }

View File

@ -28,10 +28,6 @@ class TextMessage {
text: string; text: string;
} }
class linkPreviewMessage {
text: string;
}
export class StatusMessage { export class StatusMessage {
type: string; type: string;
content: string; content: string;
@ -52,10 +48,6 @@ export class SendTextDto extends Metadata {
textMessage: TextMessage; textMessage: TextMessage;
} }
export class SendLinkPreviewDto extends Metadata {
linkPreview: linkPreviewMessage;
}
export class SendStatusDto extends Metadata { export class SendStatusDto extends Metadata {
statusMessage: StatusMessage; statusMessage: StatusMessage;
} }

View File

@ -3,7 +3,6 @@ import {
audioMessageSchema, audioMessageSchema,
buttonMessageSchema, buttonMessageSchema,
contactMessageSchema, contactMessageSchema,
linkPreviewSchema,
listMessageSchema, listMessageSchema,
locationMessageSchema, locationMessageSchema,
mediaMessageSchema, mediaMessageSchema,
@ -17,7 +16,6 @@ import {
SendAudioDto, SendAudioDto,
SendButtonDto, SendButtonDto,
SendContactDto, SendContactDto,
SendLinkPreviewDto,
SendListDto, SendListDto,
SendLocationDto, SendLocationDto,
SendMediaDto, SendMediaDto,
@ -199,23 +197,6 @@ export class MessageRouter extends RouterBroker {
return res.status(HttpStatus.CREATED).json(response); return res.status(HttpStatus.CREATED).json(response);
}) })
.post(this.routerPath('sendLinkPreview'), ...guards, async (req, res) => {
logger.verbose('request received in sendLinkPreview');
logger.verbose('request body: ');
logger.verbose(req.body);
logger.verbose('request query: ');
logger.verbose(req.query);
const response = await this.dataValidate<SendLinkPreviewDto>({
request: req,
schema: linkPreviewSchema,
ClassRef: SendLinkPreviewDto,
execute: (instance, data) =>
sendMessageController.sendLinkPreview(instance, data),
});
return res.status(HttpStatus.CREATED).json(response);
})
.post(this.routerPath('sendSticker'), ...guards, async (req, res) => { .post(this.routerPath('sendSticker'), ...guards, async (req, res) => {
logger.verbose('request received in sendSticker'); logger.verbose('request received in sendSticker');
logger.verbose('request body: '); logger.verbose('request body: ');

View File

@ -76,7 +76,6 @@ import {
SendReactionDto, SendReactionDto,
SendTextDto, SendTextDto,
SendPollDto, SendPollDto,
SendLinkPreviewDto,
SendStickerDto, SendStickerDto,
SendStatusDto, SendStatusDto,
StatusMessage, StatusMessage,
@ -1476,8 +1475,8 @@ export class WAStartupService {
if ( if (
!message['audio'] && !message['audio'] &&
!message['poll'] && !message['poll'] &&
!message['linkPreview'] &&
!message['sticker'] && !message['sticker'] &&
!message['conversation'] &&
!sender.includes('@broadcast') !sender.includes('@broadcast')
) { ) {
if (!message['audio']) { if (!message['audio']) {
@ -1496,12 +1495,13 @@ export class WAStartupService {
} }
} }
if (message['linkPreview']) { if (message['conversation']) {
console.log(message['conversation']);
this.logger.verbose('Sending message'); this.logger.verbose('Sending message');
return await this.client.sendMessage( return await this.client.sendMessage(
sender, sender,
{ {
text: message['linkPreview'].text, text: message['conversation'],
} as unknown as AnyMessageContent, } as unknown as AnyMessageContent,
option as unknown as MiscMessageGenerationOptions, option as unknown as MiscMessageGenerationOptions,
); );
@ -1583,19 +1583,6 @@ export class WAStartupService {
); );
} }
public async linkPreview(data: SendLinkPreviewDto) {
this.logger.verbose('Sending link preview');
return await this.sendMessageWithTyping(
data.number,
{
linkPreview: {
text: data.linkPreview.text,
},
},
data?.options,
);
}
public async pollMessage(data: SendPollDto) { public async pollMessage(data: SendPollDto) {
this.logger.verbose('Sending poll message'); this.logger.verbose('Sending poll message');
return await this.sendMessageWithTyping( return await this.sendMessageWithTyping(
@ -2646,9 +2633,7 @@ export class WAStartupService {
const msg = `${description}\n\n${inviteUrl}`; const msg = `${description}\n\n${inviteUrl}`;
const message = { const message = {
linkPreview: { conversation: msg,
text: msg,
},
}; };
for await (const number of numbers) { for await (const number of numbers) {