class Notifier
{
- public static function execute($cmd, $target_id)
+ public static function execute(string $cmd, int $target_id)
{
$a = DI::app();
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'batch'], $condition);
} else {
// find ancestors
- $condition = ['id' => $target_id, 'visible' => true, 'moderated' => false];
- $target_item = Item::selectFirst([], $condition);
+ $condition = ['id' => $target_id, 'visible' => true];
+ $target_item = Post::selectFirst(Item::DELIVER_FIELDLIST, $condition);
if (!DBA::isResult($target_item) || !intval($target_item['parent'])) {
Logger::info('No target item', ['cmd' => $cmd, 'target' => $target_id]);
return;
}
- $condition = ['parent' => $target_item['parent'], 'visible' => true, 'moderated' => false];
+ $condition = ['parent' => $target_item['parent'], 'visible' => true];
$params = ['order' => ['id']];
- $items_stmt = Item::select([], $condition, $params);
+ $items_stmt = Post::select(Item::DELIVER_FIELDLIST, $condition, $params);
if (!DBA::isResult($items_stmt)) {
Logger::info('No item found', ['cmd' => $cmd, 'target' => $target_id]);
return;
}
- $items = Item::inArray($items_stmt);
+ $items = Post::toArray($items_stmt);
// avoid race condition with deleting entries
if ($items[0]['deleted']) {
$fields = ['network', 'author-id', 'author-link', 'author-network', 'owner-id'];
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
- $thr_parent = Item::selectFirst($fields, $condition);
+ $thr_parent = Post::selectFirst($fields, $condition);
if (empty($thr_parent)) {
$thr_parent = $parent;
}
$conversants = array_merge($contacts, $relay_list);
- $delivery_queue_count += self::delivery($cmd, $target_id, $target_item, $thr_parent, $owner, $batch_delivery, $conversants, $ap_contacts, []);
+ $delivery_queue_count += self::delivery($cmd, $target_id, $target_item, $thr_parent, $owner, $batch_delivery, true, $conversants, $ap_contacts, []);
$push_notify = true;
}
$contacts = DBA::toArray($delivery_contacts_stmt);
- $delivery_queue_count += self::delivery($cmd, $target_id, $target_item, $thr_parent, $owner, $batch_delivery, $contacts, $ap_contacts, $conversants);
+ $delivery_queue_count += self::delivery($cmd, $target_id, $target_item, $thr_parent, $owner, $batch_delivery, false, $contacts, $ap_contacts, $conversants);
$delivery_queue_count += self::deliverOStatus($target_id, $target_item, $owner, $url_recipients, $public_message, $push_notify);
* @throws InternalServerErrorException
* @throws Exception
*/
- private static function delivery(string $cmd, int $target_id, array $target_item, array $thr_parent, array $owner, bool $batch_delivery, array $contacts, array $ap_contacts, array $conversants = [])
+ private static function delivery(string $cmd, int $target_id, array $target_item, array $thr_parent, array $owner, bool $batch_delivery, bool $in_batch, array $contacts, array $ap_contacts, array $conversants = [])
{
$a = DI::app();
$delivery_queue_count = 0;
}
// Don't deliver to Diaspora if it already had been done as batch delivery
- if (($contact['network'] == Protocol::DIASPORA) && $batch_delivery) {
+ if (!$in_batch && $batch_delivery && ($contact['network'] == Protocol::DIASPORA)) {
Logger::info('Diaspora contact is already delivered via batch', ['id' => $target_id, 'contact' => $contact]);
continue;
}
continue;
}
- Logger::info('Delivery', ['target' => $target_id, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
+ Logger::info('Delivery', ['batch' => $in_batch, 'target' => $target_id, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
// Ensure that posts with our own protocol arrives before Diaspora posts arrive.
// Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
*/
public static function isForumPost(array $item)
{
- return !empty($item['forum_mode']);
+ return ($item['gravity'] == GRAVITY_PARENT) && !empty($item['forum_mode']);
}
}