use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Protocol\ActivityPub;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\JsonLD;
return;
}
- $children = DBA::select('inbox-entry', ['id'], ['in-reply-to-id' => $entry['object-id']]);
- while ($child = DBA::fetch($children)) {
- self::deleteById($child['id']);
- }
- DBA::close($children);
DBA::delete('inbox-entry', ['id' => $entry['id']]);
}
* 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;
}
/**
* Process all activities that are children of a given post url
*
* @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]);
while ($entry = DBA::fetch($entries)) {
+ $count += 1;
self::process($entry['id']);
}
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]);
}
/**