mirror of
https://github.com/friendica/friendica
synced 2024-05-21 00:16:42 +02:00
Update counter on delete
This commit is contained in:
parent
72f5a64cf3
commit
dfc96af2cd
|
@ -338,7 +338,7 @@ class Item
|
|||
// locate item to be deleted
|
||||
$fields = [
|
||||
'id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri-id', 'origin',
|
||||
'deleted', 'resource-id', 'event-id',
|
||||
'thr-parent-id', 'deleted', 'resource-id', 'event-id', 'vid', 'body',
|
||||
'verb', 'object-type', 'object', 'target', 'contact-id', 'psid', 'gravity'
|
||||
];
|
||||
$item = Post::selectFirst($fields, ['id' => $item_id]);
|
||||
|
@ -418,6 +418,10 @@ class Item
|
|||
DI::notify()->deleteForItem($item['uri-id']);
|
||||
DI::notification()->deleteForItem($item['uri-id']);
|
||||
|
||||
if (in_array($item['gravity'], [self::GRAVITY_ACTIVITY, self::GRAVITY_COMMENT])) {
|
||||
Post\Counts::update($item['thr-parent-id'], $item['parent-uri-id'], $item['vid'], $item['verb'], $item['body']);
|
||||
}
|
||||
|
||||
Logger::info('Item has been marked for deletion.', ['id' => $item_id]);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -44,7 +44,7 @@ class Counts
|
|||
return true;
|
||||
}
|
||||
|
||||
$condition = ['thr-parent-id' => $uri_id, 'vid' => $vid];
|
||||
$condition = ['thr-parent-id' => $uri_id, 'vid' => $vid, 'deleted' => false];
|
||||
|
||||
if ($body == $verb) {
|
||||
$condition['body'] = null;
|
||||
|
@ -67,6 +67,7 @@ class Counts
|
|||
];
|
||||
|
||||
if ($fields['count'] == 0) {
|
||||
DBA::delete('post-counts', ['uri-id' => $uri_id, 'vid' => $vid, 'reaction' => $body]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue