once again

This commit is contained in:
Inex Code 2022-04-21 06:54:29 +00:00
parent b6b58e8895
commit ef516ce396

View file

@ -106,16 +106,15 @@ Future<void> _postOnMastodon(reqJson) async {
options: options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'})); dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
} else { } else {
final mediaResponses = await photoUrls.map((photoUrl) async => await dio.post( var mediaIds = [];
'$instanceUrl/api/v1/media',
data: dio_lib.FormData.fromMap({'file': File(photoUrl)}),
options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'})));
final mediaIds = mediaResponses.map((mediaResponse) { for (final photoUrl in photoUrls) {
final mediaId = mediaResponse.data['id']; final resp = await dio.post('$instanceUrl/api/v1/media',
return mediaId; data: dio_lib.FormData.fromMap({'file': File(photoUrl)}),
}).toList(); options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
mediaIds.add(resp.data['id']);
}
await dio.post('$instanceUrl/api/v1/statuses', await dio.post('$instanceUrl/api/v1/statuses',
data: {'status': postText, 'media_ids': mediaIds}, data: {'status': postText, 'media_ids': mediaIds},