fix(whatsmeow): Archive event panics before reaching the webhook

The Archive case asserts postMap["data"] to map[string]interface{}, but at that
point it still holds the raw *events.Archive. The assertion panics on every
archive event:

    Event handler panicked while handling a *events.Archive:
    interface conversion: interface {} is *events.Archive,
    not map[string]interface {}

whatsmeow recovers the panic and logs it, so nothing crashes — the event simply
never reaches the webhook, silently.

Every other case in this switch marshals and unmarshals postMap["data"] into a
map before asserting. Archive was the only one missing that step. Six call sites
do the assertion; the other five are already guarded.

(cherry picked from commit 16c4be6e9a0ae8a0bbc41f8b2790a362a7a4e2e2)
This commit is contained in:
EcoosUP authored and Jorge Fernando dos Santos committed 2026-11-09 12:00:59 -03:00
1 parent 87a354aee8
commit 3cc5192b7b
1 file changed
+21
+21
View File
@@ -1821,6 +1821,27 @@ func (mycli *MyClient) myEventHandler(rawEvt interface{}) {
doWebhook = true doWebhook = true
postMap["event"] = "Archive" postMap["event"] = "Archive"
// postMap["data"] still holds the raw event at this point, so the type
// assertion below panicked on every Archive event. Same marshal/unmarshal
// step every other case in this switch already does.
if postMap["data"] != nil {
jsonBytes, err := json.Marshal(postMap["data"])
if err != nil {
mycli.loggerWrapper.GetLogger(mycli.userID).LogError("[%s] Failed to marshal postMap['data']: %v", mycli.userID, err)
return
}
var parsed map[string]interface{}
if err := json.Unmarshal(jsonBytes, &parsed); err != nil {
mycli.loggerWrapper.GetLogger(mycli.userID).LogError("[%s] Failed to unmarshal postMap['data'] to map[string]interface{}: %v", mycli.userID, err)
return
}
postMap["data"] = parsed
} else {
postMap["data"] = make(map[string]interface{})
}
dataMap := postMap["data"].(map[string]interface{}) dataMap := postMap["data"].(map[string]interface{})
dataMap["JID"] = evt.JID dataMap["JID"] = evt.JID
dataMap["Timestamp"] = evt.Timestamp dataMap["Timestamp"] = evt.Timestamp