try {
$curlResult = HTTPSignature::fetchRaw($url);
- $failed = empty($curlResult) || empty($curlResult->getBodyString()) ||
+ $failed = empty($curlResult->getBodyString()) ||
(!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
if (!$failed) {
$cache_avatar = !DBA::exists('contact', ['nurl' => $contact['nurl'], 'self' => true]);
}
+ $fields = [];
+
if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) || $cache_avatar) {
if (Avatar::deleteCache($contact)) {
$force = true;
Logger::debug('Use default avatar', ['id' => $cid, 'uid' => $uid]);
}
+ $local_uid = 0;
+
// Use the data from the self account
if (empty($fields)) {
$local_uid = User::getIdForURL($contact['url']);
if ($update) {
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
if ($photos) {
- $fields = ['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'blurhash' => $photos[3], 'avatar-date' => DateTimeFormat::utcNow()];
- $update = !empty($fields);
+ $fields = [
+ 'avatar' => $avatar,
+ 'photo' => $photos[0],
+ 'thumb' => $photos[1],
+ 'micro' => $photos[2],
+ 'blurhash' => $photos[3],
+ 'avatar-date' => DateTimeFormat::utcNow(),
+ ];
+ $update = true;
Logger::debug('Created new cached avatars', ['id' => $cid, 'uid' => $uid, 'owner-uid' => $local_uid]);
} else {
$update = false;
$item['uri'] = $event['uri'];
$item['uri-id'] = ItemURI::getIdByURI($event['uri']);
$item['guid'] = $event['guid'];
- $item['plink'] = $arr['plink'] ?? '';
+ $item['plink'] = '';
$item['post-type'] = Item::PT_EVENT;
$item['wall'] = $event['cid'] ? 0 : 1;
$item['contact-id'] = $contact['id'];
return ($ret && !$exists) ? $engagement['uri-id'] : 0;
}
- public static function getContentSize(array $item): int
+ public static function getContentSize(array $item): int
{
$body = ' ' . $item['title'] . ' ' . $item['content-warning'] . ' ' . $item['body'];
$body = BBCode::removeAttachment($body);
$result = Post::selectPosts(['author-addr', 'author-nick', 'author-contact-type'],
['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]);
while ($reshare = Post::fetch($result)) {
+ $prefix = '';
+
switch ($reshare['author-contact-type']) {
case Contact::TYPE_RELAY:
$prefix = ' application_';
try {
$curlResult = HTTPSignature::fetchRaw($url, 0, [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => $accept]);
- if (empty($curlResult) || !$curlResult->isSuccess()) {
- return [];
- }
} catch (\Exception $exception) {
Logger::notice('Error fetching url', ['url' => $url, 'exception' => $exception]);
return [];
if (preg_match_all("/\[url\](https?:.*?)\[\/url\]/ism", $body, $matches)) {
foreach ($matches[1] as $url) {
Logger::info('Got page url (link without description)', ['uri-id' => $uriid, 'url' => $url]);
- $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false, $network);
+ $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false);
if ($result && !in_array($network, [Protocol::ACTIVITYPUB, Protocol::DIASPORA])) {
self::revertHTMLType($uriid, $url, $fullbody);
Logger::debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]);
if (preg_match_all("/\[url\=(https?:.*?)\].*?\[\/url\]/ism", $body, $matches)) {
foreach ($matches[1] as $url) {
Logger::info('Got page url (link with description)', ['uri-id' => $uriid, 'url' => $url]);
- $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false, $network);
+ $result = self::insert(['uri-id' => $uriid, 'type' => self::UNKNOWN, 'url' => $url], false);
if ($result && !in_array($network, [Protocol::ACTIVITYPUB, Protocol::DIASPORA])) {
self::revertHTMLType($uriid, $url, $fullbody);
Logger::debug('Revert HTML type', ['uri-id' => $uriid, 'url' => $url]);