Merge pull request from nextcloud/fix/noid/notification-unreblog

fix notification and update details on unreblog
pull/1783/head
Maxence Lange 2023-06-14 08:48:27 -01:00 zatwierdzone przez GitHub
commit afa5732a43
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 17 dodań i 29 usunięć
lib/Interfaces/Object

Wyświetl plik

@ -136,7 +136,6 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
$activity->checkOrigin($announce->getId());
$activity->checkOrigin($announce->getActorId());
$this->undoAnnounceAction($announce);
$this->delete($announce);
}
}
@ -161,30 +160,20 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
*/
public function save(ACore $item): void {
/** @var Announce $item */
if ($item->hasActor()) {
$actor = $item->getActor();
} else {
$actor = $this->cacheActorService->getFromId($item->getActorId());
}
try {
$knownItem = $this->streamRequest->getStreamByObjectId($item->getObjectId(), Announce::TYPE);
if ($item->hasActor()) {
$actor = $item->getActor();
} else {
$actor = $this->cacheActorService->getFromId($item->getActorId());
}
$knownItem->setAttributedTo($actor->getId());
if (!$knownItem->hasCc($actor->getFollowers())) {
$knownItem->addCc($actor->getFollowers());
$this->streamRequest->update($knownItem, true);
}
try {
$post = $this->streamRequest->getStreamById($item->getObjectId(), false, ACore::FORMAT_LOCAL);
} catch (StreamNotFoundException $e) {
return; // should not happen.
}
$this->updateDetails($post);
$this->generateNotification($post, $actor);
} catch (StreamNotFoundException $e) {
$objectId = $item->getObjectId();
$item->addCacheItem($objectId);
@ -195,6 +184,15 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
$item->getRequestToken(), StreamQueue::TYPE_CACHE, $item->getId()
);
}
try {
$post = $this->streamRequest->getStreamById($item->getObjectId(), false, ACore::FORMAT_LOCAL);
} catch (StreamNotFoundException $e) {
return; // should not happen.
}
$this->updateDetails($post);
$this->generateNotification($post, $actor);
}
@ -230,6 +228,8 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
}
} catch (StreamNotFoundException|ItemUnknownException|SocialAppConfigException $e) {
}
$this->undoAnnounceAction($item);
}
public function event(ACore $item, string $source): void {
@ -246,18 +246,6 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
return;
}
//
//
//
//
//
// pourquoi update !????
// $to = $this->get('attributedTo', $cachedItem->getObject(), '');
// if ($to !== '') {
// $this->streamRequest->updateAttributedTo($item->getId(), $to);
// }
try {
if ($item->hasActor()) {
$actor = $item->getActor();
@ -279,7 +267,7 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
}
}
private function undoAnnounceAction(Announce $announce): void {
private function undoAnnounceAction(ACore $announce): void {
try {
$this->actionsRequest->getActionFromItem($announce);
$this->actionsRequest->delete($announce);