Skip to content

Edit da mensagem está vindo com fromMe: true - v2.2.3 #1367

Closed

Description

@rafwell

Welcome!

  • Yes, I have searched for similar issues on GitHub and found none.

What did you do?

Quando o usuário edita a mensagem existe um evento messages.edited. Neste evento está sendo enviado sempre o campo fromMe como true e o remoteJid como o número da instância, mesmo que quem está editando seja a pessoa que está conversando com a instância.

What did you expect?

O correto seria que viesse com fromMe: false e o remoteJid como o número que editou a mensagem (remetente)

What did you observe instead of what you expected?

Está vindo sempre true e como remoteJid errado

Screenshots/Videos

No response

Which version of the API are you using?

2.2.3

What is your environment?

Windows

Other environment specifications

No response

If applicable, paste the log output

No response

Additional Notes

Aqui está um exemplo do payload que recebo do webhook. Eu enviei um 'oi' para o número da minha conectado na minha instancia, e depois editei para um olá.

estou trocando o número só por questão de privacidade. Considere que 553111111111 é o número que está conectado no evolution, porém quem editou o a mensagem foi outro número.

{
"event": "messages.edited",
"instance": "minhainstancia",
"data": {
"key": {
"remoteJid": "553111111111@s.whatsapp.net",
"fromMe": true,
"id": "3EB05FDBEDF8249B8FDA29"
},
"type": "MESSAGE_EDIT",
"editedMessage": {
"conversation": "teste!",
"messageContextInfo": {
"messageSecret": "Hu6B5lHfVJtwDBEys/yhuGQ9axbA2WtbcXPgSDwbmBg="
}
},
"timestampMs": "1744233908513"
},
"destination": "https://minhainstancia/conexoes/evolution-webhook",
"date_time": "2025-04-09T18:25:09.121Z",
"sender": "553111111111@s.whatsapp.net",
"server_url": "https://evo.minhainstancia.com.br",
"apikey": "C06A8447-DEF9-469B-AAC9-EA084A2E3DA1"
}

Activity

  1. AlanCWB commented on Apr 10, 2025

    @AlanCWB

    O webhook de alteração de mensagem está gerando este erro nos LOGs. A chamada é realizada, porém falta a informação do texto da mensagem, pois o bloco editedMessage não está sendo gerado.

    evolution_api | [Evolution API] v2.2.3 169 - Thu Apr 10 2025 19:20:15 ERROR [unhandledRejection] [object]
    evolution_api | {
    evolution_api | origin: Promise {
    evolution_api | PrismaClientValidationError:
    evolution_api | Invalid this.cache.delete() invocation in
    evolution_api | /evolution/dist/main.js:230:29721
    evolution_api |
    evolution_api | 227 ),o.url&&(n+=URL:${o.url}
    evolution_api | 228 ),o.wuid||(o.wuid=Y(o.phoneNumber)),n+=item1.TEL;waid=${o.wuid}:${o.phoneNumber}
    evolution_api | 229 item1.X-ABLabel:Celular
    evolution_api | → 230 END:VCARD,n};return e.contact.length===1?t.contact={displayName:e.contact[0].fullName,vcard:s(e.contact[0])}:t.contactsArrayMessage={displayName:${e.contact.length} contacts,contacts:e.contact.map(o=>({displayName:o.fullName,vcard:s(o)}))},await this.sendMessageWithTyping(e.number,{contacts:e.contact.map(o=>({name:{formatted_name:o.fullName,first_name:o.fullName},phones:[{phone:o.phoneNumber}],urls:[{url:o.url}],emails:[{email:o.email}],org:{company:o.organization}})),message:t},{delay:e?.delay,presence:"composing",quoted:e?.quoted,linkPreview:e?.linkPreview,mentionsEveryOne:e?.mentionsEveryOne,mentioned:e?.mentioned})}async reactionMessage(e){return await this.sendMessageWithTyping(e.key.remoteJid,{reactionMessage:{key:e.key,text:e.reaction}})}async getBase64FromMediaMessage(e){try{let t=e.message,s=t.messageType.includes("Message")?t.messageType:t.messageType+"Message",o=t.message[s];return{mediaType:t.messageType,fileName:o?.fileName,caption:o?.caption,size:{fileLength:o?.fileLength,height:o?.fileLength,width:o?.width},mimetype:o?.mime_type,base64:t.message.base64}}catch(t){throw this.logger.error(t),new f(t.toString())}}async deleteMessage(){throw new f("Method not available on WhatsApp Business API")}async mediaSticker(){throw new f("Method not available on WhatsApp Business API")}async pollMessage(){throw new f("Method not available on WhatsApp Business API")}async statusMessage(){throw new f("Method not available on WhatsApp Business API")}async reloadConnection(){throw new f("Method not available on WhatsApp Business API")}async whatsappNumber(){throw new f("Method not available on WhatsApp Business API")}async markMessageAsRead(){throw new f("Method not available on WhatsApp Business API")}async archiveChat(){throw new f("Method not available on WhatsApp Business API")}async markChatUnread(){throw new f("Method not available on WhatsApp Business API")}async fetchProfile(){throw new f("Method not available on WhatsApp Business API")}async offerCall(){throw new f("Method not available on WhatsApp Business API")}async sendPresence(){throw new f("Method not available on WhatsApp Business API")}async setPresence(){throw new f("Method not available on WhatsApp Business API")}async fetchPrivacySettings(){throw new f("Method not available on WhatsApp Business API")}async updatePrivacySettings(){throw new f("Method not available on WhatsApp Business API")}async fetchBusinessProfile(){throw new f("Method not available on WhatsApp Business API")}async updateProfileName(){throw new f("Method not available on WhatsApp Business API")}async updateProfileStatus(){throw new f("Method not available on WhatsApp Business API")}async updateProfilePicture(){throw new f("Method not available on WhatsApp Business API")}async removeProfilePicture(){throw new f("Method not available on WhatsApp Business API")}async blockUser(){throw new f("Method not available on WhatsApp Business API")}async updateMessage(){throw new f("Method not available on WhatsApp Business API")}async createGroup(){throw new f("Method not available on WhatsApp Business API")}async updateGroupPicture(){throw new f("Method not available on WhatsApp Business API")}async updateGroupSubject(){throw new f("Method not available on WhatsApp Business API")}async updateGroupDescription(){throw new f("Method not available on WhatsApp Business API")}async findGroup(){throw new f("Method not available on WhatsApp Business API")}async fetchAllGroups(){throw new f("Method not available on WhatsApp Business API")}async inviteCode(){throw new f("Method not available on WhatsApp Business API")}async inviteInfo(){throw new f("Method not available on WhatsApp Business API")}async sendInvite(){throw new f("Method not available on WhatsApp Business API")}async acceptInviteCode(){throw new f("Method not available on WhatsApp Business API")}async revokeInviteCode(){throw new f("Method not available on WhatsApp Business API")}async findParticipants(){throw new f("Method not available on WhatsApp Business API")}async updateGParticipant(){throw new f("Method not available on WhatsApp Business API")}async updateGSetting(){throw new f("Method not available on WhatsApp Business API")}async toggleEphemeral(){throw new f("Method not available on WhatsApp Business API")}async leaveGroup(){throw new f("Method not available on WhatsApp Business API")}async fetchLabels(){throw new f("Method not available on WhatsApp Business API")}async handleLabel(){throw new f("Method not available on WhatsApp Business API")}async receiveMobileCode(){throw new f("Method not available on WhatsApp Business API")}async fakeCall(){throw new f("Method not available on WhatsApp Business API")}};var ct=class{constructor(i,e,t,s){this.jid=i;this.exists=e;this.number=t;this.name=s}},us=class{},ds=class{},Ct=class{};var gs=class{},ms=class{},pt=class{};var hs=class{};var fs=class{},ys=class{},ws=class{},bs=class{};var jn=class{},Ss=class extends jn{},Es=class extends Ss{},Is=class extends Ss{},Ms=class{};var Kn=require("baileys"),Pe=class{constructor(i){this.cache=i;this.logger=new v("CacheService");i?this.logger.verbose(cacheservice created using cache engine: ${i.constructor?.name}):this.logger.verbose("cacheservice disabled")}async get(i){if(this.cache)return this.cache.get(i)}async hGet(i,e){if(!this.cache)return null;try{let t=await this.cache.hGet(i,e);return t?JSON.parse(t,Kn.BufferJSON.reviver):null}catch(t){return this.logger.error(t),null}}async set(i,e,t){this.cache&&this.cache.set(i,e,t)}async hSet(i,e,t){if(this.cache)try{let s=JSON.stringify(t,Kn.BufferJSON.replacer);await this.cache.hSet(i,e,s)}catch(s){this.logger.error(s)}}async has(i){if(this.cache)return this.cache.has(i)}async delete(i){if(this.cache)return this.cache.delete({ evolution_api | data: { evolution_api | messageId: "cm9bx7dit006rpl4ppetd4xiy", evolution_api | keyId: "EBB1xxxxxxxxxxxxxxxxxxxxxxxxxxD5", evolution_api | remoteJid: "559999999991@s.whatsapp.net", evolution_api | fromMe: true, evolution_api | participant: "559999999992@s.whatsapp.net", evolution_api | pollUpdates: undefined, evolution_api | instanceId: "8bb9711x-xxxx-0000-213212-9321321d", evolution_api | + status: String evolution_api | } evolution_api | }) evolution_api | evolution_api | Argument status` is missing.
    evolution_api | at xn (/evolution/node_modules/@prisma/client/runtime/library.js:29:1363)
    evolution_api | at Bn.handleRequestError (/evolution/node_modules/@prisma/client/runtime/library.js:121:7005)
    evolution_api | at Bn.handleAndLogRequestError (/evolution/node_modules/@prisma/client/runtime/library.js:121:6686)
    evolution_api | at Bn.request (/evolution/node_modules/@prisma/client/runtime/library.js:121:6393)
    evolution_api | at async l (/evolution/node_modules/@prisma/client/runtime/library.js:130:9645)
    evolution_api | at async messages.update (/evolution/dist/main.js:230:29679) {
    evolution_api | clientVersion: '6.3.0'
    evolution_api | }
    evolution_api | },
    evolution_api | stderr: 2
    evolution_api | }

  2. w35l3y commented on Jun 1, 2025

    @w35l3y

    Na verdade, esse problema ocorreu porque a mensagem editada está chegando sem "status".

    Argument `status` is missing.
    

    Se isso é esperado ou não, eu ainda não descobri.
    Como o campo "status" é obrigatório no banco, aí está dando esse problema.

    Ainda estou me familiarizando com o projeto, mas resolvi localmente assim:

    const message: any = {
      messageId: findMessage.id,
      keyId: key.id,
      remoteJid: key.remoteJid,
      fromMe: key.fromMe,
      participant: key?.remoteJid,
    //status: status[update.status], // <--- retirei esta linha
      status: status[update.status] || findMessage.status,  // <--- acrescentei esta linha
      instanceId: this.instanceId,
    };
    

    whatsapp.baileys.service.ts

    Ainda estou em dúvida se o certo seria colocar o status anterior da mensagem (findMessage.status) ou se deveria colocar algum valor fixo (status[3], talvez ?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions