Update media if caption was changed (#1138)

Doesn't work yet as the `/api/v1/media/:id` returns 404?! wtf?!
This commit is contained in:
Nathan Mattes 2024-01-21 12:10:17 +01:00
parent 89b7df25ea
commit 80cd22a356
1 changed files with 15 additions and 1 deletions

View File

@ -115,8 +115,22 @@ extension MastodonEditStatusPublisher: StatusPublisher {
guard case let AttachmentViewModel.Input.mastodonAssetUrl(_, attachmentId) = attachmentViewModel.input else {
throw AppError.badRequest
}
attachmentIDs.append(attachmentId)
break
let needsUpdate = (attachmentViewModel.caption != attachmentViewModel.originalCaption)
if needsUpdate {
_ = try await api.updateMedia(
domain: authContext.mastodonAuthenticationBox.domain,
attachmentID: attachmentId,
query: Mastodon.API.Media.UpdateMediaQuery(
file: nil,
thumbnail: nil,
description: attachmentViewModel.caption,
focus: nil
),
mastodonAuthenticationBox: authContext.mastodonAuthenticationBox
).singleOutput()
}
case let .uploadedMastodonAttachment(attachment):
attachmentIDs.append(attachment.id)