From 259e07b259ce1a4658efa74eabe1174ee35a91ba Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 5 Dec 2021 17:51:16 +0000 Subject: [PATCH] [ENTITY][ActorTag][ActorTagBlock] Add 'use_canonical' column --- src/Entity/ActorTag.php | 28 ++++++++++++++++++---------- src/Entity/ActorTagBlock.php | 21 +++++++++++++++++---- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Entity/ActorTag.php b/src/Entity/ActorTag.php index 22c89e2aa6..0c367274b3 100644 --- a/src/Entity/ActorTag.php +++ b/src/Entity/ActorTag.php @@ -50,6 +50,7 @@ class ActorTag extends Entity private int $tagged; private string $tag; private string $canonical; + private bool $use_canonical; private DateTimeInterface $modified; public function setTagger(int $tagger): self @@ -96,6 +97,17 @@ class ActorTag extends Entity return $this->canonical; } + public function setUseCanonical(bool $use_canonical): self + { + $this->use_canonical = $use_canonical; + return $this; + } + + public function getUseCanonical(): bool + { + return $this->use_canonical; + } + public function setModified(DateTimeInterface $modified): self { $this->modified = $modified; @@ -137,11 +149,12 @@ class ActorTag extends Entity return [ 'name' => 'actor_tag', 'fields' => [ - 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'actor making the tag'], - 'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'], - 'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this actor'], - 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of tag'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'tagger' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagger_fkey', 'not null' => true, 'description' => 'actor making the tag'], + 'tagged' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'one to one', 'name' => 'actor_tag_tagged_fkey', 'not null' => true, 'description' => 'actor tagged'], + 'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this actor'], + 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of tag'], + 'use_canonical' => ['type' => 'bool', 'not null' => true, 'description' => 'whether the user wanted to block canonical tags'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['tagger', 'tagged', 'canonical'], 'indexes' => [ @@ -151,9 +164,4 @@ class ActorTag extends Entity ], ]; } - - public function __toString() - { - return $this->getTag(); - } } diff --git a/src/Entity/ActorTagBlock.php b/src/Entity/ActorTagBlock.php index ec82957a75..55507cbdc3 100644 --- a/src/Entity/ActorTagBlock.php +++ b/src/Entity/ActorTagBlock.php @@ -45,6 +45,7 @@ class ActorTagBlock extends Entity private int $blocker; private string $tag; private string $canonical; + private bool $use_canonical; private DateTimeInterface $modified; public function setBlocker(int $blocker): self @@ -80,6 +81,17 @@ class ActorTagBlock extends Entity return $this->canonical; } + public function setUseCanonical(bool $use_canonical): self + { + $this->use_canonical = $use_canonical; + return $this; + } + + public function getUseCanonical(): bool + { + return $this->use_canonical; + } + public function setModified(DateTimeInterface $modified): self { $this->modified = $modified; @@ -118,10 +130,11 @@ class ActorTagBlock extends Entity return [ 'name' => 'actor_tag_block', 'fields' => [ - 'blocker' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_block_blocker_fkey', 'not null' => true, 'description' => 'user making the block'], - 'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag this is blocking'], - 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'foreign key' => true, 'target' => 'NoteTag.canonical', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'ascii slug of tag'], - 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], + 'blocker' => ['type' => 'int', 'foreign key' => true, 'target' => 'Actor.id', 'multiplicity' => 'many to one', 'name' => 'actor_block_blocker_fkey', 'not null' => true, 'description' => 'user making the block'], + 'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag this is blocking'], + 'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'foreign key' => true, 'target' => 'NoteTag.canonical', 'multiplicity' => 'many to one', 'not null' => true, 'description' => 'ascii slug of tag'], + 'use_canonical' => ['type' => 'bool', 'not null' => true, 'description' => 'whether the user wanted to block canonical tags'], + 'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'], ], 'primary key' => ['blocker', 'canonical'], ];