Set intro.blocked to deprecated

This commit is contained in:
Philipp 2021-10-19 21:30:09 +02:00
parent bf0782dc6b
commit ed184bd592
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
7 changed files with 14 additions and 14 deletions

View File

@ -719,7 +719,7 @@ CREATE TABLE IF NOT EXISTS `intro` (
`note` text COMMENT '', `note` text COMMENT '',
`hash` varchar(255) NOT NULL DEFAULT '' COMMENT '', `hash` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '', `datetime` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT '',
`blocked` boolean NOT NULL DEFAULT '1' COMMENT '', `blocked` boolean NOT NULL DEFAULT '0' COMMENT 'deprecated',
`ignore` boolean NOT NULL DEFAULT '0' COMMENT '', `ignore` boolean NOT NULL DEFAULT '0' COMMENT '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `contact-id` (`contact-id`), INDEX `contact-id` (`contact-id`),

View File

@ -18,7 +18,7 @@ Fields
| note | | text | YES | | NULL | | | note | | text | YES | | NULL | |
| hash | | varchar(255) | NO | | | | | hash | | varchar(255) | NO | | | |
| datetime | | datetime | NO | | 0001-01-01 00:00:00 | | | datetime | | datetime | NO | | 0001-01-01 00:00:00 | |
| blocked | | boolean | NO | | 1 | | | blocked | deprecated | boolean | NO | | 0 | |
| ignore | | boolean | NO | | 0 | | | ignore | | boolean | NO | | 0 | |
Indexes Indexes

View File

@ -75,7 +75,6 @@ class Introduction extends BaseDepository
'duplex' => $introduction->duplex ? 1 : 0, 'duplex' => $introduction->duplex ? 1 : 0,
'note' => $introduction->note, 'note' => $introduction->note,
'hash' => $introduction->hash, 'hash' => $introduction->hash,
'blocked' => $introduction->blocked ? 1 : 0,
'ignore' => $introduction->ignore ? 1 : 0, 'ignore' => $introduction->ignore ? 1 : 0,
'datetime' => $introduction->datetime->format(DateTimeFormat::MYSQL), 'datetime' => $introduction->datetime->format(DateTimeFormat::MYSQL),
]; ];
@ -143,7 +142,7 @@ class Introduction extends BaseDepository
public function countActiveForUser($uid, array $params = []): int public function countActiveForUser($uid, array $params = []): int
{ {
try { try {
return $this->count(['blocked' => false, 'ignore' => false, 'uid' => $uid], $params); return $this->count(['ignore' => false, 'uid' => $uid], $params);
} catch (\Exception $e) { } catch (\Exception $e) {
throw new IntroductionPersistenceException(sprintf('Cannot count Introductions for used %d', $uid), $e); throw new IntroductionPersistenceException(sprintf('Cannot count Introductions for used %d', $uid), $e);
} }

View File

@ -33,7 +33,6 @@ use Friendica\BaseEntity;
* @property-read string $note * @property-read string $note
* @property-read string $hash * @property-read string $hash
* @property-read \DateTime $datetime * @property-read \DateTime $datetime
* @property-read bool $blocked
* @property-read bool $ignore * @property-read bool $ignore
* @property-read int|null $id * @property-read int|null $id
*/ */
@ -58,8 +57,6 @@ class Introduction extends BaseEntity
/** @var \DateTime */ /** @var \DateTime */
protected $datetime; protected $datetime;
/** @var bool */ /** @var bool */
protected $blocked;
/** @var bool */
protected $ignore; protected $ignore;
/** @var int|null */ /** @var int|null */
protected $id; protected $id;
@ -74,11 +71,10 @@ class Introduction extends BaseEntity
* @param string $note * @param string $note
* @param string $hash * @param string $hash
* @param \DateTime $datetime * @param \DateTime $datetime
* @param bool $blocked
* @param bool $ignore * @param bool $ignore
* @param int|null $id * @param int|null $id
*/ */
public function __construct(int $uid, int $sid, ?int $fid, ?int $cid, bool $knowyou, bool $duplex, string $note, string $hash, \DateTime $datetime, bool $blocked, bool $ignore, ?int $id) public function __construct(int $uid, int $sid, ?int $fid, ?int $cid, bool $knowyou, bool $duplex, string $note, string $hash, \DateTime $datetime, bool $ignore, ?int $id)
{ {
$this->uid = $uid; $this->uid = $uid;
$this->sid = $sid; $this->sid = $sid;
@ -88,7 +84,6 @@ class Introduction extends BaseEntity
$this->duplex = $duplex; $this->duplex = $duplex;
$this->note = $note; $this->note = $note;
$this->hash = $hash; $this->hash = $hash;
$this->blocked = $blocked;
$this->ignore = $ignore; $this->ignore = $ignore;
$this->id = $id; $this->id = $id;
} }

View File

@ -44,7 +44,6 @@ class Introduction extends BaseFactory implements ICanCreateFromTableRow
$row['note'] ?? '', $row['note'] ?? '',
$row['hash'] ?? '', $row['hash'] ?? '',
new \DateTime($row['datetime'] ?? 'now', new \DateTimeZone('UTC')), new \DateTime($row['datetime'] ?? 'now', new \DateTimeZone('UTC')),
!empty($row['blocked']),
!empty($row['ignore']), !empty($row['ignore']),
$row['id'] ?? null $row['id'] ?? null
); );
@ -69,7 +68,6 @@ class Introduction extends BaseFactory implements ICanCreateFromTableRow
'note' => $note, 'note' => $note,
'hash' => Strings::getRandomHex(), 'hash' => Strings::getRandomHex(),
'datetime' => DateTimeFormat::utcNow(), 'datetime' => DateTimeFormat::utcNow(),
'blocked' => false,
'ignore' => false, 'ignore' => false,
]); ]);
} }

View File

@ -782,7 +782,7 @@ return [
"note" => ["type" => "text", "comment" => ""], "note" => ["type" => "text", "comment" => ""],
"hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "hash" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
"datetime" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], "datetime" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""],
"blocked" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => ""], "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "deprecated"],
"ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "ignore" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
], ],
"indexes" => [ "indexes" => [

View File

@ -1039,7 +1039,7 @@ function update_1440()
return Update::SUCCESS; return Update::SUCCESS;
} }
function update__1441() function update_1441()
{ {
$languages = DI::l10n()->getAvailableLanguages(); $languages = DI::l10n()->getAvailableLanguages();
@ -1053,3 +1053,11 @@ function update__1441()
return Update::SUCCESS; return Update::SUCCESS;
} }
function update_1442()
{
// transform blocked intros into ignored intros
DBA::update('intro', ['ignore' => 1, 'blocked' => 0], ['blocked' => 1]);
return Update::SUCCESS;
}