minor hotfix for db-saving

save activity to db *before* mutating it for the target (e.g. save before transforming article into note)
This commit is contained in:
Yannis Vogel 2025-05-26 18:16:41 +02:00
parent 10dec5ebd3
commit f8539e479e
No known key found for this signature in database

View file

@ -351,6 +351,11 @@ class NewContent implements \Federator\Api\APIInterface
break; break;
case 'Article': case 'Article':
$articleId = $object->getID();
\Federator\DIO\Posts::deletePost($dbh, $articleId);
// also remove latest saved article-update
\Federator\DIO\Posts::deletePost($dbh, $articleId . '#update');
// Undo Article (remove article) // Undo Article (remove article)
$idPart = strrchr($recipient->id, '@'); $idPart = strrchr($recipient->id, '@');
if ($idPart === false) { if ($idPart === false) {
@ -366,10 +371,6 @@ class NewContent implements \Federator\Api\APIInterface
error_log("NewContent::postForUser Error in Undo Article for recipient $recipient->id, object is not an Article"); error_log("NewContent::postForUser Error in Undo Article for recipient $recipient->id, object is not an Article");
} }
} }
$articleId = $object->getID();
\Federator\DIO\Posts::deletePost($dbh, $articleId);
// also remove latest saved article-update
\Federator\DIO\Posts::deletePost($dbh, $articleId . '#update');
break; break;
} }
@ -403,6 +404,8 @@ class NewContent implements \Federator\Api\APIInterface
break; break;
case 'Article': case 'Article':
\Federator\DIO\Posts::savePost($dbh, $user->id, $newActivity);
$idPart = strrchr($recipient->id, '@'); $idPart = strrchr($recipient->id, '@');
if ($idPart === false) { if ($idPart === false) {
error_log("NewContent::postForUser Error in Create/Update Article. $recipient->id, recipient ID is not valid"); error_log("NewContent::postForUser Error in Create/Update Article. $recipient->id, recipient ID is not valid");
@ -417,7 +420,6 @@ class NewContent implements \Federator\Api\APIInterface
error_log("NewContent::postForUser Error in Create/Update Article for recipient $recipient->id, object is not an Article"); error_log("NewContent::postForUser Error in Create/Update Article for recipient $recipient->id, object is not an Article");
} }
} }
\Federator\DIO\Posts::savePost($dbh, $user->id, $newActivity);
break; break;
default: default: