Skip to content

Commit

Permalink
feat: support multiple number document in FetchEmailCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
keenthekeen committed Jun 2, 2024
1 parent 299a539 commit 3c4f1f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Console/Commands/FetchEmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public function handle(): void
$this->line('- Processing message '.$subject);
$subject = str_replace(['Copy of ', 'สำเนา '], '', $subject);
$list = [];
if (preg_match('/(?:สพจ|SMCU)(?:\.|\s|-){1,2}(\d+)(?:_|-|\/)(25\d\d)(?:\s|-).+/i', $subject, $list, PREG_UNMATCHED_AS_NULL)) {
// Regex pattern for document title; e.g.
// SMCU 623-624_2567 ขอความอนุเคราะห์ใช้สถานที่.pdf OR
// สพจ. 623-2567 ขอความอนุเคราะห์ใช้สถานที่.pdf
if (preg_match('/(?:สพจ|SMCU)(?:\.|\s|-){1,2}(\d+)(?:_|-|\/)(?:\d+(?:_|-|\/))?(25\d\d)(?:\s|-).+/i', $subject, $list,
PREG_UNMATCHED_AS_NULL)) {
$document = Document::where('number', $list[1])->where('year', $list[2])->first();
if ($document) {
$this->line('-- Found update of document '.$document->id.' ('.$document->number.'/'.$document->year.') '.$document->title);
Expand Down

0 comments on commit 3c4f1f7

Please sign in to comment.