Browse Source

debug

master
Inex Code 4 months ago
parent
commit
6bddb2e0b8
  1. 28
      bin/server.dart

28
bin/server.dart

@ -102,6 +102,9 @@ Future<void> _postOnMastodon(reqJson) async { @@ -102,6 +102,9 @@ Future<void> _postOnMastodon(reqJson) async {
photoUrls = photoUrls.sublist(0, 4);
}
print('photoUrls: $photoUrls');
print('otherPhotos: $otherPhotos');
// Post the post on Mastodon.
// First we upload all photos with dio.
// Then we post the post with the uploaded photos and the text.
@ -132,10 +135,10 @@ Future<void> _postOnMastodon(reqJson) async { @@ -132,10 +135,10 @@ Future<void> _postOnMastodon(reqJson) async {
mediaIds.add(resp.data['id']);
}
var postResponse = await dio.post('$instanceUrl/api/v1/statuses',
data: {'status': postText, 'media_ids': mediaIds},
options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
// var postResponse = await dio.post('$instanceUrl/api/v1/statuses',
// data: {'status': postText, 'media_ids': mediaIds},
// options:
// dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
await Future.wait(photoUrls.map((photoUrl) => File(photoUrl).delete()));
@ -150,6 +153,9 @@ Future<void> _postOnMastodon(reqJson) async { @@ -150,6 +153,9 @@ Future<void> _postOnMastodon(reqJson) async {
otherPhotos = [];
}
print('photoUrls: $photoUrls');
print('otherPhotos: $otherPhotos');
for (final photoUrl in photoUrls) {
final resp = await dio.post('$instanceUrl/api/v1/media',
data: dio_lib.FormData.fromMap(
@ -159,13 +165,13 @@ Future<void> _postOnMastodon(reqJson) async { @@ -159,13 +165,13 @@ Future<void> _postOnMastodon(reqJson) async {
mediaIds.add(resp.data['id']);
}
postResponse = await dio.post('$instanceUrl/api/v1/statuses',
data: {
'in_reply_to_id': postResponse.data['id'],
'media_ids': mediaIds
},
options:
dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
// postResponse = await dio.post('$instanceUrl/api/v1/statuses',
// data: {
// 'in_reply_to_id': postResponse.data['id'],
// 'media_ids': mediaIds
// },
// options:
// dio_lib.Options(headers: {'Authorization': 'Bearer $authToken'}));
await Future.wait(photoUrls.map((photoUrl) => File(photoUrl).delete()));
}

Loading…
Cancel
Save