mirror of
https://github.com/friendica/friendica
synced 2025-04-28 11:04:22 +02:00
Delete unused media attachments
This commit is contained in:
parent
af28b82858
commit
425f23bbdc
17 changed files with 459 additions and 372 deletions
|
@ -380,14 +380,6 @@ class Item
|
|||
Event::delete($item['event-id']);
|
||||
}
|
||||
|
||||
// If item has attachments, drop them
|
||||
$attachments = Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT]);
|
||||
foreach ($attachments as $attachment) {
|
||||
if (preg_match('|attach/(\d+)|', $attachment['url'], $matches)) {
|
||||
Attach::delete(['id' => $matches[1], 'uid' => $item['uid']]);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the item to "deleted"
|
||||
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
||||
Post::update($item_fields, ['id' => $item['id']]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue