Fix reference issues with new lexicon#327
Draft
tom-sherman wants to merge 2 commits into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
036a846 to
8715009
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Frontpage DB layer to use more specific AT URI-derived types (ensuring collection + DID actor are explicit) so database operations can safely target records across both legacy and current lexicon collections.
Changes:
- Introduces
PostUri/CommentUri/VoteUriandresolve*Uri()helpers to convert genericAtUriinputs into DB-safe identifiers. - Updates post/comment/vote DB queries and CRUD helpers to key by
(actor, collection, rkey)instead of(authorDid, rkey). - Expands moderation handling to include
fyi.frontpage.feed.*collections and documents the API-layer vs DB-layer URI typing approach.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/frontpage/lib/schema.ts | Makes local NSID constants as const to preserve literal types for Drizzle enums. |
| packages/frontpage/lib/data/db/post.ts | Adds PostUri + resolver; updates DB functions/queries to include collection. |
| packages/frontpage/lib/data/db/comment.ts | Adds CommentUri + resolver; updates DB functions/queries and create/delete inputs to include collection. |
| packages/frontpage/lib/data/db/vote.ts | Adds VoteUri + resolver; updates vote existence/CRUD operations to include collection. |
| packages/frontpage/app/(app)/moderation/_components/report-card.tsx | Uses new { uri: { actor, collection, rkey } } moderation inputs and handles feed collections. |
| docs/frontpage-data-layers.md | Documents rationale for generic AtUri in API layer vs specific URI types in DB layer. |
You can also share your feedback on Copilot code review. Take the survey.
| }); | ||
|
|
||
| export const getPost = cache(async (authorDid: DID, rkey: string) => { | ||
| export const getPost = cache(async (uri: PostUri) => { |
| }; | ||
|
|
||
| export const getComment = cache(async (authorDid: DID, rkey: string) => { | ||
| export const getComment = cache(async (uri: CommentUri) => { |
Comment on lines
+347
to
351
| // TODO: parent and post should include CIDs as they are strongRefs in atproto | ||
| parent?: CommentUri; | ||
| post: PostUri; | ||
| status: "live" | "pending"; | ||
| collection: CommentCollectionType; | ||
| }; |
| authorDid: DID, | ||
| rkey: string, | ||
| ) => { | ||
| export const uncached_doesPostVoteExist = async (uri: VoteUri) => { |
| }; | ||
|
|
||
| export const deleteVote = async ({ authorDid, rkey }: DeleteVoteInput) => { | ||
| export const deleteVote = async (uri: VoteUri) => { |
| status, | ||
| collection, | ||
| }: CreatePostInput) { | ||
| export async function createPost({ post, uri, cid, status }: CreatePostInput) { |
Comment on lines
431
to
434
| export type DeleteCommentInput = { | ||
| rkey: string; | ||
| authorDid: DID; | ||
| }; |
Comment on lines
119
to
+123
| export const createPostVote = async ({ | ||
| repo, | ||
| rkey, | ||
| uri, | ||
| cid, | ||
| subject, | ||
| collection, | ||
| }: CreateVoteInput) => { | ||
| subjectCid, |
Comment on lines
219
to
+221
| type UpdatePostVoteInput = Partial< | ||
| Omit<InferSelectModel<typeof schema.PostVote>, "id"> | ||
| > & { | ||
| authorDid: DID; | ||
| rkey: string; | ||
| }; | ||
|
|
||
| export const updatePostVote = async (input: UpdatePostVoteInput) => { | ||
| const { rkey, authorDid, ...updateFields } = input; | ||
| >; |
Comment on lines
239
to
+241
| type UpdateCommentVoteInput = Partial< | ||
| Omit<InferSelectModel<typeof schema.PostVote>, "id"> | ||
| > & { | ||
| authorDid: DID; | ||
| rkey: string; | ||
| }; | ||
|
|
||
| export const updateCommentVote = async (input: UpdateCommentVoteInput) => { | ||
| const { rkey, authorDid, ...updateFields } = input; | ||
| Omit<InferSelectModel<typeof schema.CommentVote>, "id"> | ||
| >; |
f38843e to
4df3ca6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #318
Ensures that we are passing around the right collection to all of the right places. The collection allows us to reference the correct entity because it's possible for two rows to exist with the same did+rkey in different collections (the old and the new).