-- ------------------------------------------
-- Friendica 2020.03-dev (Dalmatian Bellflower)
--- DB_UPDATE_VERSION 1335
+-- DB_UPDATE_VERSION 1336
-- ------------------------------------------
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
--
}
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]);
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1335);
+ define('DB_UPDATE_VERSION', 1336);
}
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" => [