Skip to content

Commit 06a02b3

Browse files
committed
Events integrated
1 parent 913fbea commit 06a02b3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/IMAP/Message.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
use Carbon\Carbon;
1616
use Illuminate\Support\Str;
17+
use Webklex\IMAP\Events\MessageDeletedEvent;
18+
use Webklex\IMAP\Events\MessageMovedEvent;
19+
use Webklex\IMAP\Events\MessageRestoredEvent;
1720
use Webklex\IMAP\Exceptions\InvalidMessageDateException;
1821
use Webklex\IMAP\Exceptions\MaskNotFoundException;
1922
use Webklex\IMAP\Exceptions\MethodNotFoundException;
@@ -997,7 +1000,9 @@ public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folde
9971000
if($expunge) $this->client->expunge();
9981001
$this->client->openFolder($target_folder->path);
9991002

1000-
return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
1003+
$message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
1004+
MessageMovedEvent::dispatch($this, $message);
1005+
return $message;
10011006
}
10021007

10031008
return null;
@@ -1015,6 +1020,7 @@ public function delete($expunge = true) {
10151020

10161021
$status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
10171022
if($expunge) $this->client->expunge();
1023+
MessageDeletedEvent::dispatch($this);
10181024

10191025
return $status;
10201026
}
@@ -1031,6 +1037,7 @@ public function restore($expunge = true) {
10311037

10321038
$status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
10331039
if($expunge) $this->client->expunge();
1040+
MessageRestoredEvent::dispatch($this);
10341041

10351042
return $status;
10361043
}

0 commit comments

Comments
 (0)