Issue 11776 - process replies via a worker task
This commit is contained in:
parent
3a4a76ac56
commit
3af55de978
|
@ -980,7 +980,11 @@ class Processor
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
Queue::remove($activity);
|
Queue::remove($activity);
|
||||||
Queue::processReplyByUri($item['uri']);
|
|
||||||
|
if (Queue::hasChildren($item['uri'])) {
|
||||||
|
//Queue::processReplyByUri($item['uri']);
|
||||||
|
Worker::add(PRIORITY_HIGH, 'ProcessReplyByUri', $item['uri']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store send a follow request for every reshare - but only when the item had been stored
|
// Store send a follow request for every reshare - but only when the item had been stored
|
||||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Protocol\ActivityPub;
|
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\JsonLD;
|
use Friendica\Util\JsonLD;
|
||||||
|
|
||||||
|
@ -242,15 +241,30 @@ class Queue
|
||||||
* Process all activities that are children of a given post url
|
* Process all activities that are children of a given post url
|
||||||
*
|
*
|
||||||
* @param string $uri
|
* @param string $uri
|
||||||
* @return void
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function processReplyByUri(string $uri)
|
public static function processReplyByUri(string $uri): int
|
||||||
{
|
{
|
||||||
|
$count = 0;
|
||||||
$entries = DBA::select('inbox-entry', ['id'], ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
|
$entries = DBA::select('inbox-entry', ['id'], ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
|
||||||
while ($entry = DBA::fetch($entries)) {
|
while ($entry = DBA::fetch($entries)) {
|
||||||
|
$count += 1;
|
||||||
self::process($entry['id']);
|
self::process($entry['id']);
|
||||||
}
|
}
|
||||||
DBA::close($entries);
|
DBA::close($entries);
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are children of the given uri
|
||||||
|
*
|
||||||
|
* @param string $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function hasChildren(string $uri): bool
|
||||||
|
{
|
||||||
|
return DBA::exists('inbox-entry', ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
42
src/Worker/ProcessReplyByUri.php
Normal file
42
src/Worker/ProcessReplyByUri.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
|
use Friendica\Core\Logger;
|
||||||
|
use Friendica\Protocol\ActivityPub\Queue;
|
||||||
|
|
||||||
|
class ProcessReplyByUri
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Process queued replies
|
||||||
|
*
|
||||||
|
* @param string $uri post url
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function execute(string $uri)
|
||||||
|
{
|
||||||
|
Logger::info('Start processing queued replies', ['url' => $uri]);
|
||||||
|
$count = Queue::processReplyByUri($uri);
|
||||||
|
Logger::info('Successfully processed queued replies', ['count' => $count, 'url' => $uri]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue