Merge pull request #12280 from MrPetovan/bug/11804-delete-notifications-item
Remove related notifications when marking an item for deletion
This commit is contained in:
commit
b56e6f4b5b
|
@ -385,6 +385,9 @@ class Item
|
||||||
Post\ThreadUser::update($item['uri-id'], $item['uid'], ['hidden' => true]);
|
Post\ThreadUser::update($item['uri-id'], $item['uid'], ['hidden' => true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DI::notify()->deleteForItem($item['uri-id']);
|
||||||
|
DI::notification()->deleteForItem($item['uri-id']);
|
||||||
|
|
||||||
Logger::info('Item has been marked for deletion.', ['id' => $item_id]);
|
Logger::info('Item has been marked for deletion.', ['id' => $item_id]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -33,6 +33,7 @@ use Friendica\Navigation\Notifications\Collection;
|
||||||
use Friendica\Navigation\Notifications\Entity;
|
use Friendica\Navigation\Notifications\Entity;
|
||||||
use Friendica\Navigation\Notifications\Factory;
|
use Friendica\Navigation\Notifications\Factory;
|
||||||
use Friendica\Network\HTTPException\NotFoundException;
|
use Friendica\Network\HTTPException\NotFoundException;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
@ -268,4 +269,23 @@ class Notification extends BaseRepository
|
||||||
|
|
||||||
return $this->db->delete(self::$table_name, $condition);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,4 +807,10 @@ class Notify extends BaseRepository
|
||||||
|
|
||||||
return $this->storeAndSend($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $item['body'], $itemlink, true);
|
return $this->storeAndSend($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $item['body'], $itemlink, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteForItem(int $itemUriId): void
|
||||||
|
{
|
||||||
|
$this->db->delete('notify', ['otype' => 'item', 'uri-id' => $itemUriId]);
|
||||||
|
$this->db->delete('notify', ['otype' => 'item', 'parent-uri-id' => $itemUriId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user