Files
itflow/functions/mail_unprocessed_message.php

47 lines
1.6 KiB
PHP

<?php
/*
* An email kept for agents to sort (functions/mail_unprocessed.php), taken by the email parser from its copy when an
* agent asks - as ImapEngine reads it, with what the parser does to a mailbox's email done to its row instead: moved
* (taken) is sorted, with the ticket it went on ($ticket_id). Required by cron/ticket_email_parser.php after ImapEngine.
*/
use DirectoryTree\ImapEngine\FileMessage;
class MailUnprocessedMessage extends FileMessage {
public array $row;
public int $ticket_id = 0;
public function __construct(array $row, $mime) {
parent::__construct((string) $mime);
$this->row = $row;
}
/* What the agent asked for - ticket, reply or retry */
public function asked(): string {
return (string) $this->row['email_unprocessed_action'];
}
/* Its row's id, for the logs as a mailbox email's UID is */
public function uid(): int {
return intval($this->row['email_unprocessed_id']);
}
/* The raw body (all after the headers) - the parser's last resort for an email with no text or HTML part */
public function body(): string {
$parts = preg_split("/\r?\n\r?\n/", $this->contents, 2);
return $parts[1] ?? '';
}
/* Read, flagged - nothing to mark: it is in no mailbox */
public function flag(BackedEnum|string $flag, string $operation, bool $expunge = false): void {
}
/* Taken - sorted, on the ticket it went on */
public function move(string $folder, bool $expunge = false): ?int {
mailUnprocessedDone($this->uid(), $this->ticket_id);
return null;
}
}