Merge pull request #12244 from MrPetovan/bug/warnings
Address various Warning messages
This commit is contained in:
commit
1f08b2c1c0
5 changed files with 31 additions and 7 deletions
|
@ -94,12 +94,17 @@ class Attachment extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function createFromPhoto(int $id): array
|
public function createFromPhoto(int $id): array
|
||||||
{
|
{
|
||||||
$photo = Photo::selectFirst(['resource-id', 'uid', 'id', 'title', 'type'], ['id' => $id]);
|
$photo = Photo::selectFirst(['resource-id', 'uid', 'id', 'title', 'type', 'width', 'height'], ['id' => $id]);
|
||||||
if (empty($photo)) {
|
if (empty($photo)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$attachment = ['id' => $photo['id'], 'description' => $photo['title']];
|
$attachment = [
|
||||||
|
'id' => $photo['id'],
|
||||||
|
'description' => $photo['title'],
|
||||||
|
'width' => $photo['width'],
|
||||||
|
'height' => $photo['height'],
|
||||||
|
];
|
||||||
|
|
||||||
$photoTypes = Images::supportedTypes();
|
$photoTypes = Images::supportedTypes();
|
||||||
$ext = $photoTypes[$photo['type']];
|
$ext = $photoTypes[$photo['type']];
|
||||||
|
@ -113,7 +118,6 @@ class Attachment extends BaseFactory
|
||||||
$preview_url = '';
|
$preview_url = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, 'image', $url, $preview_url, '');
|
$object = new \Friendica\Object\Api\Mastodon\Attachment($attachment, 'image', $url, $preview_url, '');
|
||||||
return $object->toArray();
|
return $object->toArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,11 @@ class Notification extends BaseFactory
|
||||||
if (($contact['uid'] == 0) && !empty($contact['uri-id'])) {
|
if (($contact['uid'] == 0) && !empty($contact['uri-id'])) {
|
||||||
$contact = Contact::selectFirst(['pending'], ['uri-id' => $contact['uri-id'], 'uid' => $Notification->uid]);
|
$contact = Contact::selectFirst(['pending'], ['uri-id' => $contact['uri-id'], 'uid' => $Notification->uid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($contact['pending'])) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$type = $contact['pending'] ? MstdnNotification::TYPE_INTRODUCTION : MstdnNotification::TYPE_FOLLOW;
|
$type = $contact['pending'] ? MstdnNotification::TYPE_INTRODUCTION : MstdnNotification::TYPE_FOLLOW;
|
||||||
} elseif (($Notification->verb == Activity::ANNOUNCE) &&
|
} elseif (($Notification->verb == Activity::ANNOUNCE) &&
|
||||||
in_array($Notification->type, [Post\UserNotification::TYPE_DIRECT_COMMENT, Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT])) {
|
in_array($Notification->type, [Post\UserNotification::TYPE_DIRECT_COMMENT, Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT])) {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
namespace Friendica\Object\Api\Mastodon;
|
namespace Friendica\Object\Api\Mastodon;
|
||||||
|
|
||||||
use Friendica\BaseDataTransferObject;
|
use Friendica\BaseDataTransferObject;
|
||||||
|
use Friendica\Core\Logger;
|
||||||
|
use Friendica\Core\System;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Attachment
|
* Class Attachment
|
||||||
|
@ -50,8 +52,12 @@ class Attachment extends BaseDataTransferObject
|
||||||
/**
|
/**
|
||||||
* Creates an attachment
|
* Creates an attachment
|
||||||
*
|
*
|
||||||
* @param array $attachment
|
* @param array $attachment Expected keys: id, description
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* If $type == 'image': width, height[, preview-width, preview-height]
|
||||||
|
* @param string $type One of: audio, video, gifv, image, unknown
|
||||||
|
* @param string $url
|
||||||
|
* @param string $preview
|
||||||
|
* @param string $remote
|
||||||
*/
|
*/
|
||||||
public function __construct(array $attachment, string $type, string $url, string $preview, string $remote)
|
public function __construct(array $attachment, string $type, string $url, string $preview, string $remote)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +76,7 @@ class Attachment extends BaseDataTransferObject
|
||||||
$this->meta['original']['aspect'] = (float) ((int) $attachment['width'] / (int) $attachment['height']);
|
$this->meta['original']['aspect'] = (float) ((int) $attachment['width'] / (int) $attachment['height']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int) $attachment['preview-width'] > 0 && (int) $attachment['preview-height'] > 0) {
|
if (isset($attachment['preview-width']) && (int) $attachment['preview-width'] > 0 && (int) $attachment['preview-height'] > 0) {
|
||||||
$this->meta['small']['width'] = (int) $attachment['preview-width'];
|
$this->meta['small']['width'] = (int) $attachment['preview-width'];
|
||||||
$this->meta['small']['height'] = (int) $attachment['preview-height'];
|
$this->meta['small']['height'] = (int) $attachment['preview-height'];
|
||||||
$this->meta['small']['size'] = (int) $attachment['preview-width'] . 'x' . (int) $attachment['preview-height'];
|
$this->meta['small']['size'] = (int) $attachment['preview-width'] . 'x' . (int) $attachment['preview-height'];
|
||||||
|
|
|
@ -431,7 +431,7 @@ class Processor
|
||||||
$item['owner-id'] = $item['author-id'];
|
$item['owner-id'] = $item['author-id'];
|
||||||
} else {
|
} else {
|
||||||
$actor = APContact::getByURL($item['owner-link'], false);
|
$actor = APContact::getByURL($item['owner-link'], false);
|
||||||
$item['isForum'] = ($actor['type'] == 'Group');
|
$item['isForum'] = ($actor['type'] ?? 'Person') == 'Group';
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['uri'] = $activity['id'];
|
$item['uri'] = $activity['id'];
|
||||||
|
|
|
@ -2031,6 +2031,10 @@ class Transmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
|
if (empty($owner)) {
|
||||||
|
Logger::warning('No user found for actor, aborting', ['uid' => $uid]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$id = DI::baseUrl() . '/activity/' . System::createGUID();
|
$id = DI::baseUrl() . '/activity/' . System::createGUID();
|
||||||
|
@ -2167,6 +2171,11 @@ class Transmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
|
if (empty($owner)) {
|
||||||
|
Logger::notice('No user found for actor', ['uid' => $uid]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'@context' => ActivityPub::CONTEXT,
|
'@context' => ActivityPub::CONTEXT,
|
||||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||||
|
|
Loading…
Reference in a new issue