Merge branch 'develop' into rewrite/gravity-constants

This commit is contained in:
Roland Häder 2022-10-18 16:34:40 +02:00 committed by GitHub
commit 26e0469de7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
181 changed files with 2408 additions and 2405 deletions

View file

@ -319,7 +319,7 @@ class Contact
// Update the contact in the background if needed
if (Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
}
// Remove the internal fields
@ -884,7 +884,7 @@ class Contact
}
// Delete it in the background
Worker::add(PRIORITY_MEDIUM, 'Contact\Remove', $id);
Worker::add(Worker::PRIORITY_MEDIUM, 'Contact\Remove', $id);
}
/**
@ -908,7 +908,7 @@ class Contact
if (in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
if (!empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
}
}
@ -938,7 +938,7 @@ class Contact
if (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND])) {
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
if (!empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
}
}
@ -966,11 +966,11 @@ class Contact
$cdata = self::getPublicAndUserContactID($contact['id'], $contact['uid']);
if (in_array($contact['rel'], [self::SHARING, self::FRIEND]) && !empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\Unfollow', $cdata['public'], $contact['uid']);
}
if (in_array($contact['rel'], [self::FOLLOWER, self::FRIEND]) && !empty($cdata['public'])) {
Worker::add(PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Contact\RevokeFollow', $cdata['public'], $contact['uid']);
}
self::remove($contact['id']);
@ -1248,7 +1248,7 @@ class Contact
$contact_id = $contact['id'];
if (Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
}
if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) {
@ -2365,7 +2365,7 @@ class Contact
return;
}
Logger::warning('account-user exists for a different contact id', ['account_user' => $account_user, 'id' => $id, 'uid' => $uid, 'uri-id' => $uri_id, 'url' => $url]);
Worker::add(PRIORITY_HIGH, 'MergeContact', $account_user['id'], $id, $uid);
Worker::add(Worker::PRIORITY_HIGH, 'MergeContact', $account_user['id'], $id, $uid);
} elseif (DBA::insert('account-user', ['id' => $id, 'uri-id' => $uri_id, 'uid' => $uid], Database::INSERT_IGNORE)) {
Logger::notice('account-user was added', ['id' => $id, 'uid' => $uid, 'uri-id' => $uri_id, 'url' => $url]);
} else {
@ -2406,7 +2406,7 @@ class Contact
continue;
}
Worker::add(PRIORITY_HIGH, 'MergeContact', $first, $duplicate['id'], $uid);
Worker::add(Worker::PRIORITY_HIGH, 'MergeContact', $first, $duplicate['id'], $uid);
}
DBA::close($duplicates);
Logger::info('Duplicates handled', ['uid' => $uid, 'nurl' => $nurl, 'callstack' => System::callstack(20)]);
@ -2608,7 +2608,7 @@ class Contact
if ($ret['network'] == Protocol::ACTIVITYPUB) {
$apcontact = APContact::getByURL($ret['url'], false);
if (!empty($apcontact['featured'])) {
Worker::add(PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
Worker::add(Worker::PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']);
}
}
@ -2649,7 +2649,7 @@ class Contact
self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => false, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $success_next_update, 'success_update' => $updated]);
if (Contact\Relation::isDiscoverable($ret['url'])) {
Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
Worker::add(Worker::PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
}
// Update the public contact
@ -2693,7 +2693,7 @@ class Contact
self::updateContact($id, $uid, $ret['uri-id'], $ret['url'], $ret);
if (Contact\Relation::isDiscoverable($ret['url'])) {
Worker::add(PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
Worker::add(Worker::PRIORITY_LOW, 'ContactDiscovery', $ret['url']);
}
return true;
@ -2853,30 +2853,30 @@ class Contact
// do we have enough information?
if (empty($protocol) || ($protocol == Protocol::PHANTOM) || (empty($ret['url']) && empty($ret['addr']))) {
$result['message'] .= DI::l10n()->t('The profile address specified does not provide adequate information.') . EOL;
$result['message'] .= DI::l10n()->t('The profile address specified does not provide adequate information.') . '<br />';
if (empty($ret['poll'])) {
$result['message'] .= DI::l10n()->t('No compatible communication protocols or feeds were discovered.') . EOL;
$result['message'] .= DI::l10n()->t('No compatible communication protocols or feeds were discovered.') . '<br />';
}
if (empty($ret['name'])) {
$result['message'] .= DI::l10n()->t('An author or name was not found.') . EOL;
$result['message'] .= DI::l10n()->t('An author or name was not found.') . '<br />';
}
if (empty($ret['url'])) {
$result['message'] .= DI::l10n()->t('No browser URL could be matched to this address.') . EOL;
$result['message'] .= DI::l10n()->t('No browser URL could be matched to this address.') . '<br />';
}
if (strpos($ret['url'], '@') !== false) {
$result['message'] .= DI::l10n()->t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
$result['message'] .= DI::l10n()->t('Use mailto: in front of address to force email check.') . EOL;
$result['message'] .= DI::l10n()->t('Unable to match @-style Identity Address with a known protocol or email contact.') . '<br />';
$result['message'] .= DI::l10n()->t('Use mailto: in front of address to force email check.') . '<br />';
}
return $result;
}
if ($protocol === Protocol::OSTATUS && DI::config()->get('system', 'ostatus_disabled')) {
$result['message'] .= DI::l10n()->t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
$result['message'] .= DI::l10n()->t('The profile address specified belongs to a network which has been disabled on this site.') . '<br />';
$ret['notify'] = '';
}
if (!$ret['notify']) {
$result['message'] .= DI::l10n()->t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
$result['message'] .= DI::l10n()->t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . '<br />';
}
$writeable = ((($protocol === Protocol::OSTATUS) && ($ret['notify'])) ? 1 : 0);
@ -2935,7 +2935,7 @@ class Contact
$contact = DBA::selectFirst('contact', [], ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
if (!DBA::isResult($contact)) {
$result['message'] .= DI::l10n()->t('Unable to retrieve contact information.') . EOL;
$result['message'] .= DI::l10n()->t('Unable to retrieve contact information.') . '<br />';
return $result;
}
@ -2949,13 +2949,13 @@ class Contact
// pull feed and consume it, which should subscribe to the hub.
if ($contact['network'] == Protocol::OSTATUS) {
Worker::add(PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
Worker::add(Worker::PRIORITY_HIGH, 'OnePoll', $contact_id, 'force');
}
if ($probed) {
self::updateFromProbeArray($contact_id, $ret);
} else {
Worker::add(PRIORITY_HIGH, 'UpdateContact', $contact_id);
Worker::add(Worker::PRIORITY_HIGH, 'UpdateContact', $contact_id);
}
$result['success'] = Protocol::follow($uid, $contact, $protocol);
@ -3407,10 +3407,10 @@ class Contact
}
$contact = self::getByURL($url, false, ['id', 'network', 'next-update']);
if (empty($contact['id']) && Network::isValidHttpUrl($url)) {
Worker::add(PRIORITY_LOW, 'AddContact', 0, $url);
Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $url);
++$added;
} elseif (!empty($contact['network']) && Probe::isProbable($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id']);
++$updated;
} else {
++$unchanged;

View file

@ -59,7 +59,7 @@ class FContact
$update = empty($person['guid']) || empty($person['uri-id']) || ($person['created'] <= DBA::NULL_DATETIME);
if (GServer::getNextUpdateDate(true, $person['created'], $person['updated'], false) < DateTimeFormat::utcNow()) {
Logger::debug('Start background update', ['handle' => $handle]);
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], 'UpdateFContact', $handle);
Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateFContact', $handle);
}
}
} elseif (is_null($update)) {

View file

@ -102,7 +102,7 @@ class GServer
return;
}
Worker::add(PRIORITY_LOW, 'UpdateGServer', $url, $only_nodeinfo);
Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $url, $only_nodeinfo);
}
/**
@ -2108,10 +2108,10 @@ class GServer
while ($gserver = DBA::fetch($gservers)) {
Logger::info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
Worker::add(PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
Worker::add(Worker::PRIORITY_LOW, 'UpdateServerPeers', $gserver['url']);
Logger::info('Update directory', ['server' => $gserver['url'], 'id' => $gserver['id']]);
Worker::add(PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
Worker::add(Worker::PRIORITY_LOW, 'UpdateServerDirectory', $gserver);
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
self::update($fields, ['nurl' => $gserver['nurl']]);

View file

@ -102,7 +102,7 @@ class Group
$group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
if (DBA::isResult($group) && $group['deleted']) {
DBA::update('group', ['deleted' => 0], ['id' => $gid]);
notice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.'));
DI::sysmsg()->addNotice(DI::l10n()->t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.'));
}
return true;
}

View file

@ -93,7 +93,7 @@ class Item
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id',
'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated',
'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
@ -115,7 +115,7 @@ class Item
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'author-id', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
'signed_text', 'network', 'wall', 'contact-id', 'plink', 'origin',
'thr-parent-id', 'parent-uri-id', 'postopts', 'pubmail',
'thr-parent-id', 'parent-uri-id', 'quote-uri', 'quote-uri-id', 'postopts', 'pubmail',
'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-ignore', 'event-id'];
@ -123,7 +123,7 @@ class Item
// All fields in the item table
const ITEM_FIELDLIST = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent',
'guid', 'uri-id', 'parent-uri-id', 'thr-parent-id', 'conversation', 'vid',
'contact-id', 'wall', 'gravity', 'extid', 'psid',
'quote-uri', 'quote-uri-id', 'contact-id', 'wall', 'gravity', 'extid', 'psid',
'created', 'edited', 'commented', 'received', 'changed', 'verb',
'postopts', 'plink', 'resource-id', 'event-id', 'inform',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', 'post-reason',
@ -238,7 +238,7 @@ class Item
foreach ($notify_items as $notify_item) {
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]);
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
}
return $rows;
@ -252,7 +252,7 @@ class Item
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function markForDeletion(array $condition, int $priority = PRIORITY_HIGH)
public static function markForDeletion(array $condition, int $priority = Worker::PRIORITY_HIGH)
{
$items = Post::select(['id'], $condition);
while ($item = Post::fetch($items)) {
@ -283,7 +283,7 @@ class Item
}
if ($item['uid'] == $uid) {
self::markForDeletionById($item['id'], PRIORITY_HIGH);
self::markForDeletionById($item['id'], Worker::PRIORITY_HIGH);
} elseif ($item['uid'] != 0) {
Logger::warning('Wrong ownership. Not deleting item', ['id' => $item['id']]);
}
@ -299,7 +299,7 @@ class Item
* @return boolean success
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function markForDeletionById(int $item_id, int $priority = PRIORITY_HIGH): bool
public static function markForDeletionById(int $item_id, int $priority = Worker::PRIORITY_HIGH): bool
{
Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
// locate item to be deleted
@ -822,7 +822,7 @@ class Item
{
$orig_item = $item;
$priority = PRIORITY_HIGH;
$priority = Worker::PRIORITY_HIGH;
// If it is a posting where users should get notifications, then define it as wall posting
if ($notify) {
@ -832,7 +832,7 @@ class Item
$item['protocol'] = Conversation::PARCEL_DIRECT;
$item['direction'] = Conversation::PUSH;
if (is_int($notify) && in_array($notify, PRIORITIES)) {
if (is_int($notify) && in_array($notify, Worker::PRIORITIES)) {
$priority = $notify;
}
} else {
@ -1125,6 +1125,13 @@ class Item
$item['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $item['raw-body']);
$item['raw-body'] = self::setHashtags($item['raw-body']);
$quote_id = self::getQuoteUriId($item['body']);
if (!empty($quote_id) && Post::exists(['uri-id' => $quote_id, 'network' => Protocol::FEDERATED])) {
$item['quote-uri-id'] = $quote_id;
$item['raw-body'] = BBCode::removeSharedData($item['raw-body']);
}
if (!DBA::exists('contact', ['id' => $item['author-id'], 'network' => Protocol::DFRN])) {
Post\Media::insertFromRelevantUrl($item['uri-id'], $item['raw-body']);
}
@ -2945,17 +2952,44 @@ class Item
$body = $item['body'] ?? '';
$shared = BBCode::fetchShareAttributes($body);
if (!empty($shared['guid'])) {
$shared_item = Post::selectFirst(['uri-id', 'plink', 'has-media'], ['guid' => $shared['guid']]);
$shared_uri_id = $shared_item['uri-id'] ?? 0;
$shared_links = [strtolower($shared_item['plink'] ?? '')];
$shared_attachments = Post\Media::splitAttachments($shared_uri_id, $shared['guid'], [], $shared_item['has-media'] ?? false);
$shared_item = Post::selectFirst(['uri-id', 'guid', 'plink', 'has-media'], ['guid' => $shared['guid'], 'uid' => [$item['uid'], 0]]);
}
$fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media'];
$shared_uri_id = 0;
$shared_links = [];
if (empty($shared_item['uri-id']) && !empty($item['quote-uri-id'])) {
$shared_item = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id']]);
$quote_uri_id = $item['quote-uri-id'] ?? 0;
$shared_links[] = strtolower($item['quote-uri']);
} elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id'])) {
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]);
if (!empty($media)) {
$shared_item = Post::selectFirst($fields, ['plink' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
if (empty($shared_item['uri-id'])) {
$shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
$shared_links[] = strtolower($media[0]['url']);
}
$quote_uri_id = $shared_item['uri-id'] ?? 0;
}
}
if (!empty($quote_uri_id)) {
$item['body'] .= "\n" . DI::contentItem()->createSharedBlockByArray($shared_item);
}
if (!empty($shared_item['uri-id'])) {
$shared_uri_id = $shared_item['uri-id'];
$shared_links[] = strtolower($shared_item['plink']);
$shared_attachments = Post\Media::splitAttachments($shared_uri_id, $shared_item['guid'], [], $shared_item['has-media']);
$shared_links = array_merge($shared_links, array_column($shared_attachments['visual'], 'url'));
$shared_links = array_merge($shared_links, array_column($shared_attachments['link'], 'url'));
$shared_links = array_merge($shared_links, array_column($shared_attachments['additional'], 'url'));
$item['body'] = self::replaceVisualAttachments($shared_attachments, $item['body']);
} else {
$shared_uri_id = 0;
$shared_links = [];
}
$attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media'] ?? false);
@ -3277,7 +3311,7 @@ class Item
}
DI::profiler()->stopRecording();
if (isset($data['url']) && !in_array($data['url'], $ignore_links)) {
if (isset($data['url']) && !in_array(strtolower($data['url']), $ignore_links)) {
if (!empty($data['description']) || !empty($data['image']) || !empty($data['preview'])) {
$parts = parse_url($data['url']);
if (!empty($parts['scheme']) && !empty($parts['host'])) {
@ -3611,9 +3645,10 @@ class Item
* Improve the data in shared posts
*
* @param array $item
* @param bool $add_media
* @return string body
*/
public static function improveSharedDataInBody(array $item): string
public static function improveSharedDataInBody(array $item, bool $add_media = false): string
{
$shared = BBCode::fetchShareAttributes($item['body']);
if (empty($shared['guid']) && empty($shared['message_id'])) {
@ -3623,7 +3658,7 @@ class Item
$link = $shared['link'] ?: $shared['message_id'];
if (empty($shared_content)) {
$shared_content = DI::contentItem()->createSharedPostByUrl($link, $item['uid'] ?? 0);
$shared_content = DI::contentItem()->createSharedPostByUrl($link, $item['uid'] ?? 0, $add_media);
}
if (empty($shared_content)) {
@ -3635,4 +3670,19 @@ class Item
Logger::debug('New shared data', ['uri-id' => $item['uri-id'], 'link' => $link, 'guid' => $item['guid']]);
return $item['body'];
}
/**
* Fetch the uri-id of a quote
*
* @param string $body
* @return integer
*/
private static function getQuoteUriId(string $body): int
{
$shared = BBCode::fetchShareAttributes($body);
if (empty($shared['message_id'])) {
return 0;
}
return ItemURI::getIdByURI($shared['message_id']);
}
}

View file

@ -239,7 +239,7 @@ class Mail
}
if ($post_id) {
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::MAIL, $post_id);
return intval($post_id);
} else {
return -3;

View file

@ -80,7 +80,7 @@ class Delayed
Logger::notice('Adding post for delayed publishing', ['uid' => $item['uid'], 'delayed' => $delayed, 'uri' => $uri]);
$wid = Worker::add(['priority' => PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
$wid = Worker::add(['priority' => Worker::PRIORITY_HIGH, 'delayed' => $delayed], 'DelayedPublish', $item, $notify, $taglist, $attachments, $preparation_mode, $uri);
if (!$wid) {
return 0;
}

View file

@ -23,10 +23,12 @@ namespace Friendica\Model\Post;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Post;
@ -56,6 +58,7 @@ class Media
const HTML = 17;
const XML = 18;
const PLAIN = 19;
const ACTIVITY = 20;
const DOCUMENT = 128;
/**
@ -215,6 +218,10 @@ class Media
$media = self::addType($media);
}
if (in_array($media['type'], [self::TEXT, self::APPLICATION, self::HTML, self::XML, self::PLAIN])) {
$media = self::addActivity($media);
}
if ($media['type'] == self::HTML) {
$data = ParseUrl::getSiteinfoCached($media['url'], false);
$media['preview'] = $data['images'][0]['src'] ?? null;
@ -232,6 +239,65 @@ class Media
return $media;
}
/**
* Adds the activity type if the media entry is linked to an activity
*
* @param array $media
* @return array
*/
private static function addActivity(array $media): array
{
$id = Item::fetchByLink($media['url']);
if (empty($id)) {
return $media;
}
$item = Post::selectFirst([], ['id' => $id, 'network' => Protocol::FEDERATED]);
if (empty($item['id'])) {
Logger::debug('Not a federated activity', ['id' => $id, 'uri-id' => $media['uri-id'], 'url' => $media['url']]);
return $media;
}
if (!empty($item['plink']) && Strings::compareLink($item['plink'], $media['url']) &&
parse_url($item['plink'], PHP_URL_HOST) != parse_url($item['uri'], PHP_URL_HOST)) {
Logger::debug('Not a link to an activity', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
return $media;
}
if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) {
$media['mimetype'] = 'application/activity+json';
} elseif ($item['network'] == Protocol::DIASPORA) {
$media['mimetype'] = 'application/xml';
} else {
$media['mimetype'] = '';
}
$contact = Contact::getById($item['author-id'], ['avatar', 'gsid']);
if (!empty($contact['gsid'])) {
$gserver = DBA::selectFirst('gserver', ['url', 'site_name'], ['id' => $contact['gsid']]);
}
$media['type'] = self::ACTIVITY;
$media['media-uri-id'] = $item['uri-id'];
$media['height'] = null;
$media['width'] = null;
$media['size'] = null;
$media['preview'] = null;
$media['preview-height'] = null;
$media['preview-width'] = null;
$media['description'] = $item['body'];
$media['name'] = $item['title'];
$media['author-url'] = $item['author-link'];
$media['author-name'] = $item['author-name'];
$media['author-image'] = $contact['avatar'] ?? $item['author-avatar'];
$media['publisher-url'] = $gserver['url'] ?? null;
$media['publisher-name'] = $gserver['site_name'] ?? null;
$media['publisher-image'] = null;
Logger::debug('Activity detected', ['uri-id' => $media['uri-id'], 'url' => $media['url'], 'plink' => $item['plink'], 'uri' => $item['uri']]);
return $media;
}
/**
* Fetch media data from local resources
* @param array $media

View file

@ -153,11 +153,11 @@ class Profile
if ($owner['net-publish'] || $force) {
// Update global directory in background
if (Search::getGlobalDirectory()) {
Worker::add(PRIORITY_LOW, 'Directory', $owner['url']);
Worker::add(Worker::PRIORITY_LOW, 'Directory', $owner['url']);
}
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', $uid);
Worker::add(Worker::PRIORITY_LOW, 'ProfileUpdate', $uid);
}
/**
@ -865,7 +865,7 @@ class Profile
$a->setContactId($arr['visitor']['id']);
info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name']));
DI::sysmsg()->addInfo(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name']));
Logger::info('OpenWebAuth: auth success from ' . $visitor['addr']);
}

View file

@ -37,7 +37,7 @@ class PushSubscriber
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function publishFeed(int $uid, int $default_priority = PRIORITY_HIGH)
public static function publishFeed(int $uid, int $default_priority = Worker::PRIORITY_HIGH)
{
$condition = ['push' => 0, 'uid' => $uid];
DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition);
@ -52,7 +52,7 @@ class PushSubscriber
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function requeue(int $default_priority = PRIORITY_HIGH)
public static function requeue(int $default_priority = Worker::PRIORITY_HIGH)
{
// We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php).
@ -61,7 +61,7 @@ class PushSubscriber
while ($subscriber = DBA::fetch($subscribers)) {
// We always handle retries with low priority
if ($subscriber['push'] > 1) {
$priority = PRIORITY_LOW;
$priority = Worker::PRIORITY_LOW;
} else {
$priority = $default_priority;
}

View file

@ -152,7 +152,7 @@ class Subscription
$subscriptions = DBA::select('subscription', [], ['uid' => $notification->uid, $type => true]);
while ($subscription = DBA::fetch($subscriptions)) {
Logger::info('Push notification', ['id' => $subscription['id'], 'uid' => $subscription['uid'], 'type' => $type]);
Worker::add(PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
Worker::add(Worker::PRIORITY_HIGH, 'PushSubscription', $subscription['id'], $notification->id);
}
DBA::close($subscriptions);
}

View file

@ -994,7 +994,7 @@ class User
try {
$authurl = $openid->authUrl();
} catch (Exception $e) {
throw new Exception(DI::l10n()->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . EOL . EOL . DI::l10n()->t('The error message was:') . $e->getMessage(), 0, $e);
throw new Exception(DI::l10n()->t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.') . '<br />' . DI::l10n()->t('The error message was:') . $e->getMessage(), 0, $e);
}
System::externalRedirect($authurl);
// NOTREACHED
@ -1317,7 +1317,7 @@ class User
if (DBA::isResult($profile) && $profile['net-publish'] && Search::getGlobalDirectory()) {
$url = DI::baseUrl() . '/profile/' . $user['nickname'];
Worker::add(PRIORITY_LOW, "Directory", $url);
Worker::add(Worker::PRIORITY_LOW, "Directory", $url);
}
$l10n = DI::l10n()->withLang($register['language']);
@ -1567,14 +1567,14 @@ class User
// The user and related data will be deleted in Friendica\Worker\ExpireAndRemoveUsers
DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utc('now + 7 day')], ['uid' => $uid]);
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::REMOVAL, $uid);
// Send an update to the directory
$self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
Worker::add(PRIORITY_LOW, 'Directory', $self['url']);
Worker::add(Worker::PRIORITY_LOW, 'Directory', $self['url']);
// Remove the user relevant data
Worker::add(PRIORITY_NEGLIGIBLE, 'RemoveUser', $uid);
Worker::add(Worker::PRIORITY_NEGLIGIBLE, 'RemoveUser', $uid);
return true;
}