X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FUpdateContact.php;h=c2e443282056381cae6594c1c88d7a618e1d7e1f;hb=f609e38600f54fe8465d1194008d823103f41baa;hp=f23c5c0a070ff0aa4b40345027414d77d113ce49;hpb=7b4bba66dbb122585e6c7e844d636d62b704ea38;p=friendica.git diff --git a/src/Worker/UpdateContact.php b/src/Worker/UpdateContact.php index f23c5c0a07..c2e4432820 100644 --- a/src/Worker/UpdateContact.php +++ b/src/Worker/UpdateContact.php @@ -1,24 +1,71 @@ . + * */ namespace Friendica\Worker; use Friendica\Core\Logger; +use Friendica\Core\Worker; use Friendica\Model\Contact; -use Friendica\Util\DateTimeFormat; -use Friendica\Database\DBA; +use Friendica\Network\HTTPException\InternalServerErrorException; +use Friendica\Util\Network; class UpdateContact { - public static function execute($contact_id, $command = '') + /** + * Update contact data via probe + * + * @param int $contact_id Contact ID + * @return void + * @throws InternalServerErrorException + * @throws \ImagickException + */ + public static function execute(int $contact_id) + { + // Silently dropping the task if the contact is blocked + if (Contact::isBlocked($contact_id)) { + return; + } + + $success = Contact::updateFromProbe($contact_id); + + Logger::info('Updated from probe', ['id' => $contact_id, 'success' => $success]); + } + + /** + * @param array|int $run_parameters Priority constant or array of options described in Worker::add + * @param int $contact_id + * @return int + * @throws InternalServerErrorException + */ + public static function add($run_parameters, int $contact_id): int { - $force = ($command == "force"); + if (!$contact_id) { + throw new \InvalidArgumentException('Invalid value provided for contact_id'); + } - $success = Contact::updateFromProbe($contact_id, '', $force); + // Dropping the task if the contact is blocked + if (Contact::isBlocked($contact_id)) { + return 0; + } - Logger::info('Updated from probe', ['id' => $contact_id, 'force' => $force, 'success' => $success]); + return Worker::add($run_parameters, 'UpdateContact', $contact_id); } }