]> git.mxchange.org Git - friendica.git/commitdiff
AP: Announce will now work
authorMichael <heluecht@pirati.ca>
Sat, 13 Oct 2018 16:41:29 +0000 (16:41 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 13 Oct 2018 16:41:29 +0000 (16:41 +0000)
index.php
src/Protocol/ActivityPub/Transmitter.php

index dc3dc80f60399111c24141ce2e472c120f67702e..6ab405c632a3f092db5914db9f146f6f457b7ab1 100644 (file)
--- a/index.php
+++ b/index.php
@@ -46,7 +46,7 @@ if ($a->isMaxProcessesReached() || $a->isMaxLoadReached()) {
        System::httpExit(503, ['title' => 'Error 503 - Service Temporarily Unavailable', 'description' => 'System is currently overloaded. Please try again later.']);
 }
 
-if (strstr($a->query_string, '.well-known/host-meta') and ($a->query_string != '.well-known/host-meta')) {
+if (strstr($a->query_string, '.well-known/host-meta') && ($a->query_string != '.well-known/host-meta')) {
        System::httpExit(404);
 }
 
index 96c069e589c94d503845e77cff7dc4d44809eceb..3fc5900afa0d1b05b51a2dcd4fa323bcce15bfc9 100644 (file)
@@ -22,8 +22,11 @@ use Friendica\Model\Profile;
 use Friendica\Core\Config;
 use Friendica\Object\Image;
 use Friendica\Protocol\ActivityPub;
+use Friendica\Protocol\Diaspora;
 use Friendica\Core\Cache;
 
+require_once 'include/api.php';
+
 /**
  * @brief ActivityPub Transmitter Protocol class
  *
@@ -37,7 +40,6 @@ use Friendica\Core\Cache;
  * - Event
  *
  * Complicated object types:
- * - Announce
  * - Undo Announce
  *
  * General:
@@ -467,7 +469,9 @@ class Transmitter
         */
        private static function getTypeOfItem($item)
        {
-               if ($item['verb'] == ACTIVITY_POST) {
+               if (!empty(Diaspora::isReshare($item['body'], false))) {
+                       $type = 'Announce';
+               } elseif ($item['verb'] == ACTIVITY_POST) {
                        if ($item['created'] == $item['edited']) {
                                $type = 'Create';
                        } else {
@@ -558,8 +562,10 @@ class Transmitter
 
                $data = array_merge($data, self::createPermissionBlockForItem($item));
 
-               if (in_array($data['type'], ['Create', 'Update', 'Announce', 'Delete'])) {
+               if (in_array($data['type'], ['Create', 'Update', 'Delete'])) {
                        $data['object'] = self::createNote($item);
+               } elseif ($data['type'] == 'Announce') {
+                       $data['object'] = self::createAnnounce($item);
                } elseif ($data['type'] == 'Undo') {
                        $data['object'] = self::createActivityFromItem($item_id, true);
                } else {
@@ -805,6 +811,23 @@ class Transmitter
                return $data;
        }
 
+       /**
+        * Creates an announce object entry
+        *
+        * @param array $item
+        *
+        * @return string with announced object url
+        */
+       public static function createAnnounce($item)
+       {
+               $announce = api_share_as_retweet($item);
+               if (empty($announce['plink'])) {
+                       return self::createNote($item);
+               }
+
+               return $announce['plink'];
+       }
+
        /**
         * Transmits a contact suggestion to a given inbox
         *