]> git.mxchange.org Git - friendica.git/commitdiff
Code cleaning / wrong table for flags
authorMichael <heluecht@pirati.ca>
Thu, 20 Sep 2018 09:50:03 +0000 (09:50 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 20 Sep 2018 09:50:03 +0000 (09:50 +0000)
src/Protocol/ActivityPub.php
src/Util/HTTPSignature.php

index bd125aaaef1d3a03dce762c29e060e3a0645b496..25ebedc8bd72f96dbed50e08fbf20fbb3a593e16 100644 (file)
@@ -103,10 +103,10 @@ class ActivityPub
         */
        public static function profile($uid)
        {
-               $accounttype = ['Person', 'Organization', 'Service', 'Group', 'Application', 'page-flags'];
+               $accounttype = ['Person', 'Organization', 'Service', 'Group', 'Application'];
                $condition = ['uid' => $uid, 'blocked' => false, 'account_expired' => false,
                        'account_removed' => false, 'verified' => true];
-               $fields = ['guid', 'nickname', 'pubkey', 'account-type'];
+               $fields = ['guid', 'nickname', 'pubkey', 'account-type', 'page-flags'];
                $user = DBA::selectFirst('user', $fields, $condition);
                if (!DBA::isResult($user)) {
                        return [];
@@ -141,7 +141,7 @@ class ActivityPub
                        'vcard:region' => $profile['region'], 'vcard:locality' => $profile['locality']];
                $data['summary'] = $contact['about'];
                $data['url'] = $contact['url'];
-               $data['manuallyApprovesFollowers'] = in_array($profile['page-flags'], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP]);
+               $data['manuallyApprovesFollowers'] = in_array($user['page-flags'], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP]);
                $data['publicKey'] = ['id' => $contact['url'] . '#main-key',
                        'owner' => $contact['url'],
                        'publicKeyPem' => $user['pubkey']];
index 911de4308e5f7eb0b371f6c277f48d88386232e8..adf5d8ad27e063f6e42676435058cc5b0446a3f4 100644 (file)
@@ -18,30 +18,6 @@ use Friendica\Database\DBA;
 
 class HTTPSignature
 {
-       /**
-        * @brief RFC5843
-        *
-        * Disabled until Friendica's ActivityPub implementation
-        * is ready.
-        *
-        * @see https://tools.ietf.org/html/rfc5843
-        *
-        * @param string  $body The value to create the digest for
-        * @param boolean $set  (optional, default true)
-        *   If set send a Digest HTTP header
-        *
-        * @return string The generated digest of $body
-        */
-//     public static function generateDigest($body, $set = true)
-//     {
-//             $digest = base64_encode(hash('sha256', $body, true));
-//
-//             if($set) {
-//                     header('Digest: SHA-256=' . $digest);
-//             }
-//             return $digest;
-//     }
-
        // See draft-cavage-http-signatures-08
        public static function verify($data, $key = '')
        {
@@ -127,12 +103,6 @@ class HTTPSignature
 
                logger('Got keyID ' . $sig_block['keyId']);
 
-               // We don't use Activity Pub at the moment.
-//             if (!$key) {
-//                     $result['signer'] = $sig_block['keyId'];
-//                     $key = self::getActivitypubKey($sig_block['keyId']);
-//             }
-
                if (!$key) {
                        return $result;
                }
@@ -171,43 +141,6 @@ class HTTPSignature
                return $result;
        }
 
-       /**
-        * Fetch the public key for Activity Pub contact.
-        *
-        * @param string|int The identifier (contact addr or contact ID).
-        * @return string|boolean The public key or false on failure.
-        */
-       private static function getActivitypubKey($id)
-       {
-               if (strpos($id, 'acct:') === 0) {
-                       $contact = DBA::selectFirst('contact', ['pubkey'], ['uid' => 0, 'addr' => str_replace('acct:', '', $id)]);
-               } else {
-                       $contact = DBA::selectFirst('contact', ['pubkey'], ['id' => $id, 'network' => 'activitypub']);
-               }
-
-               if (DBA::isResult($contact)) {
-                       return $contact['pubkey'];
-               }
-
-               if(function_exists('as_fetch')) {
-                       $r = as_fetch($id);
-               }
-
-               if ($r) {
-                       $j = json_decode($r, true);
-
-                       if (array_key_exists('publicKey', $j) && array_key_exists('publicKeyPem', $j['publicKey'])) {
-                               if ((array_key_exists('id', $j['publicKey']) && $j['publicKey']['id'] !== $id) && $j['id'] !== $id) {
-                                       return false;
-                               }
-
-                               return $j['publicKey']['publicKeyPem'];
-                       }
-               }
-
-               return false;
-       }
-
        /**
         * @brief
         *