From 09302367d5d4116bad9c952f392ae930600c1f73 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 Oct 2018 03:17:44 +0000 Subject: [PATCH] Include AP in the contact search --- mod/acl.php | 6 ++++-- mod/contacts.php | 24 ++++++++++++------------ mod/network.php | 2 +- src/Core/ACL.php | 6 +++--- src/Model/GContact.php | 10 +++++----- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mod/acl.php b/mod/acl.php index f9589598dd..48c45f2934 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -83,8 +83,9 @@ function acl_content(App $a) WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `success_update` >= `failure_update` - AND `network` IN ('%s', '%s') $sql_extra2", + AND `network` IN ('%s', '%s', '%s') $sql_extra2", intval(local_user()), + DBA::escape(Protocol::ACTIVITYPUB), DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA) ); @@ -169,10 +170,11 @@ function acl_content(App $a) } elseif ($type == 'm') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` - AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s') + AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s', '%s') $sql_extra2 ORDER BY `name` ASC ", intval(local_user()), + DBA::escape(Protocol::ACTIVITYPUB), DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA) ); diff --git a/mod/contacts.php b/mod/contacts.php index 8342906952..c33e9b6206 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -471,7 +471,7 @@ function contacts_content(App $a, $update = 0) _contact_drop($orig_record); info(L10n::t('Contact has been removed.') . EOL); - + goaway('contacts'); return; // NOTREACHED } @@ -544,7 +544,7 @@ function contacts_content(App $a, $update = 0) } $lblsuggest = (($contact['network'] === Protocol::DFRN) ? L10n::t('Suggest friends') : ''); - $poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]); + $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]); $nettype = L10n::t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"])); @@ -635,15 +635,15 @@ function contacts_content(App $a, $update = 0) '$follow_text' => $follow_text, '$profile_select' => $profile_select, '$contact_id' => $contact['id'], - '$block_text' => (($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block') ), - '$ignore_text' => (($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore') ), - '$insecure' => (($contact['network'] !== Protocol::DFRN && $contact['network'] !== Protocol::MAIL && $contact['network'] !== Protocol::DIASPORA) ? $insecure : ''), + '$block_text' => ($contact['blocked'] ? L10n::t('Unblock') : L10n::t('Block')), + '$ignore_text' => ($contact['readonly'] ? L10n::t('Unignore') : L10n::t('Ignore')), + '$insecure' => (in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]) ? '' : $insecure), '$info' => $contact['info'], '$cinfo' => ['info', '', $contact['info'], ''], - '$blocked' => (($contact['blocked']) ? L10n::t('Currently blocked') : ''), - '$ignored' => (($contact['readonly']) ? L10n::t('Currently ignored') : ''), - '$archived' => (($contact['archive']) ? L10n::t('Currently archived') : ''), - '$pending' => (($contact['pending']) ? L10n::t('Awaiting connection acknowledge') : ''), + '$blocked' => ($contact['blocked'] ? L10n::t('Currently blocked') : ''), + '$ignored' => ($contact['readonly'] ? L10n::t('Currently ignored') : ''), + '$archived' => ($contact['archive'] ? L10n::t('Currently archived') : ''), + '$pending' => ($contact['pending'] ? L10n::t('Awaiting connection acknowledge') : ''), '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($contact['hidden'] == 1), L10n::t('Replies/likes to your public posts may still be visible')], '$notify' => ['notify', L10n::t('Notification for new posts'), ($contact['notify_new_posts'] == 1), L10n::t('Send a notification of every new post of this contact')], '$fetch_further_information' => $fetch_further_information, @@ -1085,7 +1085,7 @@ function contact_actions($contact) } $contact_actions['block'] = [ - 'label' => (intval($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block') ), + 'label' => (intval($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block')), 'url' => 'contacts/' . $contact['id'] . '/block', 'title' => L10n::t('Toggle Blocked status'), 'sel' => (intval($contact['blocked']) ? 'active' : ''), @@ -1093,7 +1093,7 @@ function contact_actions($contact) ]; $contact_actions['ignore'] = [ - 'label' => (intval($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore') ), + 'label' => (intval($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore')), 'url' => 'contacts/' . $contact['id'] . '/ignore', 'title' => L10n::t('Toggle Ignored status'), 'sel' => (intval($contact['readonly']) ? 'active' : ''), @@ -1102,7 +1102,7 @@ function contact_actions($contact) if ($contact['uid'] != 0) { $contact_actions['archive'] = [ - 'label' => (intval($contact['archive']) ? L10n::t('Unarchive') : L10n::t('Archive') ), + 'label' => (intval($contact['archive']) ? L10n::t('Unarchive') : L10n::t('Archive')), 'url' => 'contacts/' . $contact['id'] . '/archive', 'title' => L10n::t('Toggle Archive status'), 'sel' => (intval($contact['archive']) ? 'active' : ''), diff --git a/mod/network.php b/mod/network.php index c630beb25f..58e147d1f7 100644 --- a/mod/network.php +++ b/mod/network.php @@ -810,7 +810,7 @@ function networkThreadedView(App $a, $update, $parent) } // Only show it when unfiltered (no groups, no networks, ...) - if (in_array($nets, ['', Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) { + if (in_array($nets, ['', Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) { if (DBA::isResult($r)) { $top_limit = current($r)['order_date']; $bottom_limit = end($r)['order_date']; diff --git a/src/Core/ACL.php b/src/Core/ACL.php index ffe11363f5..0b48895d65 100644 --- a/src/Core/ACL.php +++ b/src/Core/ACL.php @@ -51,14 +51,14 @@ class ACL extends BaseObject break; case 'PRIVATE': - $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; + $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; break; case 'TWO_WAY': if (!empty($a->user['prvnets'])) { - $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; + $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA]; } else { - $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS]; + $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS]; } break; diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 18d8171615..f979abef52 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -61,11 +61,11 @@ class GContact $search .= "%"; $results = DBA::p("SELECT `nurl` FROM `gcontact` - WHERE NOT `hide` AND `network` IN (?, ?, ?) AND + WHERE NOT `hide` AND `network` IN (?, ?, ?, ?) AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000", - Protocol::DFRN, $ostatus, $diaspora, $search, $search, $search + Protocol::DFRN, Protocol::ACTIVITYPUB, $ostatus, $diaspora, $search, $search, $search ); $gcontacts = []; @@ -138,7 +138,7 @@ class GContact } // Assure that there are no parameter fragments in the profile url - if (in_array($gcontact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) { + if (in_array($gcontact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) { $gcontact['url'] = self::cleanContactUrl($gcontact['url']); } @@ -214,7 +214,7 @@ class GContact throw new Exception('No name and photo for URL '.$gcontact['url']); } - if (!in_array($gcontact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) { + if (!in_array($gcontact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) { throw new Exception('No federated network ('.$gcontact['network'].') detected for URL '.$gcontact['url']); } @@ -651,7 +651,7 @@ class GContact self::fixAlternateContactAddress($contact); // Remove unwanted parts from the contact url (e.g. "?zrl=...") - if (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) { + if (in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) { $contact["url"] = self::cleanContactUrl($contact["url"]); } -- 2.39.5