diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-09-29 20:59:25 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-09-29 21:03:08 +0300 |
commit | 41709feb12685f741850528e411b881c5fe65317 (patch) | |
tree | 8e16cfd1ca3b72b7a8c4f174dd9212639e255198 /lib/IMAP | |
parent | a0c3f8f4ee8a835a57985d46e7531e21cbc7706e (diff) |
Optionally redact the exported thread data
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/IMAP')
-rw-r--r-- | lib/IMAP/Threading/DatabaseMessage.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/IMAP/Threading/DatabaseMessage.php b/lib/IMAP/Threading/DatabaseMessage.php index d36001885..da79522ce 100644 --- a/lib/IMAP/Threading/DatabaseMessage.php +++ b/lib/IMAP/Threading/DatabaseMessage.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\Mail\IMAP\Threading; use JsonSerializable; +use function array_map; use function array_merge; use function json_decode; @@ -91,6 +92,18 @@ class DatabaseMessage extends Message implements JsonSerializable { return $this->dirty; } + public function redact(callable $hash): DatabaseMessage { + return new self( + $this->databaseId, + $this->hasReSubject() ? "Re: " . $hash($this->getSubject()) : $hash($this->getSubject()), + $hash($this->getId()), + array_map(function (string $ref) use ($hash) { + return $hash($ref); + }, $this->getReferences()), + $this->threadRootId === null ? null : $hash($this->threadRootId) + ); + } + public function jsonSerialize(): array { return array_merge( parent::jsonSerialize(), |