From 7f649d67d9c90d19a4ebf47e6237353453ff1bce Mon Sep 17 00:00:00 2001 From: walterdiazesa Date: Fri, 26 Jun 2026 21:16:58 -0600 Subject: [PATCH] feat(events): forward Picture, UserAbout and BusinessName webhook events The dispatcher in pkg/whatsmeow/service/whatsmeow.go dropped three events emitted by go.mau.fi/whatsmeow because the central switch had no case for them, logging "Unhandled event" instead of forwarding them: - events.Picture: a user's profile picture or a group's photo changes (JID, Author, Timestamp, Remove, PictureID). - events.UserAbout: a user's about/status text changes (JID, Status, Timestamp). - events.BusinessName: a contact's verified business name changes (JID, OldBusinessName, NewBusinessName). Add the three handler cases in myEventHandler, the matching branches in CallWebhook, and the PICTURE, USER_ABOUT and BUSINESS_NAME subscription categories in pkg/internal/event_types so IsEventType accepts them. The change is additive: existing subscribers are unaffected, and the new events require opting in via the subscribe list (or ALL). --- pkg/internal/event_types/event_types.go | 9 +++++++++ pkg/whatsmeow/service/whatsmeow.go | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/pkg/internal/event_types/event_types.go b/pkg/internal/event_types/event_types.go index 3f7a6325..8c7569aa 100644 --- a/pkg/internal/event_types/event_types.go +++ b/pkg/internal/event_types/event_types.go @@ -16,6 +16,9 @@ const ( NEWSLETTER = "NEWSLETTER" QRCODE = "QRCODE" BUTTON_CLICK = "BUTTON_CLICK" + PICTURE = "PICTURE" + USER_ABOUT = "USER_ABOUT" + BUSINESS_NAME = "BUSINESS_NAME" ) var AllEventTypes = []string{ @@ -33,6 +36,9 @@ var AllEventTypes = []string{ NEWSLETTER, QRCODE, BUTTON_CLICK, + PICTURE, + USER_ABOUT, + BUSINESS_NAME, } var validEventTypes = map[string]bool{ @@ -51,6 +57,9 @@ var validEventTypes = map[string]bool{ NEWSLETTER: true, QRCODE: true, BUTTON_CLICK: true, + PICTURE: true, + USER_ABOUT: true, + BUSINESS_NAME: true, } func IsEventType(eventType string) bool { diff --git a/pkg/whatsmeow/service/whatsmeow.go b/pkg/whatsmeow/service/whatsmeow.go index 78ec6c17..949a69b9 100644 --- a/pkg/whatsmeow/service/whatsmeow.go +++ b/pkg/whatsmeow/service/whatsmeow.go @@ -1898,6 +1898,15 @@ func (mycli *MyClient) myEventHandler(rawEvt interface{}) { case *events.PushName: doWebhook = true postMap["event"] = "PushName" + case *events.Picture: + doWebhook = true + postMap["event"] = "Picture" + case *events.UserAbout: + doWebhook = true + postMap["event"] = "UserAbout" + case *events.BusinessName: + doWebhook = true + postMap["event"] = "BusinessName" case *events.IdentityChange: doWebhook = false case *events.GroupInfo: @@ -2127,6 +2136,21 @@ func (w *whatsmeowService) CallWebhook(instance *instance_model.Instance, queueN w.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Event received of type %s", instance.Id, eventType) w.sendToQueueOrWebhook(instance, queueName, jsonData) } + case "Picture": + if contains(subscriptions, "PICTURE") { + w.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Event received of type %s", instance.Id, eventType) + w.sendToQueueOrWebhook(instance, queueName, jsonData) + } + case "UserAbout": + if contains(subscriptions, "USER_ABOUT") { + w.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Event received of type %s", instance.Id, eventType) + w.sendToQueueOrWebhook(instance, queueName, jsonData) + } + case "BusinessName": + if contains(subscriptions, "BUSINESS_NAME") { + w.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Event received of type %s", instance.Id, eventType) + w.sendToQueueOrWebhook(instance, queueName, jsonData) + } default: return