use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
+use Friendica\Model\Post;
use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature;
}
}
- $item = Item::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity'],
+ $item = Post::selectFirst(['id', 'uid', 'origin', 'author-link', 'changed', 'private', 'psid', 'gravity', 'deleted', 'parent-uri-id'],
['uri-id' => $itemuri['id']], ['order' => ['origin' => true]]);
if (!DBA::isResult($item)) {
}
}
- // Valid items are original post or posted from this node (including in the case of a forum)
- if (!$validated || !$item['origin'] && (parse_url($item['author-link'], PHP_URL_HOST) != parse_url(DI::baseUrl()->get(), PHP_URL_HOST))) {
+ if ($validated) {
+ // Valid items are original post or posted from this node (including in the case of a forum)
+ $validated = ($item['origin'] || (parse_url($item['author-link'], PHP_URL_HOST) == parse_url(DI::baseUrl()->get(), PHP_URL_HOST)));
+
+ if (!$validated && $item['deleted']) {
+ $validated = Post::exists(['origin' => true, 'uri-id' => $item['parent-uri-id']]);
+ }
+ }
+
+ if (!$validated) {
throw new HTTPException\NotFoundException();
}
if (empty($parameters['activity']) && ($item['gravity'] != GRAVITY_ACTIVITY)) {
$activity = ActivityPub\Transmitter::createActivityFromItem($item['id'], true);
+ if (empty($activity['type'])) {
+ throw new HTTPException\NotFoundException();
+ }
+
$activity['type'] = $activity['type'] == 'Update' ? 'Create' : $activity['type'];
// Only display "Create" activity objects here, no reshares or anything else