1
0
Fork 0

Ensure to store user-contact / display contact relations

This commit is contained in:
Michael 2023-05-29 06:41:07 +00:00
parent 89b6c4c73f
commit a42ddafbbb
4 changed files with 8 additions and 8 deletions

View file

@ -27,7 +27,6 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\ItemURI;
@ -95,13 +94,14 @@ class User
$update_fields = self::preparedFields($fields);
if (!empty($update_fields)) {
$contacts = DBA::select('contact', ['uri-id', 'uid'], $condition);
$contacts = DBA::select('account-user-view', ['pid', 'uri-id', 'uid'], $condition);
while ($contact = DBA::fetch($contacts)) {
if (empty($contact['uri-id']) || empty($contact['uid'])) {
continue;
}
$ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']]);
Logger::info('Updated user contact', ['uid' => $contact['uid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
$update_fields['cid'] = $contact['pid'];
$ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']], true);
Logger::info('Updated user contact', ['uid' => $contact['uid'], 'id' => $contact['pid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
}
DBA::close($contacts);

View file

@ -246,7 +246,7 @@ class Profile extends BaseModule
$relation_text = '';
}
if (!in_array($contact['network'], array_merge(Protocol::FEDERATED, [Protocol::TWITTER]))) {
if (!Protocol::supportsFollow($contact['network'])) {
$relation_text = '';
}

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1518);
define('DB_UPDATE_VERSION', 1519);
}
return [

View file

@ -214,7 +214,7 @@
"parent-author-network" => ["parent-post-author", "network"],
],
"query" => "FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
STRAIGHT_JOIN `contact` ON `contact`.`id` = `post-user`.`contact-id`
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = `post-user`.`author-id`
STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = `post-user`.`owner-id`
@ -763,7 +763,7 @@
"contact-type" => ["ownercontact", "contact-type"],
],
"query" => "FROM `post-user`
STRAIGHT_JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
INNER JOIN `post-thread-user` ON `post-thread-user`.`uri-id` = `post-user`.`parent-uri-id` AND `post-thread-user`.`uid` = `post-user`.`uid`
INNER JOIN `contact` ON `contact`.`id` = `post-thread-user`.`contact-id`
LEFT JOIN `user-contact` AS `author` ON `author`.`uid` = `post-thread-user`.`uid` AND `author`.`cid` = `post-thread-user`.`author-id`
LEFT JOIN `user-contact` AS `owner` ON `owner`.`uid` = `post-thread-user`.`uid` AND `owner`.`cid` = `post-thread-user`.`owner-id`