diff --git a/src/Worker/ProfileUpdate.php b/src/Worker/ProfileUpdate.php index ba15436d84..e26abf7e20 100644 --- a/src/Worker/ProfileUpdate.php +++ b/src/Worker/ProfileUpdate.php @@ -31,7 +31,14 @@ use Friendica\Protocol\ActivityPub; * Send updated profile data to Diaspora and ActivityPub */ class ProfileUpdate { - public static function execute($uid = 0) { + /** + * Sends updated profile data to Diaspora and ActivityPub + * + * @param int $uid User id (optional, default: 0) + * @return void + */ + public static function execute(int $uid = 0) + { if (empty($uid)) { return; } @@ -43,7 +50,13 @@ class ProfileUpdate { foreach ($inboxes as $inbox => $receivers) { Logger::info('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub'); Worker::add(['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true], - 'APDelivery', Delivery::PROFILEUPDATE, 0, $inbox, $uid, $receivers); + 'APDelivery', + Delivery::PROFILEUPDATE, + 0, + $inbox, + $uid, + $receivers + ); } Diaspora::sendProfile($uid); diff --git a/src/Worker/PubSubPublish.php b/src/Worker/PubSubPublish.php index e84ac3152e..1bfc3657ae 100644 --- a/src/Worker/PubSubPublish.php +++ b/src/Worker/PubSubPublish.php @@ -29,7 +29,13 @@ use Friendica\Protocol\OStatus; class PubSubPublish { - public static function execute($pubsubpublish_id = 0) + /** + * Publishes subscriber id + * + * @param int $pubsubpublish_id Push subscriber id + * @return void + */ + public static function execute(int $pubsubpublish_id = 0) { if ($pubsubpublish_id == 0) { return; @@ -38,7 +44,13 @@ class PubSubPublish self::publish($pubsubpublish_id); } - private static function publish($id) + /** + * Publishes push subscriber + * + * @param int $id Push subscriber id + * @return void + */ + private static function publish(int $id) { $subscriber = DBA::selectFirst('push_subscriber', [], ['id' => $id]); if (!DBA::isResult($subscriber)) { @@ -48,7 +60,7 @@ class PubSubPublish /// @todo Check server status with GServer::check() // Before this can be done we need a way to safely detect the server url. - Logger::info("Generate feed of user " . $subscriber['nickname']. " to " . $subscriber['callback_url']. " - last updated " . $subscriber['last_update']); + Logger::info('Generate feed of user ' . $subscriber['nickname'] . ' to ' . $subscriber['callback_url'] . ' - last updated ' . $subscriber['last_update']); $last_update = $subscriber['last_update']; $params = OStatus::feed($subscriber['nickname'], $last_update); @@ -57,11 +69,11 @@ class PubSubPublish return; } - $hmac_sig = hash_hmac("sha1", $params, $subscriber['secret']); + $hmac_sig = hash_hmac('sha1', $params, $subscriber['secret']); $headers = [ 'Content-type' => 'application/atom+xml', - 'Link' => sprintf("<%s>;rel=hub,<%s>;rel=self", + 'Link' => sprintf('<%s>;rel=hub,<%s>;rel=self', DI::baseUrl() . '/pubsubhubbub/' . $subscriber['nickname'], $subscriber['topic']), 'X-Hub-Signature' => 'sha1=' . $hmac_sig]; diff --git a/src/Worker/PushSubscription.php b/src/Worker/PushSubscription.php index 45ecb62291..48695bfcd0 100644 --- a/src/Worker/PushSubscription.php +++ b/src/Worker/PushSubscription.php @@ -37,6 +37,13 @@ use Minishlink\WebPush\Subscription; class PushSubscription { + /** + * Creates push subscription by subscription and notification ids + * + * @param int $sid Subscription id + * @param int $nid Notification id + * @return void + */ public static function execute(int $sid, int $nid) { Logger::info('Start', ['subscription' => $sid, 'notification' => $nid]); @@ -48,7 +55,7 @@ class PushSubscription } try { - $Notification = DI::notification()->selectOneById($nid); + $notification = DI::notification()->selectOneById($nid); } catch (NotFoundException $e) { Logger::info('Notification not found', ['notification' => $nid]); return; @@ -60,7 +67,7 @@ class PushSubscription return; } - $user = User::getById($Notification->uid); + $user = User::getById($notification->uid); if (empty($user)) { Logger::info('User not found', ['application' => $subscription['uid']]); return; @@ -68,21 +75,21 @@ class PushSubscription $l10n = DI::l10n()->withLang($user['language']); - if ($Notification->actorId) { - $actor = Contact::getById($Notification->actorId); + if ($notification->actorId) { + $actor = Contact::getById($notification->actorId); } $body = ''; - if ($Notification->targetUriId) { - $post = Post::selectFirst([], ['uri-id' => $Notification->targetUriId, 'uid' => [0, $Notification->uid]]); + if ($notification->targetUriId) { + $post = Post::selectFirst([], ['uri-id' => $notification->targetUriId, 'uid' => [0, $notification->uid]]); if (!empty($post['body'])) { $body = BBCode::toPlaintext($post['body'], false); - $body = Plaintext::shorten($body, 160, $Notification->uid); + $body = Plaintext::shorten($body, 160, $notification->uid); } } - $message = DI::notificationFactory()->getMessageFromNotification($Notification); + $message = DI::notificationFactory()->getMessageFromNotification($notification); $title = $message['plain'] ?: ''; $push = Subscription::create([ @@ -94,11 +101,12 @@ class PushSubscription ], ]); + // @todo Only used for logging? $payload = [ 'access_token' => $application_token['access_token'], 'preferred_locale' => $user['language'], 'notification_id' => $nid, - 'notification_type' => \Friendica\Factory\Api\Mastodon\Notification::getType($Notification), + 'notification_type' => \Friendica\Factory\Api\Mastodon\Notification::getType($notification), 'icon' => $actor['thumb'] ?? '', 'title' => $title ?: $l10n->t('Notification from Friendica'), 'body' => $body ?: $l10n->t('Empty Post'), diff --git a/src/Worker/RemoveUser.php b/src/Worker/RemoveUser.php index e209aec07f..6a2d54422e 100644 --- a/src/Worker/RemoveUser.php +++ b/src/Worker/RemoveUser.php @@ -29,7 +29,13 @@ use Friendica\Model\Post; * Removes orphaned data from deleted users */ class RemoveUser { - public static function execute($uid) + /** + * Removes user by id + * + * @param int $uid User id + * @return void + */ + public static function execute(int $uid) { // Only delete if the user is archived $condition = ['account_removed' => true, 'uid' => $uid]; diff --git a/src/Worker/UpdateContact.php b/src/Worker/UpdateContact.php index edabaf163c..8de3629caf 100644 --- a/src/Worker/UpdateContact.php +++ b/src/Worker/UpdateContact.php @@ -28,9 +28,11 @@ class UpdateContact { /** * Update contact data via probe + * * @param int $contact_id Contact ID + * @return void */ - public static function execute($contact_id) + public static function execute(int $contact_id) { $success = Contact::updateFromProbe($contact_id); diff --git a/src/Worker/UpdateContacts.php b/src/Worker/UpdateContacts.php index 2beb890918..9dc0bacca7 100644 --- a/src/Worker/UpdateContacts.php +++ b/src/Worker/UpdateContacts.php @@ -102,7 +102,7 @@ class UpdateContacts * @param array $ids * @return array contact ids */ - private static function getContactsToUpdate(array $condition, int $limit, array $ids = []) + private static function getContactsToUpdate(array $condition, int $limit, array $ids = []): array { $contacts = DBA::select('contact', ['id'], $condition, ['limit' => $limit]); while ($contact = DBA::fetch($contacts)) { diff --git a/src/Worker/UpdateGServer.php b/src/Worker/UpdateGServer.php index 1085c467c7..d180f34c45 100644 --- a/src/Worker/UpdateGServer.php +++ b/src/Worker/UpdateGServer.php @@ -30,8 +30,10 @@ class UpdateGServer { /** * Update the given server + * * @param string $server_url Server URL * @param boolean $only_nodeinfo Only use nodeinfo for server detection + * @return void */ public static function execute(string $server_url, bool $only_nodeinfo = false) { diff --git a/src/Worker/UpdateServerPeers.php b/src/Worker/UpdateServerPeers.php index 98ae88a97b..09c88499ec 100644 --- a/src/Worker/UpdateServerPeers.php +++ b/src/Worker/UpdateServerPeers.php @@ -32,7 +32,9 @@ class UpdateServerPeers { /** * Query the given server for their known peers + * * @param string $gserver Server URL + * @return void */ public static function execute(string $url) {