v1.2.0
- E-mail intake (IMAP), optional and off by default: clients can create a ticket or reply to an existing one just by sending/replying to an e-mail. Configure any number of mailboxes in the new Admin > Poczta page (SMTP + IMAP together, replacing the old "E-MAIL" tab), each routed to a specific subcategory or a whole category (new tickets.category_id column). Replies are matched to their ticket via the number/checksum already in every notification subject; autoresponders/bounces are detected and rejected; "restrict tickets to LDAP" is enforced for e-mail like the guest web form. Manual "Pobierz teraz" per-mailbox fetch button; dedicated storage/logs/imap-*.log regardless of the app's log level; mail-icon badges on e-mail-originated tickets/messages in the operator queue and ticket view. - Operator queue: "select all" checkbox in the table header for every currently visible ticket under the active filter/tab. - Fixed: scheduled commands (SLA breach check, automation rules, and now IMAP fetch) always sent notifications through .env's default mailer instead of the configured SMTP server, because AppServiceProvider's Settings override used to skip itself for any console command, not just migrate. - Fixed: visiting a ticket that no longer exists (deleted mid-session, or a stale background refresh) showed a raw 404 instead of redirecting back to the operator queue / client dashboard. - Docs: README/ARCHITECTURE/CLAUDE/install/wiki updated for all of the above, including the previously-missing host crontab entry for schedule:run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
49
src/app/Support/Imap/InboundEmail.php
Normal file
49
src/app/Support/Imap/InboundEmail.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support\Imap;
|
||||
|
||||
/**
|
||||
* Normalized view of one inbound message, independent of the IMAP client
|
||||
* library — the seam between ImapMailboxFetcher (I/O, effectively
|
||||
* untestable without a real mailbox) and ImapMessageClassifier (pure
|
||||
* decision logic, fully Pest-testable against hand-built instances).
|
||||
*/
|
||||
class InboundEmail
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $headers lower-cased header names
|
||||
* @param array<int, array{filename: string, mime: string, content: string}> $attachments
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $fromEmail,
|
||||
public readonly string $fromName,
|
||||
public readonly string $subject,
|
||||
public readonly string $textBody,
|
||||
public readonly string $htmlBody,
|
||||
public readonly array $headers,
|
||||
public readonly array $attachments = [],
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Treats an empty string the same as an absent header — the IMAP
|
||||
* library backing ImapMailboxFetcher represents "header not present" as
|
||||
* an empty value rather than a missing array key in some cases, so
|
||||
* callers checking `header($x) !== null` alone would otherwise
|
||||
* misdetect every message as carrying every header.
|
||||
*/
|
||||
public function header(string $name): ?string
|
||||
{
|
||||
$value = $this->headers[strtolower($name)] ?? null;
|
||||
|
||||
return $value !== null && $value !== '' ? $value : null;
|
||||
}
|
||||
|
||||
public function body(): string
|
||||
{
|
||||
if (trim($this->textBody) !== '') {
|
||||
return $this->textBody;
|
||||
}
|
||||
|
||||
return trim(html_entity_decode(strip_tags($this->htmlBody)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user