mirror of
https://github.com/friendica/friendica
synced 2025-04-25 04:30:11 +00:00
More prevention of double processing of the same content
This commit is contained in:
parent
8b698b183d
commit
87a945b295
8 changed files with 141 additions and 52 deletions
|
@ -586,11 +586,19 @@ class Receiver
|
|||
$object_data['object_activity'] = $activity;
|
||||
}
|
||||
|
||||
if (($type == 'as:Create') && Queue::exists($object_data['object_id'], $type)) {
|
||||
Logger::info('The activity is already added.', ['id' => $object_data['object_id']]);
|
||||
return true;
|
||||
}
|
||||
if (($type == 'as:Create') && $trust_source) {
|
||||
if (self::hasArrived($object_data['object_id'])) {
|
||||
Logger::info('The activity already arrived.', ['id' => $object_data['object_id']]);
|
||||
return true;
|
||||
}
|
||||
self::addArrivedId($object_data['object_id']);
|
||||
|
||||
if (Queue::exists($object_data['object_id'], $type)) {
|
||||
Logger::info('The activity is already added.', ['id' => $object_data['object_id']]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'decoupled_receiver') && ($trust_source || DI::config()->get('debug', 'ap_inbox_store_untrusted'))) {
|
||||
$object_data = Queue::add($object_data, $type, $uid, $http_signer, $push, $trust_source);
|
||||
}
|
||||
|
@ -1883,4 +1891,29 @@ class Receiver
|
|||
|
||||
return $object_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an object id to the list of arrived activities
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function addArrivedId(string $id)
|
||||
{
|
||||
DBA::delete('arrived-activity', ["`received` < ?", DateTimeFormat::utc('now - 5 minutes')]);
|
||||
DBA::insert('arrived-activity', ['object-id' => $id, 'received' => DateTimeFormat::utcNow()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given object already arrived before
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private static function hasArrived(string $id): bool
|
||||
{
|
||||
return DBA::exists('arrived-activity', ['object-id' => $id]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue