-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
- Loading branch information
1 parent
f34ba63
commit 93bc496
Showing
9 changed files
with
294 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace OCA\Mail\Events; | ||
|
||
use OCA\Mail\Account; | ||
use OCP\EventDispatcher\Event; | ||
|
||
class SynchronizationEvent extends Event { | ||
|
||
/** @var Account */ | ||
private $account; | ||
|
||
public function __construct(Account $account) { | ||
parent::__construct(); | ||
|
||
$this->account = $account; | ||
} | ||
|
||
public function getAccount(): Account { | ||
return $this->account; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace OCA\Mail\IMAP\Threading; | ||
|
||
use Horde_Mail_Rfc822_Identification; | ||
use function json_decode; | ||
|
||
class DatabaseMessage extends Message { | ||
|
||
/** @var int */ | ||
private $databaseId; | ||
|
||
/** @var string|null */ | ||
private $threadRootId; | ||
|
||
/** @var bool */ | ||
private $dirty = false; | ||
|
||
public function __construct(int $databaseId, | ||
string $subject, | ||
string $id, | ||
array $references, | ||
?string $threadRootId) { | ||
parent::__construct($subject, $id, $references); | ||
|
||
$this->databaseId = $databaseId; | ||
$this->threadRootId = $threadRootId; | ||
} | ||
|
||
public static function fromRowData(int $id, | ||
string $subject, | ||
?string $messageId, | ||
?string $references, | ||
?string $inReplyTo, | ||
?string $threadRootId): self { | ||
$referencesForThreading = $references !== null ? json_decode($references, true) : []; | ||
if (!empty($inReplyTo)) { | ||
$referencesForThreading[] = $inReplyTo; | ||
} | ||
|
||
return new self( | ||
$id, | ||
$subject, | ||
$messageId, | ||
$referencesForThreading, | ||
$threadRootId | ||
); | ||
} | ||
|
||
public function getDatabaseId(): int { | ||
return $this->databaseId; | ||
} | ||
|
||
public function getThreadRootId(): ?string { | ||
return $this->threadRootId; | ||
} | ||
|
||
public function setThreadRootId(?string $threadRootId): void { | ||
$this->threadRootId = $threadRootId; | ||
$this->dirty = true; | ||
} | ||
|
||
public function isDirty(): bool { | ||
return $this->dirty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace OCA\Mail\Listener; | ||
|
||
use OCA\Mail\Db\MessageMapper; | ||
use OCA\Mail\Events\SynchronizationEvent; | ||
use OCA\Mail\IMAP\Threading\ThreadBuilder; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
|
||
class AccountSynchronizedThreadUpdaterListener implements IEventListener { | ||
|
||
/** @var MessageMapper */ | ||
private $mapper; | ||
|
||
/** @var ThreadBuilder */ | ||
private $builder; | ||
|
||
public function __construct(MessageMapper $mapper, | ||
ThreadBuilder $builder) { | ||
$this->mapper = $mapper; | ||
$this->builder = $builder; | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!($event instanceof SynchronizationEvent)) { | ||
// Unrelated | ||
return; | ||
} | ||
|
||
$messages = $this->mapper->findThreadingData($event->getAccount()); | ||
$threads = $this->builder->build($messages); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.