mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 12:06:54 -06:00
feat: adiciona o status da mensagem no retorno da função "prepareMessage"
This commit is contained in:
parent
79170b8f01
commit
68b5d8db4d
@ -439,7 +439,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return webMessageInfo[0].message;
|
||||
} catch (error) {
|
||||
this.logger.error('line 508');
|
||||
return { conversation: '' };
|
||||
}
|
||||
}
|
||||
@ -594,7 +593,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return await this.createClient(number);
|
||||
} catch (error) {
|
||||
this.logger.error('line 667');
|
||||
this.logger.error(error);
|
||||
throw new InternalServerErrorException(error?.toString());
|
||||
}
|
||||
@ -604,7 +602,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
try {
|
||||
return await this.createClient(this.phoneNumber);
|
||||
} catch (error) {
|
||||
this.logger.error('line 677');
|
||||
this.logger.error(error);
|
||||
throw new InternalServerErrorException(error?.toString());
|
||||
}
|
||||
@ -758,7 +755,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.logger.error('line 817');
|
||||
this.logger.error(`Error: ${error.message}`);
|
||||
}
|
||||
},
|
||||
@ -948,7 +944,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
messages = undefined;
|
||||
chats = undefined;
|
||||
} catch (error) {
|
||||
this.logger.error('line 1011');
|
||||
this.logger.error(error);
|
||||
}
|
||||
},
|
||||
@ -1136,7 +1131,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
data: messageRaw,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('line 1181');
|
||||
this.logger.error(['Error on upload file to minio', error?.message, error?.stack]);
|
||||
}
|
||||
}
|
||||
@ -1227,7 +1221,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error('line 1318');
|
||||
this.logger.error(error);
|
||||
}
|
||||
},
|
||||
@ -2015,7 +2008,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
data: messageRaw,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('line 1181');
|
||||
this.logger.error(['Error on upload file to minio', error?.message, error?.stack]);
|
||||
}
|
||||
}
|
||||
@ -2051,7 +2043,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return messageRaw;
|
||||
} catch (error) {
|
||||
this.logger.error('line 2097');
|
||||
this.logger.error(error);
|
||||
throw new BadRequestException(error.toString());
|
||||
}
|
||||
@ -2104,7 +2095,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { presence: data.presence };
|
||||
} catch (error) {
|
||||
this.logger.error('line 2134');
|
||||
this.logger.error(error);
|
||||
throw new BadRequestException(error.toString());
|
||||
}
|
||||
@ -2117,7 +2107,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { presence: data.presence };
|
||||
} catch (error) {
|
||||
this.logger.error('line 2147');
|
||||
this.logger.error(error);
|
||||
throw new BadRequestException(error.toString());
|
||||
}
|
||||
@ -2348,7 +2337,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
{ userJid: this.instance.wuid },
|
||||
);
|
||||
} catch (error) {
|
||||
this.logger.error('line 2378');
|
||||
this.logger.error(error);
|
||||
throw new InternalServerErrorException(error?.toString() || error);
|
||||
}
|
||||
@ -2390,7 +2378,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return webpBuffer;
|
||||
} catch (error) {
|
||||
this.logger.error('line 2420');
|
||||
console.error('Erro ao converter a imagem para WebP:', error);
|
||||
throw error;
|
||||
}
|
||||
@ -2807,7 +2794,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
await this.client.readMessages(keys);
|
||||
return { message: 'Read messages', read: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 2818');
|
||||
throw new InternalServerErrorException('Read messages fail', error.toString());
|
||||
}
|
||||
}
|
||||
@ -2873,7 +2859,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
archived: true,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error('line 2884');
|
||||
throw new InternalServerErrorException({
|
||||
archived: false,
|
||||
message: ['An error occurred while archiving the chat. Open a calling.', error.toString()],
|
||||
@ -2911,7 +2896,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
markedChatUnread: true,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error('line 2922');
|
||||
throw new InternalServerErrorException({
|
||||
markedChatUnread: false,
|
||||
message: ['An error occurred while marked unread the chat. Open a calling.', error.toString()],
|
||||
@ -2923,7 +2907,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
try {
|
||||
return await this.client.sendMessage(del.remoteJid, { delete: del });
|
||||
} catch (error) {
|
||||
this.logger.error('line 2934');
|
||||
throw new InternalServerErrorException('Error while deleting message for everyone', error?.toString());
|
||||
}
|
||||
}
|
||||
@ -3015,7 +2998,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
buffer: getBuffer ? buffer : null,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error('line 3026');
|
||||
this.logger.error(error);
|
||||
throw new BadRequestException(error.toString());
|
||||
}
|
||||
@ -3057,7 +3039,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error('line 3068');
|
||||
throw new InternalServerErrorException('Error updating privacy settings', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3083,7 +3064,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
...profile,
|
||||
};
|
||||
} catch (error) {
|
||||
this.logger.error('line 3094');
|
||||
throw new InternalServerErrorException('Error updating profile name', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3094,7 +3074,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3105');
|
||||
throw new InternalServerErrorException('Error updating profile name', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3105,7 +3084,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3116');
|
||||
throw new InternalServerErrorException('Error updating profile status', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3147,7 +3125,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3158');
|
||||
throw new InternalServerErrorException('Error updating profile picture', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3160,7 +3137,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3171');
|
||||
throw new InternalServerErrorException('Error removing profile picture', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3181,7 +3157,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { block: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3192');
|
||||
throw new InternalServerErrorException('Error blocking user', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3212,7 +3187,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
this.logger.error('line 3223');
|
||||
this.logger.error(error);
|
||||
throw new BadRequestException(error.toString());
|
||||
}
|
||||
@ -3234,7 +3208,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
edit: data.key,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('line 3245');
|
||||
this.logger.error(error);
|
||||
throw new BadRequestException(error.toString());
|
||||
}
|
||||
@ -3277,7 +3250,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
return { numberJid: contact.jid, labelId: data.labelId, remove: true };
|
||||
}
|
||||
} catch (error) {
|
||||
this.logger.error('line 3288');
|
||||
throw new BadRequestException(`Unable to ${data.action} label to chat`, error.toString());
|
||||
}
|
||||
}
|
||||
@ -3299,7 +3271,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return meta;
|
||||
} catch (error) {
|
||||
this.logger.error('line 3310');
|
||||
this.logger.error(error);
|
||||
return null;
|
||||
}
|
||||
@ -3352,7 +3323,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return group;
|
||||
} catch (error) {
|
||||
this.logger.error('line 3363');
|
||||
this.logger.error(error);
|
||||
throw new InternalServerErrorException('Error creating group', error.toString());
|
||||
}
|
||||
@ -3392,7 +3362,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3403');
|
||||
throw new InternalServerErrorException('Error update group picture', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3403,7 +3372,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3414');
|
||||
throw new InternalServerErrorException('Error updating group subject', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3414,7 +3382,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3425');
|
||||
throw new InternalServerErrorException('Error updating group description', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3449,7 +3416,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
if (reply === 'inner') {
|
||||
return;
|
||||
}
|
||||
this.logger.error('line 3460');
|
||||
throw new NotFoundException('Error fetching group', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3491,7 +3457,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const code = await this.client.groupInviteCode(id.groupJid);
|
||||
return { inviteUrl: `https://chat.whatsapp.com/${code}`, inviteCode: code };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3502');
|
||||
throw new NotFoundException('No invite code', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3500,7 +3465,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
try {
|
||||
return await this.client.groupGetInviteInfo(id.inviteCode);
|
||||
} catch (error) {
|
||||
this.logger.error('line 3511');
|
||||
throw new NotFoundException('No invite info', id.inviteCode);
|
||||
}
|
||||
}
|
||||
@ -3526,7 +3490,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
return { send: true, inviteUrl };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3537');
|
||||
throw new NotFoundException('No send invite');
|
||||
}
|
||||
}
|
||||
@ -3536,7 +3499,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const groupJid = await this.client.groupAcceptInvite(id.inviteCode);
|
||||
return { accepted: true, groupJid: groupJid };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3547');
|
||||
throw new NotFoundException('Accept invite error', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3546,7 +3508,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const inviteCode = await this.client.groupRevokeInvite(id.groupJid);
|
||||
return { revoked: true, inviteCode };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3557');
|
||||
throw new NotFoundException('Revoke error', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3579,7 +3540,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
return { participants: parsedParticipants };
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.logger.error('line 3583');
|
||||
throw new NotFoundException('No participants', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3594,7 +3554,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
);
|
||||
return { updateParticipants: updateParticipants };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3598');
|
||||
throw new BadRequestException('Error updating participants', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3604,7 +3563,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const updateSetting = await this.client.groupSettingUpdate(update.groupJid, update.action);
|
||||
return { updateSetting: updateSetting };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3608');
|
||||
throw new BadRequestException('Error updating setting', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3614,7 +3572,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
await this.client.groupToggleEphemeral(update.groupJid, update.expiration);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3618');
|
||||
throw new BadRequestException('Error updating setting', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3624,7 +3581,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
await this.client.groupLeave(id.groupJid);
|
||||
return { groupJid: id.groupJid, leave: true };
|
||||
} catch (error) {
|
||||
this.logger.error('line 3628');
|
||||
throw new BadRequestException('Unable to leave the group', error.toString());
|
||||
}
|
||||
}
|
||||
@ -3638,6 +3594,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const messageRaw = {
|
||||
key: message.key,
|
||||
pushName: message.pushName,
|
||||
status: message.status,
|
||||
message: { ...message.message },
|
||||
contextInfo: contentMsg?.contextInfo,
|
||||
messageType: getContentType(message.message) || 'unknown',
|
||||
@ -3652,6 +3609,12 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
delete messageRaw.message.extendedTextMessage;
|
||||
}
|
||||
|
||||
if (messageRaw.message.documentWithCaptionMessage) {
|
||||
messageRaw.messageType = 'documentMessage';
|
||||
messageRaw.message.documentMessage = messageRaw.message.documentWithCaptionMessage.message.documentMessage;
|
||||
delete messageRaw.message.documentWithCaptionMessage;
|
||||
}
|
||||
|
||||
return messageRaw;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user