generated from Nodarx/template
refactor: CommandStatusResult
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -220,11 +220,7 @@ class RemoteMailService
|
||||
*/
|
||||
public function collectionCreate(string $name): Mailbox
|
||||
{
|
||||
$result = $this->imapClient()->perform(new CreateCommand($name));
|
||||
|
||||
if (!$result->isOk()) {
|
||||
throw new ImapException('Failed to create mailbox: ' . $name);
|
||||
}
|
||||
$this->imapClient()->perform(new CreateCommand($name));
|
||||
|
||||
// Attempt to refetch the new mailbox from the server
|
||||
$mailbox = $this->collectionFetch($name);
|
||||
@@ -240,11 +236,7 @@ class RemoteMailService
|
||||
*/
|
||||
public function collectionRename(string $oldName, string $newName): Mailbox
|
||||
{
|
||||
$result = $this->imapClient()->perform(new RenameCommand($oldName, $newName));
|
||||
|
||||
if (!$result->isOk()) {
|
||||
throw new ImapException('Failed to rename mailbox: ' . $oldName . ' to ' . $newName);
|
||||
}
|
||||
$this->imapClient()->perform(new RenameCommand($oldName, $newName));
|
||||
|
||||
$mailbox = $this->collectionFetch($newName);
|
||||
|
||||
@@ -260,11 +252,7 @@ class RemoteMailService
|
||||
*/
|
||||
public function collectionDestroy(string $name): bool
|
||||
{
|
||||
$result = $this->imapClient()->perform(new DeleteCommand($name));
|
||||
|
||||
if (!$result->isOk()) {
|
||||
throw new ImapException('Failed to delete mailbox: ' . $name);
|
||||
}
|
||||
$this->imapClient()->perform(new DeleteCommand($name));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -617,20 +605,14 @@ class RemoteMailService
|
||||
MessageTarget::uid(SequenceSet::items(...array_values($uids))),
|
||||
$targetCollection,
|
||||
));
|
||||
if ($response->isOk()) {
|
||||
$this->imapClient()->perform(new StoreCommand(
|
||||
MessageTarget::uid(SequenceSet::items(...array_values($uids))),
|
||||
['\\Deleted'],
|
||||
'+',
|
||||
));
|
||||
$this->imapClient()->perform(new ExpungeCommand(
|
||||
MessageTarget::uid(SequenceSet::items(...array_values($uids))),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$response->isOk()) {
|
||||
throw new ImapException('Failed to move messages: ' . implode(', ', $response->responseCodes()));
|
||||
$this->imapClient()->perform(new StoreCommand(
|
||||
MessageTarget::uid(SequenceSet::items(...array_values($uids))),
|
||||
['\\Deleted'],
|
||||
'+',
|
||||
));
|
||||
$this->imapClient()->perform(new ExpungeCommand(
|
||||
MessageTarget::uid(SequenceSet::items(...array_values($uids))),
|
||||
));
|
||||
}
|
||||
|
||||
// construct operation result as a map of source UID to boolean or destination UID, depending on server support
|
||||
@@ -660,10 +642,6 @@ class RemoteMailService
|
||||
$targetCollection,
|
||||
));
|
||||
|
||||
if (!$response->isOk()) {
|
||||
throw new ImapException('Failed to copy messages: ' . implode(', ', $response->responseCodes()));
|
||||
}
|
||||
|
||||
// construct operation result as a map of source UID to boolean or destination UID, depending on server support
|
||||
$map = $response->copyUidMap();
|
||||
if ($map === []) {
|
||||
|
||||
Reference in New Issue
Block a user