}
for _, message := range queue.Pending {
- if message.Target == agent.config.Name {
+ if (message.Notification && message.TargetID != "" && message.TargetID == agent.config.ID) || (message.TargetID == "" && message.Target == agent.config.Name) {
return fmt.Errorf("import refused: agent %q has pending deliveries", agent.config.Name)
}
}
return names, owner, nil
}
-// whatsappImportName adds an exact match unless distinct IDs share its name.
-func whatsappImportName(names map[string]WhatsAppChat, chat WhatsAppChat) {
- old, found := names[chat.Name]
- if found && old.ID != chat.ID {
- chat.ID = ""
- }
-
- names[chat.Name] = chat
-}
-
// whatsappImportPlan filters each chat at its earliest live message across the
// target and root logs. Only imported days in the target are skipped. Each
// remaining chat-day becomes a work message dated at its last exported message.
return plan, nil
}
+// whatsappImportName adds an exact match unless distinct IDs share its name.
+func whatsappImportName(names map[string]WhatsAppChat, chat WhatsAppChat) {
+ old, found := names[chat.Name]
+ if found && old.ID != chat.ID {
+ chat.ID = ""
+ }
+
+ names[chat.Name] = chat
+}
+
// whatsappImportHistory reads batch names and live cutoffs from both logs.
// Imported chat-days belong only to the target log, which is first.
func whatsappImportHistory(target, root []DatedMessage, names map[string]WhatsAppChat, cutoffs map[string]time.Time, location *time.Location) (map[string]bool, error) {