Skip to content

Commit 76048de

Browse files
committed
[Bug Fix] Validate reply references via the AppView for cross-PDS replies
`isValidReplyReference` resolved the root and parent records through the posting user's PDS (`session.pdsURL`). `com.atproto.repo.getRecord` served by a single PDS only returns records for the repositories that PDS hosts, so any reply whose root or parent is authored on a different PDS failed validation. `createPostRecord` then threw `invalidReplyReference`, blocking otherwise-valid replies to users on third-party PDSes. Resolve both records through Bluesky's AppView (`APIHostname.bskyAppView`), which resolves records across PDSes. Also removes a duplicated-scheme typo in the root fallback URL (`https://https://`).
1 parent 72b977e commit 76048de

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Sources/ATProtoKit/Utilities/ATProtoTools.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public struct ATProtoTools {
3131

3232
/// Determines whether the reply reference is valid.
3333
///
34+
/// Both the root and parent records are resolved through Bluesky's AppView
35+
/// (``APIHostname/bskyAppView``) rather than through a specific Personal Data Server (PDS).
36+
/// A reply reference can point to records authored on any PDS, and
37+
/// `com.atproto.repo.getRecord` served by a single PDS only returns records for the
38+
/// repositories that PDS hosts. Resolving through the AppView allows references to records
39+
/// on other PDSes to validate correctly.
40+
///
3441
/// - Parameters:
3542
/// - reference: The reply reference object to check for validity.
3643
/// - session: The ``UserSession`` instance in relation to the reply. Optional.
@@ -51,7 +58,7 @@ public struct ATProtoTools {
5158
return false
5259
}
5360

54-
_ = try await ATProtoKit(pdsURL: session?.pdsURL ?? "https://https://public.api.bsky.app", canUseBlueskyRecords: false).getRepositoryRecord(
61+
_ = try await ATProtoKit(pdsURL: APIHostname.bskyAppView, canUseBlueskyRecords: false).getRepositoryRecord(
5562
from: repository,
5663
collection: collection,
5764
recordKey: recordKey
@@ -70,7 +77,7 @@ public struct ATProtoTools {
7077
return false
7178
}
7279

73-
_ = try await ATProtoKit(pdsURL: session?.pdsURL ?? "https://public.api.bsky.app", canUseBlueskyRecords: false).getRepositoryRecord(
80+
_ = try await ATProtoKit(pdsURL: APIHostname.bskyAppView, canUseBlueskyRecords: false).getRepositoryRecord(
7481
from: repository,
7582
collection: collection,
7683
recordKey: recordKey

0 commit comments

Comments
 (0)