Skip to content

send: keep the edited content's type for newsletter edits (fixes media caption edits in channels, error 479) - #4

Open
freedomcomedelivery wants to merge 1 commit into
devlikeapro:mainfrom
freedomcomedelivery:newsletter-edit-type
Open

freedomcomedelivery wants to merge 1 commit into
devlikeapro:mainfrom
freedomcomedelivery:newsletter-edit-type

Conversation

@freedomcomedelivery

Copy link
Copy Markdown

Summary

Editing the caption of an image/video/document message in a newsletter (channel) fails with server returned error 479, while editing a text message in the same newsletter works. This is the root cause behind devlikeapro/waha#1852 ("[GOWS] - Edit message with image not working in Channels") and the same symptom as tulir/whatsmeow discussion tulir#697.

Root cause

In sendNewsletter() the node type attribute is computed from the outer EditedMessage wrapper before the edited content is unwrapped into the <plaintext> node. getTypeFromMessage() has no case for EditedMessage, so the wrapper falls through to "text". A media caption edit therefore goes out as

<message to=... type="text" edit="3">
  <plaintext mediatype="image">…ImageMessage{caption: …}…</plaintext>
</message>

whereas the original media send is type="media". In 1:1 chats and groups this mismatch is invisible (the content is encrypted), but a newsletter message is plaintext and the server rejects the mismatch with 479.

Fix

Recompute attrs["type"] from the unwrapped edited content. Text edits are unaffected (their type is "text" either way); media caption edits now go out as type="media", exactly like the original send.

What was tried and did not help

Before finding the cause I checked the two obvious suspects, both still returned 479:

  • sending the edited ImageMessage/VideoMessage with the full media reference of the original (URL, directPath, fileSha256, fileLength, …) instead of caption + contextInfo only;
  • re-uploading the media with UploadNewsletter and passing the new handle as SendRequestExtra.MediaHandle (media_id attribute), as suggested in discussion Editing Newsletter Caption (ImageMessage) returns 479 tulir/whatsmeow#697.

Neither is needed. With this change the caption-only edited message (as built by WAHA/GOWS today) is accepted.

Testing

Built GOWS (gows-plus @ 120a614, the commit behind the WAHA 2026.9.2 image) against this fork at the pinned commit plus this patch, and ran it as the engine of WAHA 2026.9.2 (devlikeapro/waha:gows-2026.9.2) with a real WhatsApp account that is an admin of a newsletter:

  • PUT /api/{session}/chats/{chatId}/messages/{id} on an image message → 200, the new caption is shown in the channel on the phone;
  • the same on a video message → 200, the new caption is shown;
  • the same on a text message → 200 (regression check);
  • a second edit of the same image message → 200.

Without the patch every media edit above fails with 2 UNKNOWN: server returned error 479.

Notes

  • The same code exists in upstream tulir/whatsmeow (send.go, sendNewsletter); I have the identical change ready for an upstream PR.
  • gofmt, go build ./... and go vet are clean.

sendNewsletter computes the node "type" attribute from the outer
EditedMessage wrapper, which getTypeFromMessage maps to "text", and only
then unwraps the edited content into the <plaintext> node. A caption edit
of an image/video/document in a newsletter therefore goes out as
type="text" with mediatype="image" (etc.) inside, and the server rejects
it with "server returned error 479". Text edits are unaffected because
their type is "text" anyway.

Recompute the type after unwrapping, so a media caption edit is sent as
type="media" exactly like the original send. Verified through WAHA/GOWS
against a real newsletter: image, video and text edits are accepted and
rendered, and no media handle or re-upload is needed for that.

Fixes devlikeapro/waha#1852.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant