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', `blocked` boolean COMMENT 'Contact is completely blocked for this user',
`ignored` boolean COMMENT 'Posts from this contact are ignored', `ignored` boolean COMMENT 'Posts from this contact are ignored',
`collapsed` boolean COMMENT 'Posts from this contact are collapsed', `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`), PRIMARY KEY(`uid`,`cid`),
INDEX `cid` (`cid`), INDEX `cid` (`cid`),
UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`), UNIQUE INDEX `uri-id_uid` (`uri-id`,`uid`),

View File

@ -6,14 +6,19 @@ User specific public contact data
Fields Fields
------ ------
| Field | Description | Type | Null | Key | Default | Extra | | Field | Description | Type | Null | Key | Default | Extra |
| --------- | ------------------------------------------------------------ | ------------------ | ---- | --- | ------- | ----- | | ------------------------- | ------------------------------------------------------------ | ------------------ | ---- | --- | ------- | ----- |
| cid | Contact id of the linked public contact | int unsigned | NO | PRI | 0 | | | cid | Contact id of the linked public contact | int unsigned | NO | PRI | 0 | |
| uid | User id | mediumint 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 | | | 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 | | | blocked | Contact is completely blocked for this user | boolean | YES | | NULL | |
| ignored | Posts from this contact are ignored | boolean | YES | | NULL | | | ignored | Posts from this contact are ignored | boolean | YES | | NULL | |
| collapsed | Posts from this contact are collapsed | 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 Indexes
------------ ------------

View File

@ -22,6 +22,7 @@
namespace Friendica\Model\Contact; namespace Friendica\Model\Contact;
use Exception; use Exception;
use Friendica\Collection\Api\Mastodon\Fields;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
@ -59,13 +60,16 @@ class User
return false; return false;
} }
$fields = [ $fields = $contact;
'cid' => $pcontact['id'],
'uid' => $contact['uid'], if (isset($fields['readonly'])) {
'uri-id' => $contact['uri-id'], $fields['ignored'] = $fields['readonly'];
'blocked' => $contact['blocked'] ?? false, }
'ignored' => $contact['readonly'] ?? false,
]; $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); $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"], "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"], "blocked" => ["type" => "boolean", "comment" => "Contact is completely blocked for this user"],
"ignored" => ["type" => "boolean", "comment" => "Posts from this contact are ignored"], "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" => [ "indexes" => [
"PRIMARY" => ["uid", "cid"], "PRIMARY" => ["uid", "cid"],