This commit is contained in:
Thomas 2022-10-06 10:48:26 +02:00
parent 40be73bd9b
commit 79a1b41d50
3 changed files with 10 additions and 3 deletions

View File

@ -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.ScheduledStatus;
import app.fedilab.android.client.entities.api.Status; import app.fedilab.android.client.entities.api.Status;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.DELETE; import retrofit2.http.DELETE;
import retrofit2.http.Field; import retrofit2.http.Field;
@ -217,7 +218,7 @@ public interface MastodonStatusesService {
@Header("Authorization") String token, @Header("Authorization") String token,
@Part MultipartBody.Part file, @Part MultipartBody.Part file,
@Part MultipartBody.Part thumbnail, @Part MultipartBody.Part thumbnail,
@Part("description") String description, @Part("description") RequestBody description,
@Part("focus") String focus @Part("focus") String focus
); );

View File

@ -62,8 +62,10 @@ import app.fedilab.android.client.entities.app.StatusDraft;
import app.fedilab.android.exception.DBException; import app.fedilab.android.exception.DBException;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
import app.fedilab.android.ui.drawer.StatusAdapter; import app.fedilab.android.ui.drawer.StatusAdapter;
import okhttp3.MediaType;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; 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) { private static String postAttachment(MastodonStatusesService mastodonStatusesService, DataPost dataPost, MultipartBody.Part fileMultipartBody, Attachment attachment) {
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(dataPost.token, fileMultipartBody, null, attachment.description, attachment.focus); RequestBody descriptionBody = RequestBody.create(MediaType.parse("text/plain"), attachment.description);
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(dataPost.token, fileMultipartBody, null, descriptionBody, attachment.focus);
if (attachmentCall != null) { if (attachmentCall != null) {
try { try {

View File

@ -49,8 +49,10 @@ import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MastodonHelper; import app.fedilab.android.helper.MastodonHelper;
import app.fedilab.android.helper.TimelineHelper; import app.fedilab.android.helper.TimelineHelper;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Response; import retrofit2.Response;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -118,7 +120,8 @@ public class StatusesVM extends AndroidViewModel {
MultipartBody.Part thumbnailMultipartBody; MultipartBody.Part thumbnailMultipartBody;
fileMultipartBody = Helper.getMultipartBody(getApplication(), "file", file); fileMultipartBody = Helper.getMultipartBody(getApplication(), "file", file);
thumbnailMultipartBody = Helper.getMultipartBody(getApplication(), "file", thumbnail); thumbnailMultipartBody = Helper.getMultipartBody(getApplication(), "file", thumbnail);
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, thumbnailMultipartBody, description, focus); RequestBody descriptionBody = RequestBody.create(MediaType.parse("text/plain"), description);
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, thumbnailMultipartBody, descriptionBody, focus);
Attachment attachment = null; Attachment attachment = null;
if (attachmentCall != null) { if (attachmentCall != null) {
try { try {