diff --git a/bin/server.dart b/bin/server.dart index ab88a0c..24799e3 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -79,7 +79,9 @@ Future _postOnMastodon(reqJson) async { final photos = attachments.where((attachment) => attachment['type'] == 'photo'); - final photoUrls = photos.map((photo) async { + List photoUrls = []; + + for (final photo in photos) { final photoUrl = photo['photo']['sizes'].last['url']; // Generate a random filename. // Add the extension '.jpg'. @@ -87,8 +89,8 @@ Future _postOnMastodon(reqJson) async { final photoPath = '${Directory.systemTemp.path}/$photoFilename'; await dio.download(photoUrl, photoPath); - return photoPath; - }); + photoUrls.add(photoPath); + } // Post the post on Mastodon. // First we upload all photos with dio.