mirror of
https://github.com/friendica/friendica
synced 2024-11-17 22:23:41 +00:00
New table for relations between global contacts - will replace glink in the future
This commit is contained in:
parent
10d866bad9
commit
bd77556b49
3 changed files with 39 additions and 3 deletions
12
database.sql
12
database.sql
|
@ -1,6 +1,6 @@
|
|||
-- ------------------------------------------
|
||||
-- Friendica 2020.03-dev (Dalmatian Bellflower)
|
||||
-- DB_UPDATE_VERSION 1335
|
||||
-- DB_UPDATE_VERSION 1336
|
||||
-- ------------------------------------------
|
||||
|
||||
|
||||
|
@ -419,6 +419,16 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
|
|||
INDEX `updated` (`updated`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='global contacts';
|
||||
|
||||
--
|
||||
-- TABLE gfollower
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `gfollower` (
|
||||
`gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact',
|
||||
`follower-gcid` int unsigned NOT NULL DEFAULT 0 COMMENT 'global contact of the follower',
|
||||
PRIMARY KEY(`gcid`,`follower-gcid`),
|
||||
INDEX `follower-gcid` (`follower-gcid`)
|
||||
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Followers of global contacts';
|
||||
|
||||
--
|
||||
-- TABLE glink
|
||||
--
|
||||
|
|
|
@ -1299,10 +1299,25 @@ class GContact
|
|||
}
|
||||
|
||||
if (!empty($followers) || !empty($followings)) {
|
||||
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(($url))]);
|
||||
$gcid = $gcontact['id'];
|
||||
if (!empty($followers)) {
|
||||
// Clear the follower list, since it will be recreated in the next step
|
||||
DBA::delete('gfollower', ['gcid' => $gcid]);
|
||||
}
|
||||
|
||||
$contacts = array_unique(array_merge($followers, $followings));
|
||||
Logger::info('Discover AP contacts', ['url' => $url, 'contacts' => count($contacts)]);
|
||||
foreach ($contacts as $contact) {
|
||||
if (DBA::exists('gcontact', ['nurl' => Strings::normaliseLink(($contact))])) {
|
||||
$gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => Strings::normaliseLink(($contact))]);
|
||||
if (DBA::isResult($gcontact)) {
|
||||
if (in_array($contact, $followers)) {
|
||||
$fields = ['gcid' => $gcid, 'follower-gcid' => $gcontact['id']];
|
||||
} elseif (in_array($contact, $followings)) {
|
||||
$fields = ['gcid' => $gcontact['id'], 'follower-gcid' => $gcid];
|
||||
}
|
||||
Logger::info('Set relation between contacts', $fields);
|
||||
DBA::update('gfollower', $fields, $fields, true);
|
||||
continue;
|
||||
}
|
||||
Logger::info('Discover new AP contact', ['url' => $contact]);
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1335);
|
||||
define('DB_UPDATE_VERSION', 1336);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -490,6 +490,17 @@ return [
|
|||
"updated" => ["updated"],
|
||||
]
|
||||
],
|
||||
"gfollower" => [
|
||||
"comment" => "Followers of global contacts",
|
||||
"fields" => [
|
||||
"gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["gcontact" => "id"], "comment" => "global contact"],
|
||||
"follower-gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["gcontact" => "id"], "comment" => "global contact of the follower"],
|
||||
],
|
||||
"indexes" => [
|
||||
"PRIMARY" => ["gcid", "follower-gcid"],
|
||||
"follower-gcid" => ["follower-gcid"],
|
||||
]
|
||||
],
|
||||
"glink" => [
|
||||
"comment" => "'friends of friends' linkages derived from poco",
|
||||
"fields" => [
|
||||
|
|
Loading…
Reference in a new issue