mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:40:17 +00:00
fix errors in all models
This commit is contained in:
parent
c61ae5da42
commit
92eff402af
6 changed files with 20 additions and 10 deletions
|
@ -178,7 +178,7 @@ class APContact
|
|||
|
||||
try {
|
||||
$curlResult = HTTPSignature::fetchRaw($url);
|
||||
$failed = empty($curlResult) || empty($curlResult->getBodyString()) ||
|
||||
$failed = empty($curlResult->getBodyString()) ||
|
||||
(!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
|
||||
|
||||
if (!$failed) {
|
||||
|
|
|
@ -2364,6 +2364,8 @@ class Contact
|
|||
$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;
|
||||
|
@ -2380,6 +2382,8 @@ class Contact
|
|||
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']);
|
||||
|
@ -2411,8 +2415,15 @@ class Contact
|
|||
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;
|
||||
|
|
|
@ -333,7 +333,7 @@ class Event
|
|||
$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'];
|
||||
|
|
|
@ -128,7 +128,7 @@ class Engagement
|
|||
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);
|
||||
|
@ -318,6 +318,8 @@ class Engagement
|
|||
$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_';
|
||||
|
|
|
@ -113,9 +113,6 @@ class Link
|
|||
|
||||
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 [];
|
||||
|
|
|
@ -699,7 +699,7 @@ class Media
|
|||
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]);
|
||||
|
@ -715,7 +715,7 @@ class Media
|
|||
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]);
|
||||
|
|
Loading…
Reference in a new issue