Issue 12743: Allow editing of media in posts

This commit is contained in:
Michael 2023-11-25 12:22:25 +00:00
parent 5c3227ac4c
commit ca366e5437

View File

@ -57,6 +57,7 @@ class Statuses extends BaseApi
'in_reply_to_id' => 0, // ID of the status being replied to, if status is a reply
'spoiler_text' => '', // Text to be shown as a warning or subject before the actual content. Statuses are generally collapsed behind this field.
'language' => '', // ISO 639 language code for this status.
'media_attributes' => [],
'friendica' => [],
], $request);
@ -120,6 +121,12 @@ class Statuses extends BaseApi
$media_ids = [];
$existing_media = array_column(Post\Media::getByURIId($post['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE]), 'id');
foreach ($request['media_attributes'] as $attributes) {
if (in_array($attributes['id'], $existing_media)) {
Post\Media::updateById(['description' => $attributes['description']], $attributes['id']);
}
}
foreach ($request['media_ids'] as $media) {
if (!in_array($media, $existing_media)) {
$media_ids[] = $media;