* Relationship types
* @{
*/
+ const NOTHING = 0;
const FOLLOWER = 1;
const SHARING = 2;
const FRIEND = 3;
// Add internal fields
$removal = [];
if (!empty($fields)) {
- foreach (['id', 'avatar', 'updated', 'last-update', 'success_update', 'failure_update', 'network'] as $internal) {
+ foreach (['id', 'avatar', 'created', 'updated', 'last-update', 'success_update', 'failure_update', 'network'] as $internal) {
if (!in_array($internal, $fields)) {
$fields[] = $internal;
$removal[] = $internal;
}
// Update the contact in the background if needed
- $updated = max($contact['success_update'], $contact['updated'], $contact['last-update'], $contact['failure_update']);
- if ((($updated < DateTimeFormat::utc('now -7 days')) || empty($contact['avatar'])) &&
- in_array($contact['network'], Protocol::FEDERATED)) {
+ $updated = max($contact['success_update'], $contact['created'], $contact['updated'], $contact['last-update'], $contact['failure_update']);
+ if (($updated < DateTimeFormat::utc('now -7 days')) && in_array($contact['network'], Protocol::FEDERATED)) {
Worker::add(PRIORITY_LOW, "UpdateContact", $contact['id']);
}
if ($thread_mode) {
$condition = ["(`$contact_field` = ? OR (`causer-id` = ? AND `post-type` = ?)) AND `gravity` = ? AND " . $sql,
$cid, $cid, Item::PT_ANNOUNCEMENT, GRAVITY_PARENT, local_user()];
-
- $last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : '';
- if (!empty($last_received)) {
- $condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]);
- }
} else {
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
$cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
}
+ $last_received = isset($_GET['last_received']) ? DateTimeFormat::utc($_GET['last_received']) : '';
+ if (!empty($last_received)) {
+ $condition = DBA::mergeConditions($condition, ["`received` < ?", $last_received]);
+ }
+
if (DI::mode()->isMobile()) {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
$params = ['order' => ['received' => true], 'group_by' => ['uri-id'],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
- if ($thread_mode) {
- if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
- $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
- $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
- } else {
- $o = '';
- }
-
+ if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+ $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
+ $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
+ } else {
+ $o = '';
+ }
+
+ if ($thread_mode) {
$r = Item::selectForUser(local_user(), ['uri', 'gravity', 'parent-uri'], $condition, $params);
$items = [];
while ($item = DBA::fetch($r)) {
$items = Item::inArray($r);
- $o = conversation($a, $items, 'contact-posts', false);
+ $o .= conversation($a, $items, 'contact-posts', false);
}
if (!$update) {
- if ($thread_mode && DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
return false;
}
- if (Contact\Relation::isDiscoverable($ret['url'])) {
- Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
- }
-
if (isset($ret['hide']) && is_bool($ret['hide'])) {
$ret['unsearchable'] = $ret['hide'];
}
if (!$update) {
self::updateContact($id, $uid, $ret['url'], ['failed' => false, 'last-update' => $updated, 'success_update' => $updated]);
+ if (Contact\Relation::isDiscoverable($ret['url'])) {
+ Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
+ }
+
// Update the public contact
if ($uid != 0) {
$contact = self::getByURL($ret['url'], false, ['id']);
self::updateContact($id, $uid, $ret['url'], $ret);
+ if (Contact\Relation::isDiscoverable($ret['url'])) {
+ Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
+ }
+
return true;
}
{
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
- if (!Session::isAuthenticated() || ($contact['network'] != Protocol::DFRN)) {
+ if (!Session::isAuthenticated()) {
return $destination;
}
return $url;
}
+ if (DI::pConfig()->get(local_user(), 'system', 'stay_local') && ($url == '')) {
+ return 'contact/' . $contact['id'] . '/conversations';
+ }
+
+ if ($contact['network'] != Protocol::DFRN) {
+ return $destination;
+ }
+
if (!empty($contact['uid'])) {
return self::magicLink($contact['url'], $url);
}
{
$added = 0;
$updated = 0;
+ $unchanged = 0;
$count = 0;
foreach ($urls as $url) {
- $contact = Contact::getByURL($url, false, ['id']);
+ $contact = Contact::getByURL($url, false, ['id', 'updated']);
if (empty($contact['id'])) {
Worker::add(PRIORITY_LOW, 'AddContact', 0, $url);
++$added;
- } else {
+ } elseif ($contact['updated'] < DateTimeFormat::utc('now -7 days')) {
Worker::add(PRIORITY_LOW, 'UpdateContact', $contact['id']);
++$updated;
+ } else {
+ ++$unchanged;
}
++$count;
}
- return ['count' => $count, 'added' => $added, 'updated' => $updated];
+ return ['count' => $count, 'added' => $added, 'updated' => $updated, 'unchanged' => $unchanged];
}
/**