Queue::remove($activity);
if (Queue::hasChildren($item['uri'])) {
- //Queue::processReplyByUri($item['uri']);
Worker::add(PRIORITY_HIGH, 'ProcessReplyByUri', $item['uri']);
}
}
* Process the activity with the given id
*
* @param integer $id
- * @return void
+ *
+ * @return bool
*/
- public static function process(int $id)
+ public static function process(int $id): bool
{
$entry = DBA::selectFirst('inbox-entry', [], ['id' => $id]);
if (empty($entry)) {
- return;
+ return false;
}
Logger::debug('Processing queue entry', ['id' => $entry['id'], 'type' => $entry['type'], 'object-type' => $entry['object-type'], 'uri' => $entry['object-id'], 'in-reply-to' => $entry['in-reply-to-id']]);
if (!Receiver::routeActivities($activity, $type, $push)) {
self::remove($activity);
}
+
+ return true;
}
/**
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
+use Friendica\Core\Worker;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\APContact;
use Friendica\Model\User;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
+use Friendica\Util\DateTimeFormat;
use Friendica\Util\HTTPSignature;
use Friendica\Util\JsonLD;
use Friendica\Util\LDSignature;
return;
}
+ if ($push) {
+ // We delay by 5 seconds to allow to accumulate all receivers
+ $delayed = date(DateTimeFormat::MYSQL, time() + 5);
+ Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'ProcessQueue', $object_data['entry-id']);
+ return;
+ }
+
if (!empty($activity['recursion-depth'])) {
$object_data['recursion-depth'] = $activity['recursion-depth'];
}
--- /dev/null
+<?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 ProcessQueue
+{
+ /**
+ * Process queue entry
+ *
+ * @param int $id queue id
+ *
+ * @return void
+ */
+ public static function execute(int $id)
+ {
+ Logger::info('Start processing queue entry', ['id' => $id]);
+ $result = Queue::process($id);
+ Logger::info('Successfully processed queue entry', ['result' => $result, 'id' => $id]);
+ }
+}