Insert and update some more fields

This commit is contained in:
Michael 2021-09-10 20:53:10 +00:00
parent 2486c8031b
commit b170dd765d
4 changed files with 35 additions and 16 deletions

View File

@ -1516,6 +1516,11 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
`blocked` boolean COMMENT 'Contact is completely blocked for this user',
`ignored` boolean COMMENT 'Posts from this contact are ignored',
`collapsed` boolean COMMENT 'Posts from this contact are collapsed',
`rel` tinyint unsigned COMMENT 'The kind of the relation between the user and the contact',
`info` mediumtext COMMENT '',
`notify_new_posts` boolean COMMENT '',
`fetch_further_information` tinyint unsigned COMMENT '',
`ffi_keyword_denylist` text COMMENT '',
PRIMARY KEY(`uid`,`cid`),
INDEX `cid` (`cid`),
UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),

View File

@ -7,13 +7,18 @@ Fields
------
| Field | Description | Type | Null | Key | Default | Extra |
| --------- | ------------------------------------------------------------ | ------------------ | ---- | --- | ------- | ----- |
| ------------------------- | ------------------------------------------------------------ | ------------------ | ---- | --- | ------- | ----- |
| cid | Contact id of the linked public contact | int unsigned | NO | PRI | 0 | |
| uid | User id | mediumint unsigned | NO | PRI | 0 | |
| uri-id | Id of the item-uri table entry that contains the contact url | int unsigned | YES | | NULL | |
| blocked | Contact is completely blocked for this user | boolean | YES | | NULL | |
| ignored | Posts from this contact are ignored | boolean | YES | | NULL | |
| collapsed | Posts from this contact are collapsed | boolean | YES | | NULL | |
| rel | The kind of the relation between the user and the contact | tinyint unsigned | YES | | NULL | |
| info | | mediumtext | YES | | NULL | |
| notify_new_posts | | boolean | YES | | NULL | |
| fetch_further_information | | tinyint unsigned | YES | | NULL | |
| ffi_keyword_denylist | | text | YES | | NULL | |
Indexes
------------

View File

@ -22,6 +22,7 @@
namespace Friendica\Model\Contact;
use Exception;
use Friendica\Collection\Api\Mastodon\Fields;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\Database;
@ -59,13 +60,16 @@ class User
return false;
}
$fields = [
'cid' => $pcontact['id'],
'uid' => $contact['uid'],
'uri-id' => $contact['uri-id'],
'blocked' => $contact['blocked'] ?? false,
'ignored' => $contact['readonly'] ?? false,
];
$fields = $contact;
if (isset($fields['readonly'])) {
$fields['ignored'] = $fields['readonly'];
}
$fields = DBStructure::getFieldsForTable('user-contact', $fields);
$fields['cid'] = $pcontact['id'];
$fields['uid'] = $contact['uid'];
$fields['uri-id'] = $contact['uri-id'];
$ret = DBA::insert('user-contact', $fields, Database::INSERT_IGNORE);

View File

@ -1534,7 +1534,12 @@ return [
"uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the contact url"],
"blocked" => ["type" => "boolean", "comment" => "Contact is completely blocked for this user"],
"ignored" => ["type" => "boolean", "comment" => "Posts from this contact are ignored"],
"collapsed" => ["type" => "boolean", "comment" => "Posts from this contact are collapsed"]
"collapsed" => ["type" => "boolean", "comment" => "Posts from this contact are collapsed"],
"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" => ""],
"fetch_further_information" => ["type" => "tinyint unsigned", "comment" => ""],
"ffi_keyword_denylist" => ["type" => "text", "comment" => ""],
],
"indexes" => [
"PRIMARY" => ["uid", "cid"],