Use reshare with Diaspora like with ActivityPub

This commit is contained in:
Michael 2022-12-13 23:19:19 +00:00
parent ed805d1af2
commit ca8a89ed1c
11 changed files with 108 additions and 84 deletions

View file

@ -46,17 +46,26 @@ class Activity extends BaseModule
throw new HTTPException\BadRequestException();
}
$verb = $this->parameters['verb'];
$itemId = $this->parameters['id'];
$verb = $this->parameters['verb'];
$itemId = $this->parameters['id'];
$handled = false;
if (in_array($verb, ['announce', 'unannounce'])) {
$item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [DI::userSession()->getLocalUserId(), 0]]);
if ($item['network'] == Protocol::DIASPORA) {
Diaspora::performReshare($item['uri-id'], DI::userSession()->getLocalUserId());
$quote = Post::selectFirst(['id'], ['quote-uri-id' => $item['uri-id'], 'origin' => true, 'uid' => DI::userSession()->getLocalUserId()]);
if (!empty($quote['id'])) {
if (!Item::markForDeletionById($quote['id'])) {
throw new HTTPException\BadRequestException();
}
} else {
Diaspora::performReshare($item['uri-id'], DI::userSession()->getLocalUserId());
}
$handled = true;
}
}
if (!Item::performActivity($itemId, $verb, DI::userSession()->getLocalUserId())) {
if (!$handled && !Item::performActivity($itemId, $verb, DI::userSession()->getLocalUserId())) {
throw new HTTPException\BadRequestException();
}