Support the "media_attachments" field

This commit is contained in:
Michael 2021-07-30 22:39:13 +00:00
parent 9b609ba19d
commit 13529fa97d
2 changed files with 8 additions and 4 deletions

View File

@ -23,6 +23,7 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model\ItemURI;
use Friendica\Model\Photo;
use Friendica\Model\Post;
@ -60,8 +61,11 @@ class ScheduledStatus extends BaseFactory
}
$media_ids = [];
$media_attachments = [];
foreach ($parameters['attachments'] as $attachment) {
$media_ids[] = Photo::getIdForName($attachment['url']);
$id = Photo::getIdForName($attachment['url']);
$media_ids[] = (string)$id;
$media_attachments[] = DI::mstdnAttachment()->createFromPhoto($id);
}
if (isset($parameters['item']['thr-parent']) && ($parameters['item']['gravity'] ?? GRAVITY_PARENT != GRAVITY_PARENT)) {
@ -70,6 +74,6 @@ class ScheduledStatus extends BaseFactory
$in_reply_to_id = null;
}
return new \Friendica\Object\Api\Mastodon\ScheduledStatus($delayed_post, $parameters, $media_ids, $in_reply_to_id);
return new \Friendica\Object\Api\Mastodon\ScheduledStatus($delayed_post, $parameters, $media_ids, $media_attachments, $in_reply_to_id);
}
}

View File

@ -59,7 +59,7 @@ class ScheduledStatus extends BaseDataTransferObject
* @param array $parameters Parameters for the workerqueue entry for the delayed post
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $delayed_post, array $parameters, array $media_ids = null, int $in_reply_to_id = null)
public function __construct(array $delayed_post, array $parameters, array $media_ids = null, array $media_attachments = [], int $in_reply_to_id = null)
{
$visibility = ['public', 'private', 'unlisted'];
@ -79,6 +79,6 @@ class ScheduledStatus extends BaseDataTransferObject
'application_id' => ''
];
$this->media_attachments = [];
$this->media_attachments = $media_attachments;
}
}