Korjaa ticket_fetch ja sähköpostien duplikaattiongelma
- Korjaa implode()-bugi: $email['to'] on string, ei array - Lisää fetched_message_ids-taulu joka estää poistettujen tikettien uudelleenluonnin seuraavassa haussa - Viestit haetaan postilaatikosta vain kertaalleen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
api.php
13
api.php
@@ -2906,8 +2906,9 @@ switch ($action) {
|
||||
$threadedCount = 0;
|
||||
$errors = [];
|
||||
|
||||
// Collect all existing message IDs for duplicate detection
|
||||
$existingMsgIds = [];
|
||||
// Collect all previously fetched message IDs (persists even after ticket deletion)
|
||||
$existingMsgIds = dbGetFetchedMessageIds($companyId);
|
||||
// Also include message IDs from current tickets (for backward compatibility)
|
||||
foreach ($tickets as $t) {
|
||||
if ($t['message_id']) $existingMsgIds[$t['message_id']] = true;
|
||||
foreach ($t['messages'] ?? [] as $m) {
|
||||
@@ -3016,7 +3017,7 @@ switch ($action) {
|
||||
];
|
||||
|
||||
// Apply auto-rules
|
||||
$toAddresses = implode(' ', $email['to'] ?? []);
|
||||
$toAddresses = $email['to'] ?? '';
|
||||
foreach ($rules as $rule) {
|
||||
if (empty($rule['enabled'])) continue;
|
||||
$match = true;
|
||||
@@ -3094,7 +3095,11 @@ switch ($action) {
|
||||
$newCount++;
|
||||
}
|
||||
|
||||
if ($email['message_id']) $existingMsgIds[$email['message_id']] = true;
|
||||
// Merkitse haetuksi pysyvästi
|
||||
if ($email['message_id']) {
|
||||
dbMarkMessageIdFetched($companyId, $email['message_id']);
|
||||
$existingMsgIds[$email['message_id']] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user