AP: Announce will now work

This commit is contained in:
Michael 2018-10-13 16:41:29 +00:00
parent 6b2a12319c
commit 3c48a1f787
2 changed files with 27 additions and 4 deletions

View File

@ -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);
}

View 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
*