]> git.mxchange.org Git - friendica.git/commitdiff
New constant for federated protocols
authorMichael <heluecht@pirati.ca>
Mon, 1 Jul 2019 18:00:55 +0000 (18:00 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 1 Jul 2019 18:00:55 +0000 (18:00 +0000)
14 files changed:
include/conversation.php
mod/crepair.php
mod/item.php
src/Content/ContactSelector.php
src/Content/Widget/ContactBlock.php
src/Core/Protocol.php
src/Core/Search.php
src/Model/Contact.php
src/Model/Item.php
src/Model/Profile.php
src/Module/Contact.php
src/Protocol/ActivityPub/Receiver.php
src/Protocol/ActivityPub/Transmitter.php
src/Worker/UpdateGContact.php

index 3b3c7a4c185c5a3e7bb9f2c3672f79988afe8187..a2927f9bfaf68dfb766a330a2ffea9f1494bc837 100644 (file)
@@ -584,7 +584,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                if (in_array($mode, ['community', 'contacts'])) {
                        $writable = true;
                } else {
-                       $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
+                       $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
                }
 
                if (!local_user()) {
@@ -872,7 +872,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
 
        foreach ($items as $index => $item) {
                if ($item['uid'] == 0) {
-                       $items[$index]['writable'] = in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
+                       $items[$index]['writable'] = in_array($item['network'], Protocol::FEDERATED);
                }
        }
 
@@ -931,7 +931,7 @@ function item_photo_menu($item) {
                $contact_url = 'contact/' . $cid;
                $posts_link = 'contact/' . $cid . '/posts';
 
-               if (in_array($network, [Protocol::DFRN, Protocol::DIASPORA])) {
+               if (in_array($network, [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
                        $pm_url = 'message/new/' . $cid;
                }
        }
@@ -954,7 +954,7 @@ function item_photo_menu($item) {
                }
 
                if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
-                       in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
+                       in_array($item['network'], Protocol::FEDERATED)) {
                        $menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
                }
        } else {
index 7e10b2ff2b6955923b4587c5f82ac670d7a46a88..ce27b44982a26a295dd68d75ea2bdaa76b339b02 100644 (file)
@@ -132,7 +132,7 @@ function crepair_content(App $a)
                $remote_self_options = ['0' => L10n::t('No mirroring'), '2' => L10n::t('Mirror as my own posting')];
        }
 
-       $update_profile = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]);
+       $update_profile = in_array($contact['network'], Protocol::FEDERATED);
 
        $tab_str = Module\Contact::getTabsHTML($a, $contact, 5);
 
index 20dc9dfdae892a94a22da257dff8f9b235d28f60..fff4f712c3bea2a4387aaa77e8f00c72a4bcb988 100644 (file)
@@ -163,7 +163,7 @@ function item_post(App $a) {
        }
 
        // Allow commenting if it is an answer to a public post
-       $allow_comment = local_user() && ($profile_uid == 0) && $toplevel_item_id && in_array($toplevel_item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
+       $allow_comment = local_user() && ($profile_uid == 0) && $toplevel_item_id && in_array($toplevel_item['network'], Protocol::FEDERATED);
 
        // Now check that valid personal details have been provided
        if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
index e327069b33fd86653bad93e0b9a661c1c3a1bcc3..22bfe08b52a048b1bec846770df9d4b4ff51d2f1 100644 (file)
@@ -105,7 +105,7 @@ class ContactSelector
 
                $networkname = str_replace($search, $replace, $network);
 
-               if ((in_array($network, [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
+               if ((in_array($network, Protocol::FEDERATED)) && ($profile != "")) {
                        // Create the server url out of the profile url
                        $parts = parse_url($profile);
                        unset($parts['path']);
index bc33b9c9c928672a24de0d9712bf0a52562a0c73..ef152f900846fbfcaa7061475eb37499a29e94cc 100644 (file)
@@ -75,7 +75,7 @@ class ContactBlock
                                'hidden' => false,
                                'archive' => false,
                                'rel' => $rel,
-                               'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA],
+                               'network' => Protocol::FEDERATED,
                        ], ['limit' => $shown]);
 
                        if (DBA::isResult($contact_ids_stmt)) {
index 0038b505a570b4f73f3cb48837a8cf049698b784..759a6e70e66160c78f45258e09c90d8bec3af857 100644 (file)
@@ -23,6 +23,8 @@ class Protocol
 
        const NATIVE_SUPPORT = [self::DFRN, self::DIASPORA, self::OSTATUS, self::FEED, self::MAIL, self::ACTIVITYPUB];
 
+       const FEDERATED = [self::DFRN, self::DIASPORA, self::OSTATUS, self::ACTIVITYPUB];
+
        // Supported through a connector
        const DIASPORA2 = 'dspc';    // Diaspora connector
        const LINKEDIN  = 'lnkd';    // LinkedIn
index e26cc0edc3a55792b682ad397cac11e4d87fafb7..9f8375da12f66e539a25d1da0954a3c14b34ca1a 100644 (file)
@@ -49,7 +49,7 @@ class Search extends BaseObject
                                return $emptyResultList;
                        }
 
-                       if (!(in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]))) {
+                       if (!(in_array($user_data["network"], Protocol::FEDERATED))) {
                                return $emptyResultList;
                        }
 
index f38c69ed05f909ac3a6cb3504e22a8f42f106ed2..84cdbbc828e16654116102cbfd21822d440b7854 100644 (file)
@@ -963,7 +963,7 @@ class Contact extends BaseObject
                }
 
                if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
-                       && in_array($profile["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])
+                       && in_array($profile["network"], Protocol::FEDERATED)
                ) {
                        Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]);
                }
@@ -1587,7 +1587,7 @@ class Contact extends BaseObject
                        return '';
                }
 
-               if (in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
+               if (in_array($contact["network"], array_merge(Protocol::FEDERATED ,['']))) {
                        $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))";
                } else {
                        $sql = "`item`.`uid` = ?";
@@ -1779,8 +1779,7 @@ class Contact extends BaseObject
                        self::markForArchival($contact);
                }
 
-               $condition = ['self' => false, 'nurl' => Strings::normaliseLink($url),
-                       'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
+               $condition = ['self' => false, 'nurl' => Strings::normaliseLink($url), 'network' => Protocol::FEDERATED];
 
                // These contacts are sharing with us, we don't poll them.
                // This means that we don't set the update fields in "OnePoll.php".
@@ -1878,7 +1877,8 @@ class Contact extends BaseObject
                self::updateContact($id, $uid, $ret['url'], $ret);
 
                // Update the corresponding gcontact entry
-               PortableContact::lastUpdated($ret["url"]);
+//             PortableContact::lastUpdated($ret["url"]);
+               GContact::updateFromProbe($ret['url']);
 
                return true;
        }
index 3244053ba0b4d8193b1b6f98fe66a9a2d4f80536..69d9c188563d9b70202a1ed152eaa0a96640733c 100644 (file)
@@ -177,7 +177,7 @@ class Item extends BaseObject
 
                // We can always comment on posts from these networks
                if (array_key_exists('writable', $row) &&
-                       in_array($row['internal-network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+                       in_array($row['internal-network'], Protocol::FEDERATED)) {
                        $row['writable'] = true;
                }
 
@@ -1354,7 +1354,7 @@ class Item extends BaseObject
                 * We have to check several networks since Friendica posts could be repeated
                 * via OStatus (maybe Diasporsa as well)
                 */
-               if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS, ""])) {
+               if (in_array($item['network'], array_merge(Protocol::FEDERATED ,['']))) {
                        $condition = ["`uri` = ? AND `uid` = ? AND `network` IN (?, ?, ?)",
                                trim($item['uri']), $item['uid'],
                                Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS];
@@ -2077,7 +2077,7 @@ class Item extends BaseObject
 
                // Only distribute public items from native networks
                $condition = ['id' => $itemid, 'uid' => 0,
-                       'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
+                       'network' => array_merge(Protocol::FEDERATED ,['']),
                        'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
                $item = self::selectFirst(self::ITEM_FIELDLIST, $condition);
                if (!DBA::isResult($item)) {
@@ -2233,7 +2233,7 @@ class Item extends BaseObject
                }
 
                // is it an entry from a connector? Only add an entry for natively connected networks
-               if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
+               if (!in_array($item["network"], array_merge(Protocol::FEDERATED ,['']))) {
                        return;
                }
 
index 62d56798fc85257f7c266552b3e3737ba0823ea6..10bd3a1d7542843aaad239c512c4e892bba45b80 100644 (file)
@@ -471,7 +471,7 @@ class Profile
                                        'pending' => false,
                                        'hidden' => false,
                                        'archive' => false,
-                                       'network' => [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA],
+                                       'network' => Protocol::FEDERATED,
                                ]);
                        }
                }
index feae601fddf0acc9a97dcff4e9f1abe79400020a..dfa0b0659c097493ae7c88521b12e4d7ada9d406 100644 (file)
@@ -521,7 +521,7 @@ class Contact extends BaseModule
                                $relation_text = '';
                        }
 
-                       if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
+                       if (!in_array($contact['network'], Protocol::FEDERATED)) {
                                $relation_text = '';
                        }
 
@@ -968,7 +968,7 @@ class Contact extends BaseModule
 
                        $profiledata = Model\Contact::getDetailsByURL($contact['url']);
 
-                       if (local_user() && in_array($profiledata['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+                       if (local_user() && in_array($profiledata['network'], Protocol::FEDERATED)) {
                                $profiledata['remoteconnect'] = System::baseUrl() . '/follow?url=' . urlencode($profiledata['url']);
                        }
 
index 1d425600d81b76ded4dda6f4819c1690e60e2751..a8b5a18db10136a78c01ad15961b479ae3b5f508 100644 (file)
@@ -556,7 +556,7 @@ class Receiver
                                // Check if the potential receiver is following the actor
                                // Exception: The receiver is targetted via "to" or this is a comment
                                if ((($element != 'as:to') && empty($replyto)) || ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
-                                       $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+                                       $networks = Protocol::FEDERATED;
                                        $condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
                                                'network' => $networks, 'archive' => false, 'pending' => false, 'uid' => $contact['uid']];
 
@@ -591,7 +591,7 @@ class Receiver
        public static function getReceiverForActor($actor, $tags)
        {
                $receivers = [];
-               $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+               $networks = Protocol::FEDERATED;
                $condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
                        'network' => $networks, 'archive' => false, 'pending' => false];
                $contacts = DBA::select('contact', ['uid', 'rel'], $condition);
index a3b8b679e3b9d0350fe6704880a49ea43992ab23..1d5192d93be6bb2286738b6ae6ead3a3d202d01c 100644 (file)
@@ -358,7 +358,7 @@ class Transmitter
 
                if (Config::get('debug', 'total_ap_delivery')) {
                        // Will be activated in a later step
-                       $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+                       $networks = Protocol::FEDERATED;
                } else {
                        // For now only send to these contacts:
                        $networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
@@ -530,7 +530,7 @@ class Transmitter
 
                if (Config::get('debug', 'total_ap_delivery')) {
                        // Will be activated in a later step
-                       $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
+                       $networks = Protocol::FEDERATED;
                } else {
                        // For now only send to these contacts:
                        $networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
index b927e61bbd2718c1d251e8dce9dff5734783bf22..dd344baf918f9485470cd466ec1d4f4ad5a8d132 100644 (file)
@@ -31,13 +31,13 @@ class UpdateGContact
                        return;
                }
 
-               if (!in_array($r[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+               if (!in_array($r[0]["network"], Protocol::FEDERATED)) {
                        return;
                }
 
                $data = Probe::uri($r[0]["url"]);
 
-               if (!in_array($data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+               if (!in_array($data["network"], Protocol::FEDERATED)) {
                        if ($r[0]["server_url"] != "") {
                                PortableContact::checkServer($r[0]["server_url"], $r[0]["network"]);
                        }