summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2023-06-14 08:48:27 -0100
committerGitHub <noreply@github.com>2023-06-14 08:48:27 -0100
commitafa5732a432c51200de48ae41a698e8a74ac7f01 (patch)
tree0cd5cb76282f2659af96106d7efa374db2ce1a55
parent3cdaba38246a1a1f3b2401f2eaa8743742d93c57 (diff)
parent9212ead049e4a69ee265faa7cb439aa2c340b2fb (diff)
Merge pull request #1782 from nextcloud/fix/noid/notification-unreblog
fix notification and update details on unreblog
-rw-r--r--lib/Interfaces/Object/AnnounceInterface.php46
1 files changed, 17 insertions, 29 deletions
diff --git a/lib/Interfaces/Object/AnnounceInterface.php b/lib/Interfaces/Object/AnnounceInterface.php
index 1f18fe52..e27ad929 100644
--- a/lib/Interfaces/Object/AnnounceInterface.php
+++ b/lib/Interfaces/Object/AnnounceInterface.php
@@ -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);