1
1
Fork 0

Move ContactRelation class to Contact\Relation

- Update references in GContact
This commit is contained in:
Hypolite Petovan 2020-08-03 13:10:49 -04:00
parent 24a82110fd
commit a74c547af4
6 changed files with 28 additions and 17 deletions

View file

@ -2124,7 +2124,7 @@ class Contact
return false; return false;
} }
if (ContactRelation::isDiscoverable($ret['url'])) { if (Contact\Relation::isDiscoverable($ret['url'])) {
Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']); Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
} }

View file

@ -19,7 +19,7 @@
* *
*/ */
namespace Friendica\Model; namespace Friendica\Model\Contact;
use Exception; use Exception;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -35,7 +35,7 @@ use Friendica\Util\Strings;
* This table is directional (cid = source, relation-cid = target), references public contacts (with uid=0) and records both * This table is directional (cid = source, relation-cid = target), references public contacts (with uid=0) and records both
* follows and the last interaction (likes/comments) on public posts. * follows and the last interaction (likes/comments) on public posts.
*/ */
class ContactRelation class Relation
{ {
/** /**
* No discovery of followers/followings * No discovery of followers/followings

View file

@ -24,6 +24,7 @@ namespace Friendica\Model;
use Exception; use Exception;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
/** /**
@ -48,7 +49,7 @@ class GContact
$sourceId, $sourceId,
]; ];
return ContactRelation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition); return Contact\Relation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition);
} }
/** /**
@ -71,7 +72,12 @@ LIMIT 1",
$zcid $zcid
); );
return ContactRelation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0); $condition = [
'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
$sourceId,
];
return Contact\Relation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0, $condition);
} }
/** /**
@ -97,7 +103,7 @@ LIMIT 1",
$sourceId, $sourceId,
]; ];
return ContactRelation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition, $limit, $start, $shuffle); return Contact\Relation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition, $limit, $start, $shuffle);
} }
/** /**
@ -126,7 +132,12 @@ LIMIT 1",
$zcid $zcid
); );
return ContactRelation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, [], $limit, $start, $shuffle); $condition = [
'NOT `self` AND NOT `blocked` AND NOT `hidden` AND `id` != ?',
$sourceId,
];
return Contact\Relation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, $condition, $limit, $start, $shuffle);
} }
/** /**
@ -139,7 +150,7 @@ LIMIT 1",
{ {
$cids = Contact::getPublicAndUserContacID($cid, $uid); $cids = Contact::getPublicAndUserContacID($cid, $uid);
return ContactRelation::countFollows($cids['public'] ?? 0); return Contact\Relation::countFollows($cids['public'] ?? 0);
} }
/** /**
@ -154,6 +165,6 @@ LIMIT 1",
{ {
$cids = Contact::getPublicAndUserContacID($cid, $uid); $cids = Contact::getPublicAndUserContacID($cid, $uid);
return ContactRelation::listFollows($cids['public'] ?? 0, [], $limit, $start); return Contact\Relation::listFollows($cids['public'] ?? 0, [], $limit, $start);
} }
} }

View file

@ -1554,7 +1554,7 @@ class Item
} }
// Update the contact relations // Update the contact relations
ContactRelation::store($parent['author-id'], $item['author-id'], $item['created']); Contact\Relation::store($parent['author-id'], $item['author-id'], $item['created']);
} }
return $item; return $item;

View file

@ -28,7 +28,7 @@ use Friendica\Core\Theme;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\ContactRelation; use Friendica\Model\Contact;
use Friendica\Module\BaseAdmin; use Friendica\Module\BaseAdmin;
use Friendica\Module\Register; use Friendica\Module\Register;
use Friendica\Util\BasePath; use Friendica\Util\BasePath;
@ -175,7 +175,7 @@ class Site extends BaseAdmin
$min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0); $min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0);
$optimize_max_tablesize = (!empty($_POST['optimize_max_tablesize']) ? intval(trim($_POST['optimize_max_tablesize'])) : 100); $optimize_max_tablesize = (!empty($_POST['optimize_max_tablesize']) ? intval(trim($_POST['optimize_max_tablesize'])) : 100);
$optimize_fragmentation = (!empty($_POST['optimize_fragmentation']) ? intval(trim($_POST['optimize_fragmentation'])) : 30); $optimize_fragmentation = (!empty($_POST['optimize_fragmentation']) ? intval(trim($_POST['optimize_fragmentation'])) : 30);
$contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : ContactRelation::DISCOVERY_NONE); $contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : Contact\Relation::DISCOVERY_NONE);
$synchronize_directory = (!empty($_POST['synchronize_directory']) ? intval(trim($_POST['synchronize_directory'])) : false); $synchronize_directory = (!empty($_POST['synchronize_directory']) ? intval(trim($_POST['synchronize_directory'])) : false);
$poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7); $poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
$poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : false); $poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : false);
@ -532,9 +532,9 @@ class Site extends BaseAdmin
]; ];
$discovery_choices = [ $discovery_choices = [
ContactRelation::DISCOVERY_NONE => DI::l10n()->t('none'), Contact\Relation::DISCOVERY_NONE => DI::l10n()->t('none'),
ContactRelation::DISCOVERY_LOCAL => DI::l10n()->t('Local contacts'), Contact\Relation::DISCOVERY_LOCAL => DI::l10n()->t('Local contacts'),
ContactRelation::DISCOVERY_INTERACTOR => DI::l10n()->t('Interactors'), Contact\Relation::DISCOVERY_INTERACTOR => DI::l10n()->t('Interactors'),
// "All" is deactivated until we are sure not to put too much stress on the fediverse with this // "All" is deactivated until we are sure not to put too much stress on the fediverse with this
// ContactRelation::DISCOVERY_ALL => DI::l10n()->t('All'), // ContactRelation::DISCOVERY_ALL => DI::l10n()->t('All'),
]; ];

View file

@ -21,7 +21,7 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\Model\ContactRelation; use Friendica\Model\Contact;
class ContactDiscovery class ContactDiscovery
{ {
@ -31,6 +31,6 @@ class ContactDiscovery
*/ */
public static function execute(string $url) public static function execute(string $url)
{ {
ContactRelation::discoverByUrl($url); Contact\Relation::discoverByUrl($url);
} }
} }