Skip to content

Commit

Permalink
fixup! feat: delete tags
Browse files Browse the repository at this point in the history
Signed-off-by: hamza221 <[email protected]>
  • Loading branch information
hamza221 committed Nov 6, 2023
1 parent 1a95848 commit a796a2b
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/Service/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,16 @@ public function tagMessageWithClient(Horde_Imap_Client_Socket $client, Account $
$e
);
}
if ($value) {
foreach ($messages as $message) {
$this->tagMapper->tagMessage($tag, $message->getMessageId(), $account->getUserId());
}
} else {
foreach ($messages as $message) {
$this->tagMapper->untagMessage($tag, $message->getMessageId());
if ($value) {
foreach ($messages as $message) {
$this->tagMapper->tagMessage($tag, $message->getMessageId(), $account->getUserId());
}
} else {
foreach ($messages as $message) {
$this->tagMapper->untagMessage($tag, $message->getMessageId());
}
}
}
}
}
/**
* Tag (flag) a message on IMAP
Expand Down Expand Up @@ -873,7 +873,7 @@ public function deleteTagForAccount(int $id, string $userId, Tag $tag, Account $
$messageTags = $this->messageTagsMapper->getMessagesByTag($id);
$messages = array_merge(... array_map(function ($messageTag) use ($account) {
return $this->getByMessageId($account, $messageTag->getImapMessageId());
}, [...$messageTags]));
},array_values($messageTags)));
} catch (DoesNotExistException $e) {
throw new ClientException('Messages not found', 0, $e);
}
Expand All @@ -892,12 +892,15 @@ public function deleteTagForAccount(int $id, string $userId, Tag $tag, Account $
$groupedMessages[$mailboxId] = [$message];
}
}

foreach ($groupedMessages as $mailboxId => $messages) {
$mailbox = $this->getMailbox($userId, $mailboxId);
$this->tagMessageWithClient($client, $account, $mailbox, $messages, $tag, false);
try {
foreach ($groupedMessages as $mailboxId => $messages) {
$mailbox = $this->getMailbox($userId, $mailboxId);
$this->tagMessageWithClient($client, $account, $mailbox, $messages, $tag, false);
}
} finally {
$client->logout();
}
$client->logout();

}
public function moveThread(Account $srcAccount, Mailbox $srcMailbox, Account $dstAccount, Mailbox $dstMailbox, string $threadRootId): array {
$mailAccount = $srcAccount->getMailAccount();
Expand Down

0 comments on commit a796a2b

Please sign in to comment.