Merge pull request #9368 from annando/update-commented

Update the "commented" field only on several verbs
This commit is contained in:
Hypolite Petovan 2020-10-05 16:12:30 -04:00 committed by GitHub
commit 860a25eb38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1828,8 +1828,6 @@ class Item
$notify_type = Delivery::POST; $notify_type = Delivery::POST;
} }
$like_no_comment = DI::config()->get('system', 'like_no_comment');
DBA::transaction(); DBA::transaction();
if (!in_array($item['verb'], self::ACTIVITIES)) { if (!in_array($item['verb'], self::ACTIVITIES)) {
@ -1842,6 +1840,7 @@ class Item
} }
$body = $item['body']; $body = $item['body'];
$verb = $item['verb'];
// We just remove everything that is content // We just remove everything that is content
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) { foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
@ -1940,8 +1939,15 @@ class Item
$item['parent'] = $parent_id; $item['parent'] = $parent_id;
// update the commented timestamp on the parent // update the commented timestamp on the parent
// Only update "commented" if it is really a comment if (DI::config()->get('system', 'like_no_comment')) {
if (($item['gravity'] != GRAVITY_ACTIVITY) || !$like_no_comment) { // Update when it is a comment
$update_commented = in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]);
} else {
// Update when it isn't a follow or tag verb
$update_commented = !in_array($verb, [Activity::FOLLOW, Activity::TAG]);
}
if ($update_commented) {
DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
} else { } else {
DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]); DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);