Merge pull request #9658 from annando/issue-9657

Issue 9657: Check the age of an item
This commit is contained in:
Hypolite Petovan 2020-12-13 22:31:10 -05:00 committed by GitHub
commit cb5362f499
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1589,6 +1589,11 @@ class Diaspora
$datarray['diaspora_signed_text'] = json_encode($data);
}
if (Item::isTooOld($datarray)) {
Logger::info('Comment is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
return false;
}
$message_id = Item::insert($datarray);
if ($message_id <= 0) {
@ -1820,6 +1825,11 @@ class Diaspora
$datarray['diaspora_signed_text'] = json_encode($data);
}
if (Item::isTooOld($datarray)) {
Logger::info('Like is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
return false;
}
$message_id = Item::insert($datarray);
if ($message_id <= 0) {
@ -1970,6 +1980,11 @@ class Diaspora
// Diaspora doesn't provide a date for a participation
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = DateTimeFormat::utcNow();
if (Item::isTooOld($datarray)) {
Logger::info('Participation is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
return false;
}
$message_id = Item::insert($datarray);
Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
@ -2365,6 +2380,11 @@ class Diaspora
$datarray['private'] = $item['private'];
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = $item['created'];
if (Item::isTooOld($datarray)) {
Logger::info('Reshare activity is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
return false;
}
$message_id = Item::insert($datarray);
if ($message_id) {
@ -2462,6 +2482,12 @@ class Diaspora
$datarray["object-type"] = $original_item["object-type"];
self::fetchGuid($datarray);
if (Item::isTooOld($datarray)) {
Logger::info('Reshare is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
return false;
}
$message_id = Item::insert($datarray);
self::sendParticipation($contact, $datarray);
@ -2758,6 +2784,12 @@ class Diaspora
}
self::fetchGuid($datarray);
if (Item::isTooOld($datarray)) {
Logger::info('Status is too old', ['created' => $datarray['created'], 'uid' => $datarray['uid'], 'guid' => $datarray['guid']]);
return false;
}
$message_id = Item::insert($datarray);
self::sendParticipation($contact, $datarray);