Remove related notifications when marking an item for deletion

This commit is contained in:
Hypolite Petovan 2022-11-26 21:48:26 -05:00
parent a95e93c725
commit 25e1412174
3 changed files with 29 additions and 0 deletions

View file

@ -33,6 +33,7 @@ use Friendica\Navigation\Notifications\Collection;
use Friendica\Navigation\Notifications\Entity;
use Friendica\Navigation\Notifications\Factory;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Psr\Log\LoggerInterface;
@ -268,4 +269,23 @@ class Notification extends BaseRepository
return $this->db->delete(self::$table_name, $condition);
}
public function deleteForItem(int $itemUriId): bool
{
$conditionTarget = [
'vid' => Verb::getID(Activity::POST),
'target-uri-id' => $itemUriId,
];
$conditionParent = [
'vid' => Verb::getID(Activity::POST),
'parent-uri-id' => $itemUriId,
];
$this->logger->notice('deleteForItem', ['conditionTarget' => $conditionTarget, 'conditionParent' => $conditionParent]);
return
$this->db->delete(self::$table_name, $conditionTarget)
&& $this->db->delete(self::$table_name, $conditionParent);
}
}