Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

fix(chatwoot): drop redundant WhatsApp message id from reaction notes (#795)

Claudio Oliveirab8043af04732
diff --git a/src/infrastructure/whatsapp/chatwoot_forward_test.go b/src/infrastructure/whatsapp/chatwoot_forward_test.go
index bb083391..851a8636 100644
--- a/src/infrastructure/whatsapp/chatwoot_forward_test.go
+++ b/src/infrastructure/whatsapp/chatwoot_forward_test.go
@@ -389,13 +389,17 @@ func TestBuildReactionChatwootContent(t *testing.T) {
expected string
}{
{
+ // The target id is not repeated in the text: when reacted_message_id
+ // is present, syncPayloadToChatwoot already threads this note onto
+ // the reacted-to message via in_reply_to_external_id, so Chatwoot
+ // nests it under that message's bubble.
name: "reaction with sender name and target id",
payload: map[string]any{
"reaction": "πŸ‘",
"reacted_message_id": "wamid-123",
},
fromName: "Alice",
- expected: "Alice reacted πŸ‘ to message wamid-123",
+ expected: "Alice reacted πŸ‘",
},
{
name: "reaction falls back to phone",
@@ -405,7 +409,7 @@ func TestBuildReactionChatwootContent(t *testing.T) {
"from": "[email protected]",
},
fromName: "",
- expected: "628123456789 reacted πŸ”₯ to message wamid-456",
+ expected: "628123456789 reacted πŸ”₯",
},
{
name: "reaction removal",
@@ -414,7 +418,7 @@ func TestBuildReactionChatwootContent(t *testing.T) {
"reacted_message_id": "wamid-789",
},
fromName: "Bob",
- expected: "Bob removed a reaction from message wamid-789",
+ expected: "Bob removed a reaction",
},
{
name: "reaction falls back to sender jid when pushname missing",
@@ -424,7 +428,7 @@ func TestBuildReactionChatwootContent(t *testing.T) {
"from": "[email protected]",
},
fromName: "",
- expected: "628777000111 reacted πŸ˜‚ to message wamid-999",
+ expected: "628777000111 reacted πŸ˜‚",
},
{
name: "missing target id still produces readable text",
diff --git a/src/infrastructure/whatsapp/webhook_forward.go b/src/infrastructure/whatsapp/webhook_forward.go
index 53b3678f..e5d5a44c 100644
--- a/src/infrastructure/whatsapp/webhook_forward.go
+++ b/src/infrastructure/whatsapp/webhook_forward.go
@@ -601,9 +601,15 @@ func isEventWhitelistedForChatwoot(eventName string) bool {
return false
}
+// buildReactionChatwootContent renders the note posted for a reaction event.
+// It never mentions the WhatsApp message id: whenever reacted_message_id is
+// present, syncPayloadToChatwoot already threads this note onto the
+// reacted-to message via ContentAttributes.in_reply_to_external_id, so
+// Chatwoot nests it under that message's bubble - repeating the raw id in
+// the text would just be noise. When reacted_message_id is absent the note
+// is posted standalone, un-threaded, but still readable.
func buildReactionChatwootContent(data map[string]any, fromName string) string {
reaction, _ := data["reaction"].(string)
- reactedMessageID, _ := data["reacted_message_id"].(string)
actor := "Someone"
if fromName != "" {
@@ -612,13 +618,6 @@ func buildReactionChatwootContent(data map[string]any, fromName string) string {
actor = utils.ExtractPhoneFromJID(from)
}
- if reactedMessageID != "" {
- if reaction == "" {
- return fmt.Sprintf("%s removed a reaction from message %s", actor, reactedMessageID)
- }
- return fmt.Sprintf("%s reacted %s to message %s", actor, reaction, reactedMessageID)
- }
-
if reaction == "" {
return fmt.Sprintf("%s removed a reaction", actor)
}