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);
}
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
*
* - Event
*
* Complicated object types:
- * - Announce
* - Undo Announce
*
* General:
*/
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 {
$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 {
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
*