Skip to content

Commit d7ed2a8

Browse files
authored
Improve magazine matching in the AddHandler (#1403)
1 parent 7f9fef0 commit d7ed2a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/MessageHandler/ActivityPub/Inbox/AddHandler.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ private function handlePinnedAdd(Magazine $targetMag, User $actor, mixed $object
108108
throw new \LogicException("the user '$actor->username' ({$actor->getId()}) is not a moderator of $targetMag->name ({$targetMag->getId()}) and is not from the same instance. They can therefore not add pinned entries");
109109
}
110110

111+
if ('random' === $targetMag->name) {
112+
// do not pin anything in the random magazine
113+
return;
114+
}
115+
111116
$apId = null;
112117
if (\is_string($object)) {
113118
$apId = $object;
@@ -121,7 +126,9 @@ private function handlePinnedAdd(Magazine $targetMag, User $actor, mixed $object
121126
$pair = $this->apActivityRepository->findLocalByApId($apId);
122127
if (Entry::class === $pair['type']) {
123128
$existingEntry = $this->entryRepository->findOneBy(['id' => $pair['id']]);
124-
if ($existingEntry && !$existingEntry->sticky) {
129+
if ($existingEntry->magazine->getId() !== $targetMag->getId()) {
130+
$this->logger->warning('[AddHandler::handlePinnedAdd] entry {e} is not in the magazine that was targeted {m}. It was in {m2}', ['e' => $existingEntry->title, 'm' => $targetMag->name, 'm2' => $existingEntry->magazine->name]);
131+
} elseif ($existingEntry && !$existingEntry->sticky) {
125132
$this->logger->info('[AddHandler::handlePinnedAdd] Pinning entry {e} to magazine {m}', ['e' => $existingEntry->title, 'm' => $existingEntry->magazine->name]);
126133
$this->entryManager->pin($existingEntry, $actor);
127134
}

0 commit comments

Comments
 (0)