use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
+use Friendica\Worker\Delivery;
function events_init(App $a)
{
$item_id = Event::store($datarray);
if (!$cid) {
- Worker::add(PRIORITY_HIGH, "Notifier", "event", $item_id);
+ Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item_id);
}
$a->internalRedirect('events');
use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
+use Friendica\Worker\Delivery;
function fsuggest_post(App $a)
{
'photo' => $contact['avatar'], 'note' => $note, 'created' => DateTimeFormat::utcNow()];
DBA::insert('fsuggest', $fields);
- Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', DBA::lastInsertId());
+ Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::SUGGESTION, DBA::lastInsertId());
info(L10n::t('Friend suggestion sent.') . EOL);
}
$origin = $_REQUEST['origin'];
}
- $notify_type = ($toplevel_item_id ? Delivery::COMMENT : Delivery::POST);
-
$uri = ($message_id ? $message_id : Item::newURI($api_source ? $profile_uid : $uid, $guid));
// Fallback so that we alway have a parent uri
// When we are doing some forum posting via ! we have to start the notifier manually.
// These kind of posts don't initiate the notifier call in the item class.
if ($only_to_forum) {
- Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id);
+ Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post_id);
}
Logger::log('post_complete');
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
+use Friendica\Worker\Delivery;
function get_theme_config_file($theme)
{
BaseModule::checkFormSecurityTokenRedirectOnError('/settings', 'settings');
if (!empty($_POST['resend_relocate'])) {
- Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', local_user());
+ Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
info(L10n::t("Relocate message has been send to your contacts"));
$a->internalRedirect('settings');
}
use Friendica\Model\Item;
use Friendica\Util\Strings;
use Friendica\Util\XML;
+use Friendica\Worker\Delivery;
function tagger_content(App $a) {
Hook::callAll('post_local_end', $arr);
- Worker::add(PRIORITY_HIGH, "Notifier", "tag", $post_id);
+ Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $post_id);
exit();
}
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Util\Strings;
+use Friendica\Worker\Delivery;
/**
* @brief UserImport class
}
// send relocate messages
- Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', $newuid);
+ Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $newuid);
info(L10n::t("Done. You can now login with your username and password"));
$a->internalRedirect('login');
* @param (integer|array) priority or parameter array, strings are deprecated and are ignored
*
* next args are passed as $cmd command line
- * or: Worker::add(PRIORITY_HIGH, "Notifier", "drop", $drop_id);
+ * or: Worker::add(PRIORITY_HIGH, "Notifier", Delivery::DELETION, $drop_id);
* or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "CreateShadowEntry", $post_id);
*
* @return boolean "false" if proc_run couldn't be executed
// We only need to notfiy others when it is an original entry from us.
// Only call the notifier when the item has some content relevant change.
if ($item['origin'] && in_array('edited', array_keys($fields))) {
- Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $item['id']);
+ Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item['id']);
}
}
self::delete(['uri' => $item['uri'], 'deleted' => false], $priority);
// send the notification upstream/downstream
- Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", intval($item['id']));
+ Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id']));
} elseif ($item['uid'] != 0) {
// When we delete just our local user copy of an item, we have to set a marker to hide it
$item['thr-parent'] = $item['parent-uri'];
- $notify_type = '';
+ $notify_type = Delivery::POST;
$allow_cid = '';
$allow_gid = '';
$deny_cid = '';
$allow_gid = $item['allow_gid'];
$deny_cid = $item['deny_cid'];
$deny_gid = $item['deny_gid'];
- $notify_type = Delivery::POST;
} else {
// find the parent and snarf the item id and ACLs
// and anything else we need to inherit
$deny_cid = $parent['deny_cid'];
$deny_gid = $parent['deny_gid'];
$item['wall'] = $parent['wall'];
- $notify_type = Delivery::COMMENT;
/*
* If the parent is private, force privacy for the entire conversation
check_user_notification($current_post);
- if ($notify) {
+ if ($notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin']))) {
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
- } elseif ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin'])) {
- if ($item['gravity'] == GRAVITY_ACTIVITY) {
- $cmd = $item['origin'] ? Delivery::ACTIVITY : 'activity-import';
- } elseif ($item['gravity'] == GRAVITY_COMMENT) {
- $cmd = $item['origin'] ? Delivery::COMMENT : 'comment-import';
- } elseif (!empty($notify_type)) {
- $cmd = $notify_type;
- } else {
- $cmd = Delivery::POST;
- }
-
- Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $cmd, $current_post);
}
return $current_post;
self::updateThread($item_id);
- Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', 'tgroup', $item_id);
+ Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', Delivery::POST, $item_id);
}
public static function isRemoteSelf($contact, &$datarray)
use Friendica\Database\DBA;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
+use Friendica\Worker\Delivery;
/**
* Class to handle private messages
}
if ($post_id) {
- Worker::add(PRIORITY_HIGH, "Notifier", "mail", $post_id);
+ Worker::add(PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
return intval($post_id);
} else {
return -3;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings;
+use Friendica\Worker\Delivery;
use LightOpenID;
/**
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc('now + 7 day')], ['uid' => $uid]);
- Worker::add(PRIORITY_HIGH, 'Notifier', 'removeme', $uid);
+ Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
// Send an update to the directory
$self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
use Friendica\Util\BasePath;
use Friendica\Util\BaseURL;
use Friendica\Util\Strings;
+use Friendica\Worker\Delivery;
require_once __DIR__ . '/../../../boot.php';
// send relocate
$usersStmt = DBA::select('user', ['uid'], ['account_removed' => false, 'account_expired' => false]);
while ($user = DBA::fetch($usersStmt)) {
- Worker::add(PRIORITY_HIGH, 'Notifier', 'relocate', $user['uid']);
+ Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
}
info("Relocation started. Could take a while to complete.");
if ($comment['id'] == $comment['parent']) {
continue;
}
- if ($comment['verb'] == ACTIVITY_POST) {
- $cmd = $comment['self'] ? Delivery::COMMENT : 'comment-import';
- } else {
- $cmd = $comment['self'] ? Delivery::ACTIVITY : 'activity-import';
- }
- Logger::log("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, Logger::DEBUG);
- Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id);
+
+ Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $contact_id]);
+ Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['id'], $contact_id);
}
DBA::close($comments);
$data = ActivityPub\Transmitter::createCachedActivityFromItem($target_id);
if (!empty($data)) {
$success = HTTPSignature::transmit($data, $inbox, $uid);
- if ($success && in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
+ if ($success && in_array($cmd, [Delivery::POST])) {
ItemDeliveryData::incrementQueueDone($target_id);
}
}
const DELETION = 'drop';
const POST = 'wall-new';
const POKE = 'poke';
- const COMMENT = 'comment-new';
- const ACTIVITY = 'activity-new';
+ const UPLINK = 'uplink';
const REMOVAL = 'removeme';
const PROFILEUPDATE = 'profileupdate';
// We successfully delivered a message, the contact is alive
Model\Contact::unmarkForArchival($contact);
- if (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
+ if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
Model\ItemDeliveryData::incrementQueueDone($target_item['id']);
}
} else {
// We successfully delivered a message, the contact is alive
Model\Contact::unmarkForArchival($contact);
- if (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
+ if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
Model\ItemDeliveryData::incrementQueueDone($target_item['id']);
}
} else {
Logger::info('Delivery failed: defer message', ['id' => defaults($target_item, 'guid', $target_item['id'])]);
// defer message for redelivery
Worker::defer();
- } elseif (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
+ } elseif (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
Model\ItemDeliveryData::incrementQueueDone($target_item['id']);
}
}
return;
}
- if (!in_array($cmd, [self::POST, self::COMMENT])) {
+ if (!in_array($cmd, [self::POST, self::POKE])) {
return;
}
*
* Worker::add(PRIORITY_HIGH, "Notifier", COMMAND, ITEM_ID);
*
- * where COMMAND is one of the following:
- *
- * activity (in diaspora.php, dfrn_confirm.php, profiles.php)
- * comment-import (in diaspora.php, items.php)
- * comment-new (in item.php)
- * drop (in diaspora.php, items.php, photos.php)
- * edit_post (in item.php)
- * event (in events.php)
- * like (in like.php, poke.php)
- * mail (in message.php)
- * suggest (in fsuggest.php)
- * tag (in photos.php, poke.php, tagger.php)
- * tgroup (in items.php)
- * wall-new (in photos.php, item.php)
- * removeme (in Contact.php)
- * relocate (in uimport.php)
- *
+ * where COMMAND is one of the constants that are defined in Worker/Delivery.php
* and ITEM_ID is the id of the item in the database that needs to be sent to others.
*/
}
- if (($cmd === 'uplink') && (intval($parent['forum_mode']) == 1) && !$top_level) {
+ if (($cmd === Delivery::UPLINK) && (intval($parent['forum_mode']) == 1) && !$top_level) {
$relay_to_owner = true;
}
// if our parent is a public forum (forum_mode == 1), uplink to the origional author causing
// a delivery fork. private groups (forum_mode == 2) do not uplink
- if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== 'uplink')) {
- Worker::add($a->queue['priority'], 'Notifier', 'uplink', $target_id);
+ if ((intval($parent['forum_mode']) == 1) && !$top_level && ($cmd !== Delivery::UPLINK)) {
+ Worker::add($a->queue['priority'], 'Notifier', Delivery::UPLINK, $target_id);
}
foreach ($items as $item) {
if (!empty($target_item)) {
Logger::log('Calling hooks for ' . $cmd . ' ' . $target_id, Logger::DEBUG);
- if (in_array($cmd, [Delivery::POST, Delivery::COMMENT])) {
+ if (in_array($cmd, [Delivery::POST, Delivery::POKE])) {
ItemDeliveryData::update($target_item['id'], ['queue_count' => $delivery_queue_count]);
}
continue;
}
- if ($item['gravity'] == GRAVITY_PARENT) {
- $cmd = Delivery::POST;
- } else {
- $cmd = Delivery::COMMENT;
- }
-
$deliver_options = ['priority' => PRIORITY_MEDIUM, 'dont_fork' => true];
- Worker::add($deliver_options, 'Delivery', $cmd, $item['id'], $entry['cid']);
+ Worker::add($deliver_options, 'Delivery', Delivery::POST, $item['id'], $entry['cid']);
Logger::info('Added delivery worker', ['command' => $cmd, 'item' => $item['id'], 'contact' => $entry['cid']]);
DBA::delete('queue', ['id' => $entry['id']]);
}