* 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;
}
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);
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;
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)) {
/// @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);
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];
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]);
}
try {
- $Notification = DI::notification()->selectOneById($nid);
+ $notification = DI::notification()->selectOneById($nid);
} catch (NotFoundException $e) {
Logger::info('Notification not found', ['notification' => $nid]);
return;
return;
}
- $user = User::getById($Notification->uid);
+ $user = User::getById($notification->uid);
if (empty($user)) {
Logger::info('User not found', ['application' => $subscription['uid']]);
return;
$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([
],
]);
+ // @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'),
* 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];
{
/**
* 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);
* @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)) {
{
/**
* 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)
{
{
/**
* Query the given server for their known peers
+ *
* @param string $gserver Server URL
+ * @return void
*/
public static function execute(string $url)
{