[READ ONLY MIRROR] Open Source TikTok alternative built on AT Protocol github.com/sprksocial/client
flutter atproto video dart
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add crosspost to record

+54 -28
+21 -11
lib/src/core/network/atproto/data/adapters/bsky/feed_adapter.dart
··· 807 807 Record toSparkRecord() { 808 808 return when( 809 809 post: 810 - (caption, createdAt, reply, langs, tags, selfLabels, media, sound) => 811 - PostRecord( 812 - caption: caption, 813 - createdAt: createdAt, 814 - reply: reply, 815 - langs: langs, 816 - tags: tags, 817 - selfLabels: selfLabels, 818 - media: media, 819 - sound: sound, 820 - ), 810 + ( 811 + caption, 812 + createdAt, 813 + reply, 814 + langs, 815 + tags, 816 + selfLabels, 817 + crossposts, 818 + media, 819 + sound, 820 + ) => PostRecord( 821 + caption: caption, 822 + createdAt: createdAt, 823 + reply: reply, 824 + langs: langs, 825 + tags: tags, 826 + selfLabels: selfLabels, 827 + crossposts: crossposts, 828 + media: media, 829 + sound: sound, 830 + ), 821 831 reply: (caption, reply, createdAt, langs, labels, media) => ReplyRecord( 822 832 caption: caption, 823 833 reply: reply,
+1
lib/src/core/network/atproto/data/models/record_models.dart
··· 20 20 List<String>? langs, 21 21 List<String>? tags, 22 22 List<SelfLabel>? selfLabels, 23 + List<RepoStrongRef>? crossposts, 23 24 Media? media, 24 25 RepoStrongRef? sound, 25 26 }) = PostRecord;
+15 -3
lib/src/core/network/atproto/data/repositories/feed_repository_impl.dart
··· 991 991 992 992 _logger.i('Image post created successfully: ${result.uri}'); 993 993 994 + var finalResult = result; 995 + 994 996 // Crosspost to Bluesky if enabled 995 997 if (crosspostToBsky) { 996 998 try { 997 - await _crosspostToBlueSky(text, uploadedImageMaps, result, altTexts); 999 + final bskyResult = await _crosspostToBlueSky( 1000 + text, 1001 + uploadedImageMaps, 1002 + result, 1003 + altTexts, 1004 + ); 1005 + finalResult = await _client.repo.editRecord( 1006 + uri: result.uri, 1007 + record: record.copyWith(crossposts: [bskyResult]), 1008 + ); 998 1009 } catch (e) { 999 1010 _logger.w('Failed to crosspost to Bluesky: $e'); 1000 1011 // Don't fail the entire operation if Bluesky crossposting fails 1001 1012 } 1002 1013 } 1003 1014 1004 - return result; 1015 + return finalResult; 1005 1016 } 1006 1017 1007 1018 @override ··· 1287 1298 } 1288 1299 1289 1300 /// Crosspost images to Bluesky using adapter to handle Bluesky-specific model 1290 - Future<void> _crosspostToBlueSky( 1301 + Future<RepoStrongRef> _crosspostToBlueSky( 1291 1302 String text, 1292 1303 List<Image> sparkImages, 1293 1304 RepoStrongRef sparkPostData, ··· 1338 1349 ); 1339 1350 1340 1351 _logger.i('Successfully crossposted to Bluesky: ${bskyResult.uri}'); 1352 + return bskyResult; 1341 1353 } 1342 1354 1343 1355 /// Prepare text for Bluesky post, handling link addition and truncation
+17 -14
lib/src/features/posting/providers/video_upload_provider.dart
··· 65 65 record: postRecord.toJson(), 66 66 ); 67 67 68 + var finalResult = result; 69 + 68 70 if (crosspostToBsky) { 69 71 try { 70 - await _crosspostVideoToBlueSky( 72 + final bskyResult = await _crosspostVideoToBlueSky( 71 73 ref, 72 74 description, 73 75 blob, 74 76 altText, 75 77 result.uri.rkey, 76 78 ); 79 + finalResult = await GetIt.I<SprkRepository>().repo.editRecord( 80 + uri: result.uri, 81 + record: postRecord.copyWith(crossposts: [bskyResult]), 82 + ); 77 83 } catch (e, s) { 78 84 logger.w('Crosspost to Bluesky failed: $e', error: e, stackTrace: s); 79 85 } 80 86 } 81 - logger.i('Video posted successfully: ${result.uri}'); 82 - return result; 87 + logger.i('Video posted successfully: ${finalResult.uri}'); 88 + return finalResult; 83 89 } catch (error, stackTrace) { 84 90 logger.e('Error posting video', error: error, stackTrace: stackTrace); 85 91 } ··· 163 169 164 170 /// Crosspost video to Bluesky using same blob but Bluesky models 165 171 @riverpod 166 - Future<void> _crosspostVideoToBlueSky( 172 + Future<RepoStrongRef> _crosspostVideoToBlueSky( 167 173 Ref ref, 168 174 String text, 169 175 Blob blob, ··· 184 190 'createdAt': DateTime.now().toUtc().toIso8601String(), 185 191 }; 186 192 187 - try { 188 - final result = await GetIt.I<SprkRepository>().repo.createRecord( 189 - collection: 'app.bsky.feed.post', 190 - record: bskyPostRecord, 191 - rkey: rkey, 192 - ); 193 - logger.i('Crossposted video to Bluesky: ${result.uri}'); 194 - } catch (e, s) { 195 - logger.w('Failed to crosspost video: $e', error: e, stackTrace: s); 196 - } 193 + final result = await GetIt.I<SprkRepository>().repo.createRecord( 194 + collection: 'app.bsky.feed.post', 195 + record: bskyPostRecord, 196 + rkey: rkey, 197 + ); 198 + logger.i('Crossposted video to Bluesky: ${result.uri}'); 199 + return result; 197 200 }