Automaattisäännöt: vastaanottaja-ehto, prioriteetti, abuse-tyyppi
- Lisää "Vastaanottaja sisältää" -ehto (to_contains) sääntöihin - Lisää "Aseta prioriteetti" -toimenpide (set_priority) - Lisää "Abuse" tikettityyppi - Korjaa DB-schema: subject_contains, to_contains, enabled, set_priority, set_tags sarakkeet - Parsii To-headerit sähköposteista säännön matchausta varten - Mahdollistaa esim. abuse@-postien automaattisen tyypityksen ja prioriteetin Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
15
api.php
15
api.php
@@ -368,6 +368,10 @@ class ImapClient {
|
||||
$date = $dateStr ? @date('Y-m-d H:i:s', strtotime($dateStr)) : date('Y-m-d H:i:s');
|
||||
if (!$date) $date = date('Y-m-d H:i:s');
|
||||
|
||||
// Parse To
|
||||
$toRaw = $this->decodeMimeHeader($headers['to'] ?? '');
|
||||
$toEmails = $this->parseCcAddresses($toRaw);
|
||||
|
||||
// Parse CC
|
||||
$ccRaw = $this->decodeMimeHeader($headers['cc'] ?? '');
|
||||
$ccEmails = $this->parseCcAddresses($ccRaw);
|
||||
@@ -379,6 +383,7 @@ class ImapClient {
|
||||
'subject' => $subject,
|
||||
'from_email' => $fromParsed['email'],
|
||||
'from_name' => $this->decodeMimeHeader($fromParsed['name']),
|
||||
'to' => $toEmails,
|
||||
'message_id' => $messageId,
|
||||
'in_reply_to' => $inReplyTo,
|
||||
'references' => $references,
|
||||
@@ -3011,6 +3016,7 @@ switch ($action) {
|
||||
];
|
||||
|
||||
// Apply auto-rules
|
||||
$toAddresses = implode(' ', $email['to'] ?? []);
|
||||
foreach ($rules as $rule) {
|
||||
if (empty($rule['enabled'])) continue;
|
||||
$match = true;
|
||||
@@ -3026,9 +3032,16 @@ switch ($action) {
|
||||
$match = false;
|
||||
}
|
||||
}
|
||||
if (!empty($rule['to_contains'])) {
|
||||
$needle = strtolower($rule['to_contains']);
|
||||
if (strpos(strtolower($toAddresses), $needle) === false) {
|
||||
$match = false;
|
||||
}
|
||||
}
|
||||
if ($match) {
|
||||
if (!empty($rule['set_status'])) $ticket['status'] = $rule['set_status'];
|
||||
if (!empty($rule['set_type'])) $ticket['type'] = $rule['set_type'];
|
||||
if (!empty($rule['set_priority'])) $ticket['priority'] = $rule['set_priority'];
|
||||
if (!empty($rule['set_tags'])) {
|
||||
$ruleTags = array_map('trim', explode(',', $rule['set_tags']));
|
||||
$ticket['tags'] = array_values(array_unique(array_merge($ticket['tags'], $ruleTags)));
|
||||
@@ -3426,8 +3439,10 @@ switch ($action) {
|
||||
'name' => trim($input['name'] ?? ''),
|
||||
'from_contains' => trim($input['from_contains'] ?? ''),
|
||||
'subject_contains' => trim($input['subject_contains'] ?? ''),
|
||||
'to_contains' => trim($input['to_contains'] ?? ''),
|
||||
'set_status' => $input['set_status'] ?? '',
|
||||
'set_type' => $input['set_type'] ?? '',
|
||||
'set_priority' => $input['set_priority'] ?? '',
|
||||
'set_tags' => trim($input['set_tags'] ?? ''),
|
||||
'auto_close_days' => intval($input['auto_close_days'] ?? 0),
|
||||
'enabled' => $input['enabled'] ?? true,
|
||||
|
||||
Reference in New Issue
Block a user