From 79a1b41d50f973cff97dd5c69461f50b632488fe Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 6 Oct 2022 10:48:26 +0200 Subject: [PATCH] Fix issue #343 --- .../android/client/endpoints/MastodonStatusesService.java | 3 ++- .../main/java/app/fedilab/android/jobs/ComposeWorker.java | 5 ++++- .../app/fedilab/android/viewmodel/mastodon/StatusesVM.java | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/client/endpoints/MastodonStatusesService.java b/app/src/main/java/app/fedilab/android/client/endpoints/MastodonStatusesService.java index 50f0a8fc..39b960ec 100644 --- a/app/src/main/java/app/fedilab/android/client/endpoints/MastodonStatusesService.java +++ b/app/src/main/java/app/fedilab/android/client/endpoints/MastodonStatusesService.java @@ -25,6 +25,7 @@ import app.fedilab.android.client.entities.api.Poll; import app.fedilab.android.client.entities.api.ScheduledStatus; import app.fedilab.android.client.entities.api.Status; import okhttp3.MultipartBody; +import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.http.DELETE; import retrofit2.http.Field; @@ -217,7 +218,7 @@ public interface MastodonStatusesService { @Header("Authorization") String token, @Part MultipartBody.Part file, @Part MultipartBody.Part thumbnail, - @Part("description") String description, + @Part("description") RequestBody description, @Part("focus") String focus ); diff --git a/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java b/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java index 783fe47a..8733fa0b 100644 --- a/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java +++ b/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java @@ -62,8 +62,10 @@ import app.fedilab.android.client.entities.app.StatusDraft; import app.fedilab.android.exception.DBException; import app.fedilab.android.helper.Helper; import app.fedilab.android.ui.drawer.StatusAdapter; +import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; +import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.Response; import retrofit2.Retrofit; @@ -325,7 +327,8 @@ public class ComposeWorker extends Worker { private static String postAttachment(MastodonStatusesService mastodonStatusesService, DataPost dataPost, MultipartBody.Part fileMultipartBody, Attachment attachment) { - Call attachmentCall = mastodonStatusesService.postMedia(dataPost.token, fileMultipartBody, null, attachment.description, attachment.focus); + RequestBody descriptionBody = RequestBody.create(MediaType.parse("text/plain"), attachment.description); + Call attachmentCall = mastodonStatusesService.postMedia(dataPost.token, fileMultipartBody, null, descriptionBody, attachment.focus); if (attachmentCall != null) { try { diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java index f094580d..c9d0bf3d 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java @@ -49,8 +49,10 @@ import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.MastodonHelper; import app.fedilab.android.helper.TimelineHelper; import okhttp3.Headers; +import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; +import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.Response; import retrofit2.Retrofit; @@ -118,7 +120,8 @@ public class StatusesVM extends AndroidViewModel { MultipartBody.Part thumbnailMultipartBody; fileMultipartBody = Helper.getMultipartBody(getApplication(), "file", file); thumbnailMultipartBody = Helper.getMultipartBody(getApplication(), "file", thumbnail); - Call attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, thumbnailMultipartBody, description, focus); + RequestBody descriptionBody = RequestBody.create(MediaType.parse("text/plain"), description); + Call attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, thumbnailMultipartBody, descriptionBody, focus); Attachment attachment = null; if (attachmentCall != null) { try {