Skip to content

/message/edit endpoint silently fails - uses Conversation instead of ExtendedTextMessage #16

@brunobeise

Description

@brunobeise

Title:

/message/edit endpoint silently fails - uses Conversation instead of ExtendedTextMessage

Body:

Bug Description

The POST /message/edit endpoint returns "message": "success" but the message is never actually edited on WhatsApp. The edit is silently ignored.

Root Cause

In pkg/message/service/message_service.go, the EditMessage method builds the edit payload using Conversation:

client.BuildEdit(
    recipient,
    data.MessageID,
    &waE2E.Message{
        Conversation: proto.String(data.Message),  // <-- bug
    })

However, in pkg/sendMessage/service/send_service.go, the SendText method sends messages using ExtendedTextMessage:

msg := &waE2E.Message{
    ExtendedTextMessage: &waE2E.ExtendedTextMessage{
        Text: &data.Text,
    },
}

Since the original message was sent as ExtendedTextMessage, WhatsApp silently rejects the edit because the message type doesn't match. The WhatsApp protocol requires the edited message to use the same type as the original.

Fix

In pkg/message/service/message_service.go, line ~416, change:

// Before (broken)
&waE2E.Message{
    Conversation: proto.String(data.Message),
}

// After (working)
&waE2E.Message{
    ExtendedTextMessage: &waE2E.ExtendedTextMessage{
        Text: &data.Message,
    },
}

Additional issue

The EditMessage method also has an uninitialized ts variable:

var ts time.Time  // never assigned, returns "0001-01-01 00:00:00 +0000 UTC"

This same pattern appears in several other methods (ChatPresence, MarkRead, DeleteMessageEveryone, etc).

How to Reproduce

  1. Send a text message using POST /send/text
  2. Try to edit it using POST /message/edit with the returned messageId
  3. Response shows "message": "success" but the message is NOT edited on WhatsApp
  4. The response also returns a different messageId (the edit envelope ID) and a zeroed timestamp

Response example

{
  "data": {
    "messageId": "3EB028A10887FFA044B3CA",    // different from original
    "timestamp": "0001-01-01 00:00:00 +0000 UTC"  // zero value
  },
  "message": "success"
}

Environment

  • Evolution Go version: 0.6.1-beta
  • Docker image: evoapicloud/evolution-go:latest

Labels (if available)

bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions