From: Michael Date: Sat, 13 Oct 2018 16:41:29 +0000 (+0000) Subject: AP: Announce will now work X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3c48a1f787a6338fc1ce9ba7d7ac2a475f1dd093;p=friendica.git AP: Announce will now work --- diff --git a/index.php b/index.php index dc3dc80f60..6ab405c632 100644 --- 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); } diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 96c069e589..3fc5900afa 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -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 *