parent
84d3eecc33
commit
a49fb9cbf9
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user