X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FUpdateContact.php;h=c2e443282056381cae6594c1c88d7a618e1d7e1f;hb=4139134cfd2f86ba6fec2adef37bca16ab466514;hp=fab97a927be89e8e1831dc4c94c50a815c2ecbcf;hpb=a25fd7713b0ddf0badd76e225edd881127d42a83;p=friendica.git diff --git a/src/Worker/UpdateContact.php b/src/Worker/UpdateContact.php index fab97a927b..c2e4432820 100644 --- a/src/Worker/UpdateContact.php +++ b/src/Worker/UpdateContact.php @@ -1,19 +1,71 @@ . + * */ namespace Friendica\Worker; use Friendica\Core\Logger; +use Friendica\Core\Worker; use Friendica\Model\Contact; +use Friendica\Network\HTTPException\InternalServerErrorException; +use Friendica\Util\Network; class UpdateContact { - public static function execute($contact_id) + /** + * 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 + { + if (!$contact_id) { + throw new \InvalidArgumentException('Invalid value provided for contact_id'); + } + + // Dropping the task if the contact is blocked + if (Contact::isBlocked($contact_id)) { + return 0; + } + + return Worker::add($run_parameters, 'UpdateContact', $contact_id); + } }