diff options
author | Anna Larch <anna@nextcloud.com> | 2021-04-07 13:45:08 +0300 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2021-04-07 17:32:06 +0300 |
commit | 0c27b7705254f85aa34ae634d10332b3525ad9fe (patch) | |
tree | afbdb28b7b31376bfc8923a0f78090cbabb2fa7a /lib | |
parent | 3b4a09ef94750d344c340faa2493467308cfe511 (diff) |
Change provisioning column
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/Classifier.php | 2 | ||||
-rw-r--r-- | lib/Db/MailAccount.php | 14 | ||||
-rw-r--r-- | lib/Db/Mailbox.php | 6 | ||||
-rw-r--r-- | lib/Db/Message.php | 64 | ||||
-rw-r--r-- | lib/Db/Tag.php | 4 | ||||
-rw-r--r-- | lib/Migration/Version0190Date20191118160843.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1020Date20191002091035.php | 16 | ||||
-rw-r--r-- | lib/Migration/Version1020Date20200206134751.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1040Date20200422142920.php | 21 | ||||
-rw-r--r-- | lib/Migration/Version1040Date20200506111214.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1040Date20200515080614.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1050Date20200923180030.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1080Date20210108093802.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1090Date20210127160127.php | 2 | ||||
-rw-r--r-- | lib/Migration/Version1100Date20210406144257.php | 101 | ||||
-rw-r--r-- | lib/Service/Classification/ImportanceClassifier.php | 2 |
16 files changed, 173 insertions, 71 deletions
diff --git a/lib/Db/Classifier.php b/lib/Db/Classifier.php index 2ddaba243..44d2576c2 100644 --- a/lib/Db/Classifier.php +++ b/lib/Db/Classifier.php @@ -113,7 +113,7 @@ class Classifier extends Entity { $this->addType('precisionImportant', 'float'); $this->addType('f1ScoreImportant', 'float'); $this->addType('duration', 'int'); - $this->addType('active', 'bool'); + $this->addType('active', 'boolean'); $this->addType('createdAt', 'int'); } } diff --git a/lib/Db/MailAccount.php b/lib/Db/MailAccount.php index 3df3c1a67..1fa65bb2d 100644 --- a/lib/Db/MailAccount.php +++ b/lib/Db/MailAccount.php @@ -63,11 +63,11 @@ use OCP\AppFramework\Db\Entity; * @method void setLastMailboxSync(int $time) * @method string getEditorMode() * @method void setEditorMode(string $editorMode) - * @method bool getProvisioned() + * @method bool|null getProvisioned() * @method void setProvisioned(bool $provisioned) * @method int getOrder() * @method void setOrder(int $order) - * @method bool getShowSubscribedOnly() + * @method bool|null getShowSubscribedOnly() * @method void setShowSubscribedOnly(bool $showSubscribedOnly) * @method string|null getPersonalNamespace() * @method void setPersonalNamespace(string|null $personalNamespace) @@ -77,7 +77,7 @@ use OCP\AppFramework\Db\Entity; * @method int|null getSentMailboxId() * @method void setTrashMailboxId(?int $id) * @method int|null getTrashMailboxId() - * @method bool isSieveEnabled() + * @method bool|null isSieveEnabled() * @method void setSieveEnabled(bool $sieveEnabled) * @method string|null getSieveHost() * @method void setSieveHost(?string $sieveHost) @@ -186,7 +186,7 @@ class MailAccount extends Entity { $this->addType('inboundPort', 'integer'); $this->addType('outboundPort', 'integer'); $this->addType('lastMailboxSync', 'integer'); - $this->addType('provisioned', 'bool'); + $this->addType('provisioned', 'boolean'); $this->addType('order', 'integer'); $this->addType('showSubscribedOnly', 'boolean'); $this->addType('personalNamespace', 'string'); @@ -213,13 +213,13 @@ class MailAccount extends Entity { 'imapSslMode' => $this->getInboundSslMode(), 'signature' => $this->getSignature(), 'editorMode' => $this->getEditorMode(), - 'provisioned' => $this->getProvisioned(), - 'showSubscribedOnly' => $this->getShowSubscribedOnly(), + 'provisioned' => ($this->getProvisioned() === true), + 'showSubscribedOnly' => ($this->getShowSubscribedOnly() === true), 'personalNamespace' => $this->getPersonalNamespace(), 'draftsMailboxId' => $this->getDraftsMailboxId(), 'sentMailboxId' => $this->getSentMailboxId(), 'trashMailboxId' => $this->getTrashMailboxId(), - 'sieveEnabled' => $this->isSieveEnabled(), + 'sieveEnabled' => ($this->isSieveEnabled() === true), ]; if (!is_null($this->getOutboundHost())) { diff --git a/lib/Db/Mailbox.php b/lib/Db/Mailbox.php index eb7ca6a2e..ebbf149af 100644 --- a/lib/Db/Mailbox.php +++ b/lib/Db/Mailbox.php @@ -58,11 +58,11 @@ use function strtolower; * @method void setMessages(int $messages) * @method int getUnseen() * @method void setUnseen(int $unseen) - * @method bool getSelectable() + * @method bool|null getSelectable() * @method void setSelectable(bool $selectable) * @method string getSpecialUse() * @method void setSpecialUse(string $specialUse) - * @method bool getSyncInBackground() + * @method bool|null getSyncInBackground() * @method void setSyncInBackground(bool $sync) */ class Mailbox extends Entity implements JsonSerializable { @@ -151,7 +151,7 @@ class Mailbox extends Entity implements JsonSerializable { 'specialUse' => $specialUse, 'specialRole' => $specialUse[0] ?? 0, 'mailboxes' => [], - 'syncInBackground' => $this->getSyncInBackground(), + 'syncInBackground' => ($this->getSyncInBackground() === true), ]; } } diff --git a/lib/Db/Message.php b/lib/Db/Message.php index ea27288b0..326746d99 100644 --- a/lib/Db/Message.php +++ b/lib/Db/Message.php @@ -48,29 +48,29 @@ use function json_encode; * @method void setSentAt(int $time) * @method int getSentAt() * @method void setFlagAnswered(bool $answered) - * @method bool getFlagAnswered() + * @method bool|null getFlagAnswered() * @method void setFlagDeleted(bool $deleted) - * @method bool getFlagDeleted() + * @method bool|null getFlagDeleted() * @method void setFlagDraft(bool $answered) - * @method bool getFlagDraft() + * @method bool|null|null getFlagDraft() * @method void setFlagFlagged(bool $flagged) - * @method bool getFlagFlagged() + * @method bool|null getFlagFlagged() * @method void setFlagSeen(bool $seen) - * @method bool getFlagSeen() + * @method bool|null getFlagSeen() * @method void setFlagForwarded(bool $forwarded) - * @method bool getFlagForwarded() + * @method bool|null getFlagForwarded() * @method void setFlagJunk(bool $junk) - * @method bool getFlagJunk() + * @method bool|null getFlagJunk() * @method void setFlagNotjunk(bool $notjunk) - * @method bool getFlagNotjunk() + * @method bool|null getFlagNotjunk() * @method void setStructureAnalyzed(bool $analyzed) - * @method bool getStructureAnalyzed() + * @method bool|null getStructureAnalyzed() * @method void setFlagAttachments(?bool $hasAttachments) * @method null|bool getFlagAttachments() * @method void setFlagImportant(bool $important) - * @method bool getFlagImportant() + * @method bool|null getFlagImportant() * @method void setFlagMdnsent(bool $mdnsent) - * @method bool getFlagMdnsent() + * @method bool|null getFlagMdnsent() * @method void setPreviewText(?string $subject) * @method null|string getPreviewText() * @method void setUpdatedAt(int $time) @@ -138,18 +138,18 @@ class Message extends Entity implements JsonSerializable { $this->addType('uid', 'integer'); $this->addType('mailboxId', 'integer'); $this->addType('sentAt', 'integer'); - $this->addType('flagAnswered', 'bool'); - $this->addType('flagDeleted', 'bool'); - $this->addType('flagDraft', 'bool'); - $this->addType('flagFlagged', 'bool'); - $this->addType('flagSeen', 'bool'); - $this->addType('flagForwarded', 'bool'); - $this->addType('flagJunk', 'bool'); - $this->addType('flagNotjunk', 'bool'); - $this->addType('structureAnalyzed', 'bool'); - $this->addType('flagAttachments', 'bool'); - $this->addType('flagImportant', 'bool'); - $this->addType('flagMdnsent', 'bool'); + $this->addType('flagAnswered', 'boolean'); + $this->addType('flagDeleted', 'boolean'); + $this->addType('flagDraft', 'boolean'); + $this->addType('flagFlagged', 'boolean'); + $this->addType('flagSeen', 'boolean'); + $this->addType('flagForwarded', 'boolean'); + $this->addType('flagJunk', 'boolean'); + $this->addType('flagNotjunk', 'boolean'); + $this->addType('structureAnalyzed', 'boolean'); + $this->addType('flagAttachments', 'boolean'); + $this->addType('flagImportant', 'boolean'); + $this->addType('flagMdnsent', 'boolean'); $this->addType('updatedAt', 'integer'); } @@ -276,15 +276,15 @@ class Message extends Entity implements JsonSerializable { 'subject' => $this->getSubject(), 'dateInt' => $this->getSentAt(), 'flags' => [ - 'seen' => $this->getFlagSeen(), - 'flagged' => $this->getFlagFlagged(), - 'answered' => $this->getFlagAnswered(), - 'deleted' => $this->getFlagDeleted(), - 'draft' => $this->getFlagDraft(), - 'forwarded' => $this->getFlagForwarded(), - 'hasAttachments' => $this->getFlagAttachments() ?? false, - 'junk' => $this->getFlagJunk(), - 'mdnsent' => $this->getFlagMdnsent(), + 'seen' => ($this->getFlagSeen() === true), + 'flagged' => ($this->getFlagFlagged() === true), + 'answered' => ($this->getFlagAnswered() === true), + 'deleted' => ($this->getFlagDeleted() === true), + 'draft' => ($this->getFlagDraft() === true), + 'forwarded' => ($this->getFlagForwarded() === true), + 'hasAttachments' => ($this->getFlagAttachments() ?? false), + 'junk' => ($this->getFlagJunk() === true), + 'mdnsent' => ($this->getFlagMdnsent() === true), ], 'tags' => $indexed, 'from' => $this->getFrom()->jsonSerialize(), diff --git a/lib/Db/Tag.php b/lib/Db/Tag.php index 261f9c393..8f254d9eb 100644 --- a/lib/Db/Tag.php +++ b/lib/Db/Tag.php @@ -37,7 +37,7 @@ use OCP\AppFramework\Db\Entity; * @method void setImapLabel(string $imapLabel) * @method string getColor() * @method void setColor(string $color) - * @method bool getIsDefaultTag() + * @method bool|null getIsDefaultTag() * @method void setIsDefaultTag(bool $flag) */ class Tag extends Entity implements JsonSerializable { @@ -62,7 +62,7 @@ class Tag extends Entity implements JsonSerializable { 'displayName' => $this->getDisplayName(), 'imapLabel' => $this->getImapLabel(), 'color' => $this->getColor(), - 'isDefaultTag' => $this->getIsDefaultTag(), + 'isDefaultTag' => ($this->getIsDefaultTag() === true), ]; } } diff --git a/lib/Migration/Version0190Date20191118160843.php b/lib/Migration/Version0190Date20191118160843.php index 11624c166..74bbf6c91 100644 --- a/lib/Migration/Version0190Date20191118160843.php +++ b/lib/Migration/Version0190Date20191118160843.php @@ -45,7 +45,7 @@ class Version0190Date20191118160843 extends SimpleMigrationStep { $accountsTable = $schema->getTable('mail_accounts'); $accountsTable->addColumn('provisioned', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $accountsTable->changeColumn('inbound_password', [ diff --git a/lib/Migration/Version1020Date20191002091035.php b/lib/Migration/Version1020Date20191002091035.php index bd35180d1..c9d5d9d78 100644 --- a/lib/Migration/Version1020Date20191002091035.php +++ b/lib/Migration/Version1020Date20191002091035.php @@ -58,35 +58,35 @@ class Version1020Date20191002091035 extends SimpleMigrationStep { 'length' => 4, ]); $messagesTable->addColumn('flag_answered', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_deleted', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_draft', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_flagged', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_seen', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_forwarded', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_junk', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_notjunk', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('updated_at', 'integer', [ diff --git a/lib/Migration/Version1020Date20200206134751.php b/lib/Migration/Version1020Date20200206134751.php index a9765a016..b289f48dc 100644 --- a/lib/Migration/Version1020Date20200206134751.php +++ b/lib/Migration/Version1020Date20200206134751.php @@ -24,7 +24,7 @@ class Version1020Date20200206134751 extends SimpleMigrationStep { $messagesTable = $schema->getTable('mail_messages'); $messagesTable->addColumn('structure_analyzed', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_attachments', 'boolean', [ diff --git a/lib/Migration/Version1040Date20200422142920.php b/lib/Migration/Version1040Date20200422142920.php index ee8a39be4..799a6bafd 100644 --- a/lib/Migration/Version1040Date20200422142920.php +++ b/lib/Migration/Version1040Date20200422142920.php @@ -50,46 +50,47 @@ class Version1040Date20200422142920 extends SimpleMigrationStep { 'length' => 4, ]); $messagesTable->addColumn('flag_answered', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_deleted', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_draft', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_flagged', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_seen', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_forwarded', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_junk', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_notjunk', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('flag_attachments', 'boolean', [ 'notnull' => false, + 'default' => false, ]); $messagesTable->addColumn('flag_important', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('structure_analyzed', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $messagesTable->addColumn('preview_text', 'string', [ diff --git a/lib/Migration/Version1040Date20200506111214.php b/lib/Migration/Version1040Date20200506111214.php index 5f19ab931..4b1f3ad56 100644 --- a/lib/Migration/Version1040Date20200506111214.php +++ b/lib/Migration/Version1040Date20200506111214.php @@ -72,7 +72,7 @@ class Version1040Date20200506111214 extends SimpleMigrationStep { 'length' => 4, ]); $table->addColumn('active', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $table->addColumn('created_at', 'integer', [ diff --git a/lib/Migration/Version1040Date20200515080614.php b/lib/Migration/Version1040Date20200515080614.php index 20dc7c32b..2731505d8 100644 --- a/lib/Migration/Version1040Date20200515080614.php +++ b/lib/Migration/Version1040Date20200515080614.php @@ -25,7 +25,7 @@ class Version1040Date20200515080614 extends SimpleMigrationStep { $accountsTable = $schema->getTable('mail_accounts'); $accountsTable->addColumn('show_subscribed_only', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); diff --git a/lib/Migration/Version1050Date20200923180030.php b/lib/Migration/Version1050Date20200923180030.php index d925f4849..063e88ec6 100644 --- a/lib/Migration/Version1050Date20200923180030.php +++ b/lib/Migration/Version1050Date20200923180030.php @@ -24,7 +24,7 @@ class Version1050Date20200923180030 extends SimpleMigrationStep { $accountsTable = $schema->getTable('mail_mailboxes'); $accountsTable->addColumn('sync_in_background', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); diff --git a/lib/Migration/Version1080Date20210108093802.php b/lib/Migration/Version1080Date20210108093802.php index f6b303750..e68e2cadf 100644 --- a/lib/Migration/Version1080Date20210108093802.php +++ b/lib/Migration/Version1080Date20210108093802.php @@ -23,7 +23,7 @@ class Version1080Date20210108093802 extends SimpleMigrationStep { $messagesTable = $schema->getTable('mail_messages'); $messagesTable->addColumn('flag_mdnsent', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); diff --git a/lib/Migration/Version1090Date20210127160127.php b/lib/Migration/Version1090Date20210127160127.php index 8a52ae4fc..eb3385e14 100644 --- a/lib/Migration/Version1090Date20210127160127.php +++ b/lib/Migration/Version1090Date20210127160127.php @@ -22,7 +22,7 @@ class Version1090Date20210127160127 extends SimpleMigrationStep { $table = $schema->getTable('mail_accounts'); $table->addColumn('sieve_enabled', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); $table->addColumn('sieve_host', 'string', [ diff --git a/lib/Migration/Version1100Date20210406144257.php b/lib/Migration/Version1100Date20210406144257.php new file mode 100644 index 000000000..709d436d6 --- /dev/null +++ b/lib/Migration/Version1100Date20210406144257.php @@ -0,0 +1,101 @@ +<?php + +declare(strict_types=1); + +namespace OCA\Mail\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version1100Date20210406144257 extends SimpleMigrationStep { + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('mail_accounts'); + $table->changeColumn('provisioned', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('show_subscribed_only', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('sieve_enabled', [ + 'notnull' => false, + 'default' => false + ]); + + $table = $schema->getTable('mail_classifiers'); + $table->changeColumn('active', [ + 'notnull' => false, + 'default' => false + ]); + + $table = $schema->getTable('mail_mailboxes'); + $table->changeColumn('selectable', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('sync_in_background', [ + 'notnull' => false, + 'default' => false + ]); + + $table = $schema->getTable('mail_messages'); + $table->changeColumn('flag_answered', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_deleted', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_draft', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_flagged', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_seen', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_forwarded', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_junk', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_notjunk', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_important', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('flag_mdnsent', [ + 'notnull' => false, + 'default' => false + ]); + $table->changeColumn('structure_analyzed', [ + 'notnull' => false, + 'default' => false + ]); + return $schema; + } +} diff --git a/lib/Service/Classification/ImportanceClassifier.php b/lib/Service/Classification/ImportanceClassifier.php index f20727b1d..b59e16e2e 100644 --- a/lib/Service/Classification/ImportanceClassifier.php +++ b/lib/Service/Classification/ImportanceClassifier.php @@ -168,7 +168,7 @@ class ImportanceClassifier { [$this, 'filterMessageHasSenderEmail'] ); $importantMessages = array_filter($messages, function (Message $message) { - return $message->getFlagImportant(); + return ($message->getFlagImportant() === true); }); $logger->debug('found ' . count($messages) . ' messages of which ' . count($importantMessages) . ' are important'); if (count($importantMessages) < self::COLD_START_THRESHOLD) { |