Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/videah/skybridge
Browse files Browse the repository at this point in the history
  • Loading branch information
videah committed Jan 16, 2024
2 parents 7f8107c + bd1179a commit 55b9fb7
Show file tree
Hide file tree
Showing 31 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion lib/models/mastodon/mastodon_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MastodonNotification {
final posts = await chunkResults<bsky.Post, bsky.AtUri>(
items: postUris,
callback: (chunk) async {
final response = await bluesky.feeds.findPosts(uris: chunk);
final response = await bluesky.feed.getPosts(uris: chunk);
return response.data.posts;
},
);
Expand Down
10 changes: 5 additions & 5 deletions lib/models/mastodon/mastodon_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class MastodonPost {
// the account that reposted it.
id = (await repostToDatabase(view)).id;

account = await MastodonAccount.fromActor(repost.data.by);
account = await MastodonAccount.fromActor(repost.data.by.toActor());
} else {
account = await MastodonAccount.fromActor(post.author);
account = await MastodonAccount.fromActor(post.author.toActor());
}

// Construct URL/URI
Expand Down Expand Up @@ -204,7 +204,7 @@ class MastodonPost {
/// Converts a [bsky.Post] to a [MastodonPost].
static Future<MastodonPost> fromBlueSkyPost(bsky.Post post) async {
final mediaAttachments = <MastodonMediaAttachment>[];
final account = await MastodonAccount.fromActor(post.author);
final account = await MastodonAccount.fromActor(post.author.toActor());

final embed = post.embed;
if (embed != null) {
Expand Down Expand Up @@ -315,7 +315,7 @@ class MastodonPost {
final createdAt = DateTime.now().toUtc();

// Create the appropriate bluesky record.
await bluesky.repositories.createRecord(
await bluesky.repo.createRecord(
collection: at.NSID.create('feed.bsky.app', 'repost'),
record: {
'subject': {
Expand Down Expand Up @@ -516,7 +516,7 @@ Future<List<MastodonPost>> processParentPosts(
final results = await chunkResults<bsky.Post, bsky.AtUri>(
items: uris,
callback: (chunk) async {
final response = await bluesky.feeds.findPosts(uris: chunk);
final response = await bluesky.feed.getPosts(uris: chunk);
return response.data.posts;
},
);
Expand Down
2 changes: 1 addition & 1 deletion lib/models/mastodon/mastodon_relationship.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MastodonRelationship {
) async {
// Get the profile for the account and check the relationship with the
// current user.
final profile = await bluesky.actors.findProfile(actor: account.did);
final profile = await bluesky.actor.getProfile(actor: account.did);
final blocking = profile.data.viewer.blocking != null;
final blockedBy = profile.data.viewer.isBlockedBy;
final muting = profile.data.viewer.isMuted;
Expand Down
36 changes: 18 additions & 18 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,34 @@ packages:
dependency: transitive
description:
name: at_identifier
sha256: "128cfdc95a877973e3349845589f974043ca4c3ce55726e9b530ab866f39bc18"
sha256: "3f17d5efab5e34d4b6cfe357d5e97558536ca19892951dedd821e01b0c8d33f6"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.2.1"
at_uri:
dependency: transitive
description:
name: at_uri
sha256: "0a10c6b18c3deecd81ece36964ee698ee9ba3f8a07c870b2c9a0a76e432e8f7f"
sha256: c708205d126e1d3356f8c75a1548522f49b26c2b2eaa95b5cfc011d2444604a4
url: "https://pub.dev"
source: hosted
version: "0.2.2"
version: "0.2.3"
atproto:
dependency: "direct main"
description:
name: atproto
sha256: "61daa27eabfd1774a24b197eaf998bf27c315182cc2c23c2840cb2612225b58e"
sha256: "015af8457bd1ae08d3b99bcddbead971f8722ad7abb5ddafeb5acfe5602b548b"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.11.0"
atproto_core:
dependency: transitive
description:
name: atproto_core
sha256: "4d59a48935e44aaa80e1f96fc8bd03aa5ce5dd3b77623d6d04159f19a23853f1"
sha256: c25c7c4fe163f5dd206ce53f890d3805429ca3135d27ae490b9979a2bfe217df
url: "https://pub.dev"
source: hosted
version: "0.5.9"
version: "0.9.0"
base_codecs:
dependency: transitive
description:
Expand All @@ -101,18 +101,18 @@ packages:
dependency: "direct main"
description:
name: bluesky
sha256: "805c83fb5be7e09282bcae9afaf3de034f012a1e0e52cb36318cc44bb9bd6f24"
sha256: "77df53a9dc5e74ea5b30d3d2b6f7d93a05b0899aaa2efc7a19455d9c3570547c"
url: "https://pub.dev"
source: hosted
version: "0.9.3"
version: "0.15.1"
bluesky_text:
dependency: "direct main"
description:
name: bluesky_text
sha256: "1c52365e84e0ec8ce4a4bf46088be870b9aa152c0f825e9e93389900ccd685d4"
sha256: "0ff7bfe120fbe9004cbc9dac12cf8600e34e72ed973bec95ff1039e19081485e"
url: "https://pub.dev"
source: hosted
version: "0.5.15"
version: "0.6.4"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -653,10 +653,10 @@ packages:
dependency: transitive
description:
name: multiformats
sha256: c3c6bb1be062333eff159f1d04fc3a1ed02c89a58d0fdaf59daaa8b7a6fd9e81
sha256: ccaa1d4aa5bd57f1d132fc955ef2fd259e4115a80a10b4ce525c2b3d3ddfc260
url: "https://pub.dev"
source: hosted
version: "0.2.1"
version: "0.2.2"
node_preamble:
dependency: transitive
description:
Expand All @@ -669,10 +669,10 @@ packages:
dependency: transitive
description:
name: nsid
sha256: "65240e4cc13c1d1c096c65bffd8259998ea1dc46a8820150117b1a66baea6324"
sha256: c03f59aa01eb8bc0dd5e4575b51bb45b276214a1bc36b49029830a4950aaad20
url: "https://pub.dev"
source: hosted
version: "0.2.1"
version: "0.3.0"
orm:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1053,10 +1053,10 @@ packages:
dependency: transitive
description:
name: xrpc
sha256: c775f878a32a5b5f9e7a0274628d0f7e720069f2500a873bb359992d03fd3b87
sha256: a94544be95d5948c60304b4493d89f65dd88cb5c9ee7aabdeebcc23c192a20f3
url: "https://pub.dev"
source: hosted
version: "0.3.3"
version: "0.4.3"
xxh3:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
atproto: ^0.7.2
bluesky: ^0.9.3
bluesky_text: ^0.5.15
atproto: ^0.11.0
bluesky: ^0.15.1
bluesky_text: ^0.6.4
collection: ^1.17.1
copy_with_extension: ^5.0.2
crypto: ^3.0.2
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/accounts/[id]/follow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
if (did == null) Response(statusCode: HttpStatus.notFound);

// Check if we're already following the account.
final profile = await bluesky.actors.findProfile(actor: did!);
final profile = await bluesky.actor.getProfile(actor: did!);
final alreadyFollowing = profile.data.viewer.following != null;

// If we're not following the account, create a follow record.
if (!alreadyFollowing) await bluesky.graphs.createFollow(did: did);
if (!alreadyFollowing) await bluesky.graph.follow(did: did);

final rel = await MastodonRelationship.getActorRelationship(bluesky, record!);

Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/accounts/[id]/followers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
);
if (userRecord == null) return Response(statusCode: HttpStatus.notFound);

final response = await bluesky.graphs.findFollowers(actor: userRecord.did);
final response = await bluesky.graph.getFollowers(actor: userRecord.did);

// Get all the handles from the results and grab the full profile info.
final handles = response.data.followers.map((actor) => actor.handle).toList();
Expand All @@ -35,7 +35,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
final profiles = await chunkResults<bsky.ActorProfile, String>(
items: handles,
callback: (chunk) async {
final response = await bluesky.actors.findProfiles(actors: chunk);
final response = await bluesky.actor.getProfiles(actors: chunk);
return response.data.profiles;
},
);
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/accounts/[id]/following.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
);
if (userRecord == null) return Response(statusCode: HttpStatus.notFound);

final response = await bluesky.graphs.findFollows(actor: userRecord.did);
final response = await bluesky.graph.getFollows(actor: userRecord.did);

// Get all the handles from the results and grab the full profile info.
final handles = response.data.follows.map((actor) => actor.handle).toList();
Expand All @@ -35,7 +35,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
final profiles = await chunkResults<bsky.ActorProfile, String>(
items: handles,
callback: (chunk) async {
final response = await bluesky.actors.findProfiles(actors: chunk);
final response = await bluesky.actor.getProfiles(actors: chunk);
return response.data.profiles;
},
);
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/accounts/[id]/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
return Response(statusCode: HttpStatus.notFound);
}

final profile = await bluesky.actors.findProfile(actor: user.did);
final profile = await bluesky.actor.getProfile(actor: user.did);

final account = await databaseTransaction(
() => MastodonAccount.fromActorProfile(profile.data),
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/accounts/[id]/statuses.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Future<Response> onRequest(RequestContext context, String id) async {
}

// Get the users posts.
final feed = await bluesky.feeds.findFeed(actor: user.did, limit: 40);
final feed = await bluesky.feed.getAuthorFeed(actor: user.did, limit: 40);

// Take all the posts and convert them to MastodonPost futures
// Await all the futures, getting any necessary data from the database.
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/accounts/[id]/unfollow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
final did = record?.did;
if (did == null) Response(statusCode: HttpStatus.notFound);

final profile = await bluesky.actors.findProfile(actor: did!);
final profile = await bluesky.actor.getProfile(actor: did!);

// Check if we are actually following the account and get the follow uri
// so we can delete it. Otherwise we just skip this step and return
// the relationship.
final followUri = profile.data.viewer.following;
if (followUri != null) {
await bluesky.repositories.deleteRecord(uri: followUri);
await bluesky.repo.deleteRecord(uri: followUri);
}

final rel = await MastodonRelationship.getActorRelationship(bluesky, record!);
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/accounts/lookup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Future<Response> onRequest(RequestContext context) async {
if (bluesky == null) return authError();

// Get the profile for the given handle.
final profile = await bluesky.actors.findProfile(actor: encodedParams.acct);
final profile = await bluesky.actor.getProfile(actor: encodedParams.acct);
final account = await databaseTransaction(
() => MastodonAccount.fromActorProfile(profile.data),
);
Expand Down
6 changes: 3 additions & 3 deletions routes/api/v1/accounts/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Future<Response> onRequest(RequestContext context) async {
);

final handle = encodedParams.query.replaceFirst('@$base', '');
profile = (await bluesky.actors.findProfile(actor: handle)).data;
profile = (await bluesky.actor.getProfile(actor: handle)).data;
} catch (e) {
// We just assume no account exists for now.
print('Could not find profile with handle: ${encodedParams.query}');
Expand All @@ -47,7 +47,7 @@ Future<Response> onRequest(RequestContext context) async {
);
} else {
// We assume that the query is a general search query.
final results = await bluesky.actors.searchActors(
final results = await bluesky.actor.searchActors(
term: encodedParams.query,
limit: encodedParams.limit,
);
Expand All @@ -58,7 +58,7 @@ Future<Response> onRequest(RequestContext context) async {
final profiles = await chunkResults<bsky.ActorProfile, String>(
items: handles,
callback: (chunk) async {
final response = await bluesky.actors.findProfiles(actors: chunk);
final response = await bluesky.actor.getProfiles(actors: chunk);
return response.data.profiles;
},
);
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/accounts/verify_credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Future<Response> onRequest(RequestContext context) async {
if (session == null) return authError();
final bluesky = bsky.Bluesky.fromSession(session);

final profile = await bluesky.actors.findProfile(actor: session.did);
final profile = await bluesky.actor.getProfile(actor: session.did);

final account = await databaseTransaction(
() => MastodonAccount.fromActorProfile(profile.data),
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/lists/[id]/accounts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
if (record == null) Response(statusCode: HttpStatus.notFound);

// Get up to date profile information and convert it to a [MastodonAccount].
final response = await bluesky.actors.findProfile(actor: record!.did);
final response = await bluesky.actor.getProfile(actor: record!.did);
final profile = await databaseTransaction(
() => MastodonAccount.fromActorProfile(response.data),
);
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/lists/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Future<Response> onRequest(RequestContext context) async {
var lists = <MastodonList>[];

// Get saved feeds from the user's preferences.
final response = await bluesky.actors.findPreferences();
final response = await bluesky.actor.getPreferences();
for (final preference in response.data.preferences) {
await preference.map(
adultContent: (_) {},
Expand All @@ -35,7 +35,7 @@ Future<Response> onRequest(RequestContext context) async {
final result = await chunkResults<bsky.FeedGeneratorView, bsky.AtUri>(
items: feedUris.data.savedUris,
callback: (chunk) async {
final response = await bluesky.feeds.findGenerators(
final response = await bluesky.feed.getFeedGenerators(
uris: feedUris.data.savedUris,
);
return response.data.feeds;
Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/notifications/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<Response> onRequest<T>(RequestContext context) async {

final limit = encodedParams.limit <= 100 ? encodedParams.limit : 100;
// Fetch the notifications with the given parameters.
final response = await bluesky.notifications.findNotifications(
final response = await bluesky.notification.listNotifications(
limit: limit,
);

Expand Down
2 changes: 1 addition & 1 deletion routes/api/v1/statuses/[id]/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
);
if (postRecord == null) Response(statusCode: HttpStatus.notFound);

final posts = await bluesky.feeds.findPostThread(
final posts = await bluesky.feed.getPostThread(
uri: bsky.AtUri.parse(postRecord!.uri),
);

Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/statuses/[id]/favourite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
// Get the post from bluesky, we assume we already know the post exists
// and don't bother adding to the database or anything.
final uri = bsky.AtUri.parse(postRecord!.uri);
final response = await bluesky.feeds.findPosts(uris: [uri]);
final response = await bluesky.feed.getPosts(uris: [uri]);
final post = response.data.posts.first;

// Get the user who posted this from the database.
Expand All @@ -56,7 +56,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
);

// Like the post now that we have everything in order.
await bluesky.feeds.createLike(cid: post.cid, uri: post.uri);
await bluesky.feed.like(cid: post.cid, uri: post.uri);
mastodonPost
..favourited = true
..favouritesCount += 1;
Expand Down
4 changes: 2 additions & 2 deletions routes/api/v1/statuses/[id]/favourited_by.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
);
if (postRecord == null) Response(statusCode: HttpStatus.notFound);

final response = await bluesky.feeds.findLikes(
final response = await bluesky.feed.getLikes(
uri: bsky.AtUri.parse(postRecord!.uri),
);

Expand All @@ -47,7 +47,7 @@ Future<Response> onRequest<T>(RequestContext context, String id) async {
final profiles = await chunkResults<bsky.ActorProfile, String>(
items: handles,
callback: (chunk) async {
final response = await bluesky.actors.findProfiles(actors: chunk);
final response = await bluesky.actor.getProfiles(actors: chunk);
return response.data.profiles;
},
);
Expand Down
Loading

0 comments on commit 55b9fb7

Please sign in to comment.