Skip to content

Fix reference issues with new lexicon#327

Draft
tom-sherman wants to merge 2 commits into
mainfrom
fyi-frontpage-lexicon-comment-vote-bugs
Draft

Fix reference issues with new lexicon#327
tom-sherman wants to merge 2 commits into
mainfrom
fyi-frontpage-lexicon-comment-vote-bugs

Conversation

@tom-sherman
Copy link
Copy Markdown
Contributor

@tom-sherman tom-sherman commented Jan 2, 2026

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).

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
atproto-browser Error Error Apr 16, 2026 0:44am
frontpage Error Error Apr 16, 2026 0:44am
frontpage-oauth-preview-client Ready Ready Preview, Comment Apr 16, 2026 0:44am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation frontpage labels Jan 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/VoteUri and resolve*Uri() helpers to convert generic AtUri inputs 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">
>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comment/vote issues on fyi.frontpage.* records

2 participants