mirror of
https://github.com/friendica/friendica
synced 2024-11-09 17:02:54 +00:00
[Database 1524] Fix contact-user.remote_self field type from boolean to integer
- Move MIRROR_* constants to LocalRelationship entity - Convert boolean LocalRelationship->isRemoteSelf field to integer LocalRelationship->remoteSelf
This commit is contained in:
parent
d0a2357fbd
commit
33b8680dfd
8 changed files with 41 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2023.09-dev (Giant Rhubarb)
|
||||
-- DB_UPDATE_VERSION 1523
|
||||
-- DB_UPDATE_VERSION 1524
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -1834,7 +1834,7 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
|
|||
`rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
|
||||
`info` mediumtext COMMENT '',
|
||||
`notify_new_posts` boolean COMMENT '',
|
||||
`remote_self` boolean COMMENT '',
|
||||
`remote_self` tinyint unsigned COMMENT '0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare',
|
||||
`fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
|
||||
`ffi_keyword_denylist` text COMMENT '',
|
||||
`subhub` boolean COMMENT '',
|
||||
|
|
|
@ -36,7 +36,7 @@ use Friendica\Model\Contact;
|
|||
* @property-read int $rel
|
||||
* @property-read string $info
|
||||
* @property-read bool $notifyNewPosts
|
||||
* @property-read bool $isRemoteSelf
|
||||
* @property-read int $remoteSelf
|
||||
* @property-read int $fetchFurtherInformation
|
||||
* @property-read string $ffiKeywordDenylist
|
||||
* @property-read bool $subhub
|
||||
|
@ -53,6 +53,10 @@ class LocalRelationship extends \Friendica\BaseEntity
|
|||
const FFI_KEYWORD = 3;
|
||||
const FFI_BOTH = 2;
|
||||
|
||||
const MIRROR_DEACTIVATED = 0;
|
||||
const MIRROR_OWN_POST = 2;
|
||||
const MIRROR_NATIVE_RESHARE = 3;
|
||||
|
||||
/** @var int */
|
||||
protected $userId;
|
||||
/** @var int */
|
||||
|
@ -73,9 +77,8 @@ class LocalRelationship extends \Friendica\BaseEntity
|
|||
protected $info;
|
||||
/** @var bool */
|
||||
protected $notifyNewPosts;
|
||||
/** @var bool */
|
||||
protected $isRemoteSelf;
|
||||
/** @var int */
|
||||
/** @var int One of MIRROR_* */
|
||||
protected $remoteSelf;
|
||||
/** @var int One of FFI_* */
|
||||
protected $fetchFurtherInformation;
|
||||
/** @var string */
|
||||
|
@ -91,7 +94,7 @@ class LocalRelationship extends \Friendica\BaseEntity
|
|||
/** @var int */
|
||||
protected $priority;
|
||||
|
||||
public function __construct(int $userId, int $contactId, bool $blocked = false, bool $ignored = false, bool $collapsed = false, bool $hidden = false, bool $pending = false, int $rel = Contact::NOTHING, string $info = '', bool $notifyNewPosts = false, bool $isRemoteSelf = false, int $fetchFurtherInformation = self::FFI_NONE, string $ffiKeywordDenylist = '', bool $subhub = false, string $hubVerify = '', string $protocol = Protocol::PHANTOM, ?int $rating = null, ?int $priority = null)
|
||||
public function __construct(int $userId, int $contactId, bool $blocked = false, bool $ignored = false, bool $collapsed = false, bool $hidden = false, bool $pending = false, int $rel = Contact::NOTHING, string $info = '', bool $notifyNewPosts = false, int $remoteSelf = self::MIRROR_DEACTIVATED, int $fetchFurtherInformation = self::FFI_NONE, string $ffiKeywordDenylist = '', bool $subhub = false, string $hubVerify = '', string $protocol = Protocol::PHANTOM, ?int $rating = null, ?int $priority = null)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
$this->contactId = $contactId;
|
||||
|
@ -103,7 +106,7 @@ class LocalRelationship extends \Friendica\BaseEntity
|
|||
$this->rel = $rel;
|
||||
$this->info = $info;
|
||||
$this->notifyNewPosts = $notifyNewPosts;
|
||||
$this->isRemoteSelf = $isRemoteSelf;
|
||||
$this->remoteSelf = $remoteSelf;
|
||||
$this->fetchFurtherInformation = $fetchFurtherInformation;
|
||||
$this->ffiKeywordDenylist = $ffiKeywordDenylist;
|
||||
$this->subhub = $subhub;
|
||||
|
|
|
@ -45,7 +45,7 @@ class LocalRelationship extends BaseFactory implements ICanCreateFromTableRow
|
|||
$row['rel'] ?? Contact::NOTHING,
|
||||
$row['info'] ?? '',
|
||||
$row['notify_new_posts'] ?? false,
|
||||
$row['remote_self'] ?? false,
|
||||
$row['remote_self'] ?? Entity\LocalRelationship::MIRROR_DEACTIVATED,
|
||||
$row['fetch_further_information'] ?? Entity\LocalRelationship::FFI_NONE,
|
||||
$row['ffi_keyword_denylist'] ?? '',
|
||||
$row['subhub'] ?? false,
|
||||
|
|
|
@ -100,7 +100,7 @@ class LocalRelationship extends \Friendica\BaseRepository
|
|||
'rel' => $localRelationship->rel,
|
||||
'info' => $localRelationship->info,
|
||||
'notify_new_posts' => $localRelationship->notifyNewPosts,
|
||||
'remote_self' => $localRelationship->isRemoteSelf,
|
||||
'remote_self' => $localRelationship->remoteSelf,
|
||||
'fetch_further_information' => $localRelationship->fetchFurtherInformation,
|
||||
'ffi_keyword_denylist' => $localRelationship->ffiKeywordDenylist,
|
||||
'subhub' => $localRelationship->subhub,
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Model;
|
|||
|
||||
use Friendica\Contact\Avatar;
|
||||
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
|
||||
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
|
||||
use Friendica\Content\Conversation as ConversationContent;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Text\HTML;
|
||||
|
@ -111,10 +112,14 @@ class Contact
|
|||
* @}
|
||||
*/
|
||||
|
||||
const MIRROR_DEACTIVATED = 0;
|
||||
const MIRROR_FORWARDED = 1; // Deprecated, now does the same like MIRROR_OWN_POST
|
||||
const MIRROR_OWN_POST = 2;
|
||||
const MIRROR_NATIVE_RESHARE = 3;
|
||||
/** @deprecated Use Entity\LocalRelationship::MIRROR_DEACTIVATED instead */
|
||||
const MIRROR_DEACTIVATED = LocalRelationship::MIRROR_DEACTIVATED;
|
||||
/** @deprecated Now does the same as MIRROR_OWN_POST */
|
||||
const MIRROR_FORWARDED = 1;
|
||||
/** @deprecated Use Entity\LocalRelationship::MIRROR_OWN_POST instead */
|
||||
const MIRROR_OWN_POST = LocalRelationship::MIRROR_OWN_POST;
|
||||
/** @deprecated Use Entity\LocalRelationship::MIRROR_NATIVE_RESHARE instead */
|
||||
const MIRROR_NATIVE_RESHARE = LocalRelationship::MIRROR_NATIVE_RESHARE;
|
||||
|
||||
/**
|
||||
* @param array $fields Array of selected fields, empty for all
|
||||
|
|
|
@ -394,7 +394,7 @@ class Profile extends BaseModule
|
|||
'$remote_self' => [
|
||||
'remote_self',
|
||||
$this->t('Mirror postings from this contact'),
|
||||
$localRelationship->isRemoteSelf,
|
||||
$localRelationship->remoteSelf,
|
||||
$this->t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
|
||||
$remote_self_options
|
||||
],
|
||||
|
|
|
@ -56,7 +56,7 @@ use Friendica\Database\DBA;
|
|||
|
||||
// This file is required several times during the test in DbaDefinition which justifies this condition
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1523);
|
||||
define('DB_UPDATE_VERSION', 1524);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -1826,7 +1826,7 @@ return [
|
|||
"rel" => ["type" => "tinyint unsigned", "comment" => "The kind of the relation between the user and the contact"],
|
||||
"info" => ["type" => "mediumtext", "comment" => ""],
|
||||
"notify_new_posts" => ["type" => "boolean", "comment" => ""],
|
||||
"remote_self" => ["type" => "boolean", "comment" => ""],
|
||||
"remote_self" => ["type" => "tinyint unsigned", "comment" => "0 => No mirroring, 1-2 => Mirror as own post, 3 => Mirror as reshare"],
|
||||
"fetch_further_information" => ["type" => "tinyint unsigned", "comment" => "0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both"],
|
||||
"ffi_keyword_denylist" => ["type" => "text", "comment" => ""],
|
||||
"subhub" => ["type" => "boolean", "comment" => ""],
|
||||
|
|
16
update.php
16
update.php
|
@ -1333,3 +1333,19 @@ function update_1520(): int
|
|||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* user-contact.remote_self was wrongly declared as boolean, possibly truncating integer values from contact.remote_self
|
||||
*
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
function update_1524(): int
|
||||
{
|
||||
$contacts = DBA::select('contact', ['uid', 'uri-id', 'remote_self'], ["`uid` != ?", 0]);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
Contact\User::insertForContactArray($contact);
|
||||
}
|
||||
|
||||
return Update::SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue