From aea3ed45483ab402666bf310ff88bba42405d661 Mon Sep 17 00:00:00 2001
From: Michael ♲ ' . $attributes['author'] . ': ♲ ' . $attributes['author'] . ' - ' . $attributes['posted'] . ' GMT
' : '') .
- '' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ":
\n" .
- '' . $content . '
';
+ $text = ($is_quote_share ? '
' : '') .
+ '' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ":
\n" .
+ '' . $content . '
';
break;
case self::DIASPORA:
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0) {
- $text = ($is_quote_share? '
' : '') . '' . "\n";
+ $text = ($is_quote_share ? '
' : '') . '' . "\n";
} else {
$headline = '
' : '') . $headline . '' . trim($content) . '
' . "\n";
+ $text = ($is_quote_share ? '
' : '') . $headline . '' . trim($content) . '
' . "\n";
if (empty($attributes['posted']) && !empty($attributes['link'])) {
$text .= '' . "\n";
@@ -929,18 +935,18 @@ class BBCode
$headline .= DI::l10n()->t('%2$s %3$s', $attributes['link'], $mention, $attributes['posted']);
$headline .= ':
' . trim($content) . '' . "\n"; + $text = ($is_quote_share ? '
' . trim($content) . '' . "\n"; break; case self::OSTATUS: - $text = ($is_quote_share? '
' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '
' . "\n"; + $text = ($is_quote_share ? '' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '
' . "\n"; break; case self::ACTIVITYPUB: $author = '@' . $author_contact['addr'] . ':'; $text = '' . $content . '
" . $t_wrote . "
$2", - $text); + while ((strpos($text, "[/quote]") !== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) { + $text = preg_replace( + "/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism", + "
" . $t_wrote . "
$2", + $text + ); } @@ -1548,13 +1565,15 @@ class BBCode $text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $text); $text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '', $text); - $text = preg_replace_callback("/\[img\=(.*?)\](.*?)\[\/img\]/ism", + $text = preg_replace_callback( + "/\[img\=(.*?)\](.*?)\[\/img\]/ism", function ($matches) use ($simple_html, $uriid) { $matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid); $matches[2] = htmlspecialchars($matches[2], ENT_COMPAT); return ''; }, - $text); + $text + ); // Images // [img]pathtoimage[/img] @@ -1576,8 +1595,8 @@ class BBCode $text = self::convertImages($text, $simple_html, $uriid); - $text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '
' . htmlentities(trim($matches[2], "\n\r"), ENT_NOQUOTES, 'UTF-8') . '
';
@@ -1863,8 +1926,8 @@ class BBCode
// Default iframe allowed domains/path
$allowedIframeDomains = [
DI::baseUrl()->getHost()
- . (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : '')
- . '/oembed/', # The path part has to change with the source in Content\Oembed::iframe
+ . (DI::baseUrl()->getPath() ? '/' . DI::baseUrl()->getPath() : '')
+ . '/oembed/', # The path part has to change with the source in Content\Oembed::iframe
'www.youtube.com/embed/',
'player.vimeo.com/video/',
];
@@ -1977,7 +2040,8 @@ class BBCode
* Transform #tags, strip off the [url] and replace spaces with underscore
*/
$url_search_string = "^\[\]";
- $text = preg_replace_callback("/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
+ $text = preg_replace_callback(
+ "/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
function ($matches) {
return '#' . str_replace(' ', '_', $matches[2]);
},
@@ -2112,7 +2176,8 @@ class BBCode
*/
public static function expandTags(string $body): string
{
- return preg_replace_callback("/(?<=\W|^)([!#@])([^\^ \x0D\x0A,;:?'\"]*[^\^ \x0D\x0A,;:?!'\".])/",
+ return preg_replace_callback(
+ "/(?<=\W|^)([!#@])([^\^ \x0D\x0A,;:?'\"]*[^\^ \x0D\x0A,;:?!'\".])/",
function (array $match) {
switch ($match[1]) {
case '!':
@@ -2129,7 +2194,9 @@ class BBCode
default:
return $match[1] . '[url=' . DI::baseUrl() . '/search?tag=' . $match[2] . ']' . $match[2] . '[/url]';
}
- }, $body);
+ },
+ $body
+ );
}
/**
diff --git a/src/Content/Text/Plaintext.php b/src/Content/Text/Plaintext.php
index 0866e476cf..7e3263d127 100644
--- a/src/Content/Text/Plaintext.php
+++ b/src/Content/Text/Plaintext.php
@@ -122,8 +122,11 @@ class Plaintext
$body = preg_replace("/([#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $item['body']);
// Add an URL element if the text contains a raw link
- $body = preg_replace('/([^\]\=\'"]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism',
- '$1[url]$2[/url]', $body);
+ $body = preg_replace(
+ '/([^\]\=\'"]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism',
+ '$1[url]$2[/url]',
+ $body
+ );
// Remove the abstract
$body = BBCode::stripAbstract($body);
@@ -149,7 +152,7 @@ class Plaintext
if (($limit == 0) && ($abstract == $default_abstract)) {
$abstract = '';
}
- } else {// Try to guess the correct target network
+ } else { // Try to guess the correct target network
switch ($htmlmode) {
case BBCode::TWITTER:
$abstract = BBCode::getAbstract($item['body'], Protocol::TWITTER);
diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php
index ee74ee02b2..ab17789724 100644
--- a/src/Model/Post/Media.php
+++ b/src/Model/Post/Media.php
@@ -162,8 +162,10 @@ class Media
*/
public static function getAttachElement(string $href, int $length, string $type, string $title = ''): string
{
- $media = self::fetchAdditionalData(['type' => self::DOCUMENT, 'url' => $href,
- 'size' => $length, 'mimetype' => $type, 'description' => $title]);
+ $media = self::fetchAdditionalData([
+ 'type' => self::DOCUMENT, 'url' => $href,
+ 'size' => $length, 'mimetype' => $type, 'description' => $title
+ ]);
return '[attach]href="' . $media['url'] . '" length="' . $media['size'] .
'" type="' . $media['mimetype'] . '" title="' . $media['description'] . '"[/attach]';
@@ -263,8 +265,10 @@ class Media
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)) {
+ 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;
}
@@ -483,8 +487,10 @@ class Media
}
$body = str_replace($picture[0], '', $body);
$image = str_replace('-1.', '-0.', $picture[2]);
- $attachments[$image] = ['uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
- 'preview' => $picture[2], 'description' => $picture[3]];
+ $attachments[$image] = [
+ 'uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
+ 'preview' => $picture[2], 'description' => $picture[3]
+ ];
}
}
@@ -502,8 +508,10 @@ class Media
}
$body = str_replace($picture[0], '', $body);
$image = str_replace('-1.', '-0.', $picture[2]);
- $attachments[$image] = ['uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
- 'preview' => $picture[2], 'description' => null];
+ $attachments[$image] = [
+ 'uri-id' => $uriid, 'type' => self::IMAGE, 'url' => $image,
+ 'preview' => $picture[2], 'description' => null
+ ];
}
}
@@ -631,7 +639,7 @@ class Media
public static function insertFromAttachmentData(int $uriid, string $body)
{
$data = BBCode::getAttachmentData($body);
- if (empty($data)) {
+ if (empty($data)) {
return;
}
@@ -803,8 +811,10 @@ class Media
continue;
}
- if (in_array($medium['type'], [self::AUDIO, self::IMAGE]) ||
- in_array($filetype, ['audio', 'image'])) {
+ if (
+ in_array($medium['type'], [self::AUDIO, self::IMAGE]) ||
+ in_array($filetype, ['audio', 'image'])
+ ) {
$attachments['visual'][] = $medium;
} elseif (($medium['type'] == self::VIDEO) || ($filetype == 'video')) {
if (!empty($medium['height'])) {
@@ -871,15 +881,15 @@ class Media
if ($media['type'] == self::IMAGE) {
if (!empty($media['preview'])) {
if (!empty($media['description'])) {
- $body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] .'[/img][/url]';
+ $body .= "\n[url=" . $media['url'] . "][img=" . $media['preview'] . ']' . $media['description'] . '[/img][/url]';
} else {
- $body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] .'[/img][/url]';
+ $body .= "\n[url=" . $media['url'] . "][img]" . $media['preview'] . '[/img][/url]';
}
} else {
if (!empty($media['description'])) {
- $body .= "\n[img=" . $media['url'] . ']' . $media['description'] .'[/img]';
+ $body .= "\n[img=" . $media['url'] . ']' . $media['description'] . '[/img]';
} else {
- $body .= "\n[img]" . $media['url'] .'[/img]';
+ $body .= "\n[img]" . $media['url'] . '[/img]';
}
}
} elseif ($media['type'] == self::AUDIO) {
diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index 160667681f..5554af7d81 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -83,14 +83,21 @@ class Diaspora
return $contacts;
}
- $items = Post::select(['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
- ['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
+ $items = Post::select(
+ ['author-id', 'author-link', 'parent-author-link', 'parent-guid', 'guid'],
+ ['parent' => $item['parent'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]
+ );
while ($item = Post::fetch($items)) {
- $contact = DBA::selectFirst('contact', ['id', 'url', 'name', 'protocol', 'batch', 'network'],
- ['id' => $item['author-id']]);
- if (!DBA::isResult($contact) || empty($contact['batch']) ||
+ $contact = DBA::selectFirst(
+ 'contact',
+ ['id', 'url', 'name', 'protocol', 'batch', 'network'],
+ ['id' => $item['author-id']]
+ );
+ if (
+ !DBA::isResult($contact) || empty($contact['batch']) ||
($contact['network'] != Protocol::DIASPORA) ||
- Strings::compareLink($item['parent-author-link'], $item['author-link'])) {
+ Strings::compareLink($item['parent-author-link'], $item['author-link'])
+ ) {
continue;
}
@@ -270,7 +277,7 @@ class Diaspora
$basedom = XML::parseString($xml, true);
if (!is_object($basedom)) {
- Logger::notice('Received data does not seem to be an XML. Discarding. '.$xml);
+ Logger::notice('Received data does not seem to be an XML. Discarding. ' . $xml);
if ($no_exit) {
return false;
} else {
@@ -438,7 +445,7 @@ class Diaspora
$alg = $base->alg;
- $signed_data = $data.'.'.Strings::base64UrlEncode($type).'.'.Strings::base64UrlEncode($encoding).'.'.Strings::base64UrlEncode($alg);
+ $signed_data = $data . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
// decode the data
@@ -719,7 +726,8 @@ class Diaspora
$signed_data .= $entry;
}
- if (!in_array($fieldname, ['parent_author_signature', 'target_author_signature'])
+ if (
+ !in_array($fieldname, ['parent_author_signature', 'target_author_signature'])
|| ($orig_type == 'relayable_retraction')
) {
XML::copy($entry, $fields, $fieldname);
@@ -795,7 +803,7 @@ class Diaspora
Logger::info('Fetching diaspora key', ['handle' => $uri->getAddr(), 'callstack' => System::callstack(20)]);
try {
return DI::dsprContact()->getByAddr($uri)->pubKey;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
return '';
}
}
@@ -1185,9 +1193,11 @@ class Diaspora
*/
private static function parentItem(int $uid, string $guid, WebFingerUri $author, array $contact)
{
- $fields = ['id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
+ $fields = [
+ 'id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
'author-name', 'author-link', 'author-avatar', 'gravity',
- 'owner-name', 'owner-link', 'owner-avatar'];
+ 'owner-name', 'owner-link', 'owner-avatar'
+ ];
$condition = ['uid' => $uid, 'guid' => $guid];
$item = Post::selectFirst($fields, $condition);
@@ -1435,7 +1445,7 @@ class Diaspora
} elseif ($person_uri) {
try {
return DI::dsprContact()->selectOneByAddr($person_uri)->baseurl . '/objects/' . $guid;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
return '';
}
}
@@ -1472,7 +1482,6 @@ class Diaspora
$contact = DI::dsprContact()->getByUrl(new Uri($match[3]));
Tag::storeByHash($uriid, $match[1], $contact->name ?: $contact->nick, $contact->url);
} catch (\Throwable $e) {
-
}
}
}
@@ -1531,7 +1540,7 @@ class Diaspora
try {
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
Logger::notice('Unable to find author details', ['author' => $author->getAddr()]);
return false;
}
@@ -1783,7 +1792,7 @@ class Diaspora
try {
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
Logger::notice('Unable to find author details', ['author' => $author->getAddr()]);
return false;
}
@@ -1896,7 +1905,7 @@ class Diaspora
try {
$author = DI::dsprContact()->getByAddr($author_uri);
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
Logger::notice('Unable to find author details', ['author' => $author_uri->getAddr()]);
return false;
}
@@ -1968,7 +1977,7 @@ class Diaspora
try {
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
Logger::notice('unable to find author details', ['author' => $author->getAddr()]);
return false;
}
@@ -2013,8 +2022,10 @@ class Diaspora
Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
// Send all existing comments and likes to the requesting server
- $comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
- ['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]);
+ $comments = Post::select(
+ ['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
+ ['parent' => $toplevel_parent_item['id'], 'gravity' => [Item::GRAVITY_COMMENT, Item::GRAVITY_ACTIVITY]]
+ );
while ($comment = Post::fetch($comments)) {
if (($comment['gravity'] == Item::GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
@@ -2089,7 +2100,7 @@ class Diaspora
return false;
}
- $name = XML::unescape($data->first_name).((strlen($data->last_name)) ? ' ' . XML::unescape($data->last_name) : '');
+ $name = XML::unescape($data->first_name) . ((strlen($data->last_name)) ? ' ' . XML::unescape($data->last_name) : '');
$image_url = XML::unescape($data->image_url);
$birthday = XML::unescape($data->birthday);
$about = Markdown::toBBCode(XML::unescape($data->bio));
@@ -2136,10 +2147,12 @@ class Diaspora
$birthday = $contact['bd'];
}
- $fields = ['name' => $name, 'location' => $location,
+ $fields = [
+ 'name' => $name, 'location' => $location,
'name-date' => DateTimeFormat::utcNow(), 'about' => $about,
'addr' => $author->getAddr(), 'nick' => $author->getUser(), 'keywords' => $keywords,
- 'unsearchable' => !$searchable, 'sensitive' => $nsfw];
+ 'unsearchable' => !$searchable, 'sensitive' => $nsfw
+ ];
if (!empty($birthday)) {
$fields['bd'] = $birthday;
@@ -2249,7 +2262,7 @@ class Diaspora
try {
$author_url = (string)DI::dsprContact()->getByAddr($author)->url;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
Logger::notice('Cannot resolve diaspora handle for recipient', ['author' => $author->getAddr(), 'recipient' => $recipient]);
return false;
}
@@ -2426,7 +2439,7 @@ class Diaspora
try {
$author = DI::dsprContact()->getByAddr($author_uri);
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
Logger::notice('Unable to find details for author', ['author' => $author_uri->getAddr()]);
return false;
}
@@ -2561,7 +2574,7 @@ class Diaspora
private static function storePhotoAsMedia(int $uriid, $photo)
{
// @TODO Need to find object type, roland@f.haeder.net
- Logger::debug('photo='.get_class($photo));
+ Logger::debug('photo=' . get_class($photo));
$data = [];
$data['uri-id'] = $uriid;
$data['type'] = Post\Media::IMAGE;
@@ -2930,8 +2943,7 @@ class Diaspora
try {
$target = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']));
$dest_url = $public_batch ? $target->batch : $target->notify;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
-
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
}
if (empty($dest_url)) {
@@ -3011,8 +3023,7 @@ class Diaspora
if (!empty($contact['addr'])) {
try {
$pubkey = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']))->pubKey;
- } catch (HTTPException\NotFoundException|\InvalidArgumentException $e) {
-
+ } catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
}
} else {
// The "addr" field should always be filled.
@@ -3058,8 +3069,10 @@ class Diaspora
// If the item belongs to a user, we take this user id.
if ($item['uid'] == 0) {
// @todo Possibly use an administrator account?
- $condition = ['verified' => true, 'blocked' => false,
- 'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON];
+ $condition = [
+ 'verified' => true, 'blocked' => false,
+ 'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON
+ ];
$first_user = DBA::selectFirst('user', ['uid'], $condition, ['order' => ['uid']]);
$owner = User::getOwnerDataById($first_user['uid']);
} else {
@@ -3099,7 +3112,7 @@ class Diaspora
$old_handle = DI::pConfig()->get($uid, 'system', 'previous_addr');
$profile = self::createProfileData($uid);
- $signed_text = 'AccountMigration:'.$old_handle.':'.$profile['author'];
+ $signed_text = 'AccountMigration:' . $old_handle . ':' . $profile['author'];
$signature = base64_encode(Crypto::rsaSign($signed_text, $owner['uprvkey'], 'sha256'));
$message = [
@@ -3388,9 +3401,11 @@ class Diaspora
if (count($event)) {
$message['event'] = $event;
- if (!empty($event['location']['address']) &&
+ if (
+ !empty($event['location']['address']) &&
!empty($event['location']['lat']) &&
- !empty($event['location']['lng'])) {
+ !empty($event['location']['lng'])
+ ) {
$message['location'] = $event['location'];
}
@@ -3453,7 +3468,8 @@ class Diaspora
private static function prependParentAuthorMention(string $body, string $profile_url): string
{
$profile = Contact::getByURL($profile_url, false, ['addr', 'name']);
- if (!empty($profile['addr'])
+ if (
+ !empty($profile['addr'])
&& !strstr($body, $profile['addr'])
&& !strstr($body, $profile_url)
) {
@@ -3908,9 +3924,9 @@ class Diaspora
$kw = str_replace(' ', ' ', $kw);
$arr = explode(' ', $kw);
if (count($arr)) {
- for ($x = 0; $x < 5; $x ++) {
+ for ($x = 0; $x < 5; $x++) {
if (!empty($arr[$x])) {
- $data['tag_string'] .= '#'. trim($arr[$x]) .' ';
+ $data['tag_string'] .= '#' . trim($arr[$x]) . ' ';
}
}
}
@@ -4095,7 +4111,7 @@ class Diaspora
'body' => '',
'quote-uri-id' => $UriId,
'allow_cid' => $owner['allow_cid'] ?? '',
- 'allow_gid' => $owner['allow_gid']?? '',
+ 'allow_gid' => $owner['allow_gid'] ?? '',
'deny_cid' => $owner['deny_cid'] ?? '',
'deny_gid' => $owner['deny_gid'] ?? '',
];
diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php
index f9ea91c779..a83819742e 100644
--- a/src/Protocol/Feed.php
+++ b/src/Protocol/Feed.php
@@ -384,8 +384,10 @@ class Feed
}
if (!$dryRun) {
- $condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
- $importer['uid'], $item['uri'], Protocol::FEED, Protocol::DFRN];
+ $condition = [
+ "`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
+ $importer['uid'], $item['uri'], Protocol::FEED, Protocol::DFRN
+ ];
$previous = Post::selectFirst(['id', 'created'], $condition);
if (DBA::isResult($previous)) {
// Use the creation date when the post had been stored. It can happen this date changes in the feed.
@@ -644,8 +646,10 @@ class Feed
if (!$notify) {
Post\Delayed::publish($item, $notify, $taglist, $attachments);
} else {
- $postings[] = ['item' => $item, 'notify' => $notify,
- 'taglist' => $taglist, 'attachments' => $attachments];
+ $postings[] = [
+ 'item' => $item, 'notify' => $notify,
+ 'taglist' => $taglist, 'attachments' => $attachments
+ ];
}
} else {
Logger::info('Post already created or exists in the delayed posts queue', ['uid' => $item['uid'], 'uri' => $item['uri']]);
@@ -852,7 +856,7 @@ class Feed
$min_poll_interval = max(1, DI::config()->get('system', 'min_poll_interval'));
- $poll_intervals = [$min_poll_interval, 15, 30, 60, 120, 180, 360, 720 ,1440, 10080, 43200];
+ $poll_intervals = [$min_poll_interval, 15, 30, 60, 120, 180, 360, 720, 1440, 10080, 43200];
//$poll_intervals = [$min_poll_interval . ' minute', '15 minute', '30 minute',
// '1 hour', '2 hour', '3 hour', '6 hour', '12 hour' ,'1 day', '1 week', '1 month'];
@@ -942,7 +946,7 @@ class Feed
$previous_created = $last_update;
// Don't cache when the last item was posted less then 15 minutes ago (Cache duration)
- if ((time() - strtotime($owner['last-item'])) < 15*60) {
+ if ((time() - strtotime($owner['last-item'])) < 15 * 60) {
$result = DI::cache()->get($cachekey);
if (!$nocache && !is_null($result)) {
Logger::info('Cached feed duration', ['seconds' => number_format(microtime(true) - $stamp, 3), 'nick' => $owner['nickname'], 'filter' => $filter, 'created' => $previous_created]);
@@ -953,11 +957,13 @@ class Feed
$check_date = empty($last_update) ? '' : DateTimeFormat::utc($last_update);
$authorid = Contact::getIdForURL($owner['url']);
- $condition = ["`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
+ $condition = [
+ "`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
AND `private` != ? AND `visible` AND `wall` AND `parent-network` IN (?, ?, ?, ?)",
$owner['uid'], $check_date, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT,
Item::PRIVATE, Protocol::ACTIVITYPUB,
- Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA];
+ Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA
+ ];
if ($filter === 'comments') {
$condition[0] .= " AND `gravity` = ? ";
@@ -1130,8 +1136,15 @@ class Feed
XML::addElement($doc, $entry, 'content', $body, ['type' => 'html']);
- XML::addElement($doc, $entry, 'link', '', ['rel' => 'alternate', 'type' => 'text/html',
- 'href' => DI::baseUrl() . '/display/' . $item['guid']]
+ XML::addElement(
+ $doc,
+ $entry,
+ 'link',
+ '',
+ [
+ 'rel' => 'alternate', 'type' => 'text/html',
+ 'href' => DI::baseUrl() . '/display/' . $item['guid']
+ ]
);
XML::addElement($doc, $entry, 'published', DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM));
@@ -1173,12 +1186,14 @@ class Feed
if (isset($parent_plink)) {
$attributes = [
'ref' => $item['thr-parent'],
- 'href' => $parent_plink];
+ 'href' => $parent_plink
+ ];
XML::addElement($doc, $entry, 'thr:in-reply-to', '', $attributes);
$attributes = [
'rel' => 'related',
- 'href' => $parent_plink];
+ 'href' => $parent_plink
+ ];
XML::addElement($doc, $entry, 'link', '', $attributes);
}
}
@@ -1220,7 +1235,7 @@ class Feed
// Remove the share element before fetching the first line
$title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $item['body']));
- $title = BBCode::toPlaintext($title)."\n";
+ $title = BBCode::toPlaintext($title) . "\n";
$pos = strpos($title, "\n");
$trailer = '';
if (($pos == 0) || ($pos > 100)) {