More fields added to "user-contact"

This commit is contained in:
Michael 2021-09-13 14:20:20 +00:00
parent 5abc1543fd
commit 2926282f8d
4 changed files with 31 additions and 24 deletions

View file

@ -1526,6 +1526,8 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
`subhub` boolean COMMENT '',
`hub-verify` varchar(255) COMMENT '',
`protocol` char(4) COMMENT 'Protocol of the contact',
`rating` tinyint COMMENT 'Automatically detected feed poll frequency',
`priority` tinyint unsigned COMMENT 'Feed poll priority',
PRIMARY KEY(`uid`,`cid`),
INDEX `cid` (`cid`),
UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),

View file

@ -24,6 +24,8 @@ Fields
| subhub | | boolean | YES | | NULL | |
| hub-verify | | varchar(255) | YES | | NULL | |
| protocol | Protocol of the contact | char(4) | YES | | NULL | |
| rating | Automatically detected feed poll frequency | tinyint | YES | | NULL | |
| priority | Feed poll priority | tinyint unsigned | YES | | NULL | |
Indexes
------------

View file

@ -66,17 +66,7 @@ class User
return false;
}
$fields = $contact;
if (isset($fields['readonly'])) {
$fields['ignored'] = $fields['readonly'];
}
if (!empty($fields['self'])) {
$fields['rel'] = Contact::SELF;
}
$fields = DBStructure::getFieldsForTable('user-contact', $fields);
$fields = self::preparedFields($contact);
$fields['cid'] = $pcid;
$fields['uid'] = $contact['uid'];
$fields['uri-id'] = $contact['uri-id'];
@ -101,19 +91,7 @@ class User
{
DBA::transaction();
unset($fields['uid']);
unset($fields['cid']);
unset($fields['uri-id']);
if (isset($fields['readonly'])) {
$fields['ignored'] = $fields['readonly'];
}
if (!empty($fields['self'])) {
$fields['rel'] = Contact::SELF;
}
$update_fields = DBStructure::getFieldsForTable('user-contact', $fields);
$update_fields = self::preparedFields($fields);
if (!empty($update_fields)) {
$contacts = DBA::select('contact', ['uri-id', 'uid'], $condition);
while ($row = DBA::fetch($contacts)) {
@ -129,6 +107,29 @@ class User
DBA::commit();
}
/**
* Prepare field data for update/insert
*
* @param array $fields
* @return array prepared fields
*/
private static function preparedFields(array $fields): array
{
unset($fields['uid']);
unset($fields['cid']);
unset($fields['uri-id']);
if (isset($fields['readonly'])) {
$fields['ignored'] = $fields['readonly'];
}
if (!empty($fields['self'])) {
$fields['rel'] = Contact::SELF;
}
return DBStructure::getFieldsForTable('user-contact', $fields);
}
/**
* Block contact id for user id
*

View file

@ -1548,6 +1548,8 @@ return [
"subhub" => ["type" => "boolean", "comment" => ""],
"hub-verify" => ["type" => "varchar(255)", "comment" => ""],
"protocol" => ["type" => "char(4)", "comment" => "Protocol of the contact"],
"rating" => ["type" => "tinyint", "comment" => "Automatically detected feed poll frequency"],
"priority" => ["type" => "tinyint unsigned", "comment" => "Feed poll priority"],
],
"indexes" => [
"PRIMARY" => ["uid", "cid"],