diff --git a/bun.lockb b/bun.lockb index ffd0b54b..5b2b015c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/src/lib/client/piefed/rewrite.ts b/src/lib/client/piefed/rewrite.ts index 2467d3b9..29a413a0 100644 --- a/src/lib/client/piefed/rewrite.ts +++ b/src/lib/client/piefed/rewrite.ts @@ -232,11 +232,11 @@ export function toFeedView( // Query calls export function fromGetPosts( getPosts: GetPosts, -): components['schemas']['GetPosts'] { +): components['parameters']['GetPosts'] { return { ...getPosts, sort: toSortType(getPosts.sort), - page_cursor: Number(getPosts.page_cursor), + page: Number(getPosts.page_cursor), } } diff --git a/src/lib/client/piefed/schema.d.ts b/src/lib/client/piefed/schema.d.ts index a88eac6b..26048a36 100644 --- a/src/lib/client/piefed/schema.d.ts +++ b/src/lib/client/piefed/schema.d.ts @@ -260,6 +260,7 @@ export interface paths { | 'Subscribed' | 'Popular' | 'Moderating' + | 'ModeratorView' page?: number sort?: | 'Active' @@ -277,6 +278,7 @@ export interface paths { | 'TopYear' | 'TopAll' | 'Scaled' + | 'Old' community_name?: string community_id?: number } @@ -1301,6 +1303,7 @@ export interface paths { | 'TopYear' | 'TopAll' | 'Scaled' + | 'Old' page?: number limit?: number /** @description Limit posts/comments to just a single community */ @@ -2685,6 +2688,7 @@ export interface paths { | 'TopSixHour' | 'TopTwelveHour' | 'TopWeek' + | 'TopDay' | 'TopMonth' | 'TopThreeMonths' | 'TopSixMonths' @@ -2694,7 +2698,13 @@ export interface paths { | 'New' | 'Scaled' | 'Active' - type_?: 'All' | 'Local' | 'Subscribed' + type_?: + | 'All' + | 'Local' + | 'Subscribed' + | 'Popular' + | 'Moderating' + | 'ModeratorView' community_name?: string community_id?: number saved_only?: boolean @@ -3645,6 +3655,349 @@ export interface paths { patch?: never trace?: never } + '/api/alpha/private_message/list': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + /** List private messages. */ + get: { + parameters: { + query?: { + page?: number + limit?: number + unread_only?: boolean + } + header?: never + path?: never + cookie?: never + } + requestBody?: never + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['ListPrivateMessagesResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + } + } + put?: never + post?: never + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } + '/api/alpha/private_message/conversation': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + /** Get conversation with a specific person. */ + get: { + parameters: { + query: { + person_id: number + page?: number + limit?: number + } + header?: never + path?: never + cookie?: never + } + requestBody?: never + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['GetPrivateMessageConversationResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + } + } + put?: never + post?: never + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } + '/api/alpha/private_message': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + get?: never + /** Edit a private message. */ + put: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody: { + content: { + 'application/json': components['schemas']['EditPrivateMessageRequest'] + } + } + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['PrivateMessageResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + } + } + /** Create a new private message. */ + post: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody: { + content: { + 'application/json': components['schemas']['CreatePrivateMessageRequest'] + } + } + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['PrivateMessageResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + /** @description Too Many Requests */ + 429: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + } + } + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } + '/api/alpha/private_message/mark_as_read': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + get?: never + put?: never + /** Mark a private message as read or unread. */ + post: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody: { + content: { + 'application/json': components['schemas']['MarkPrivateMessageAsReadRequest'] + } + } + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['PrivateMessageResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + } + } + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } + '/api/alpha/private_message/delete': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + get?: never + put?: never + /** Delete or restore a private message. */ + post: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody: { + content: { + 'application/json': components['schemas']['DeletePrivateMessageRequest'] + } + } + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['PrivateMessageResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + } + } + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } + '/api/alpha/private_message/report': { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + get?: never + put?: never + /** Report a private message. */ + post: { + parameters: { + query?: never + header?: never + path?: never + cookie?: never + } + requestBody: { + content: { + 'application/json': components['schemas']['ReportPrivateMessageRequest'] + } + } + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['PrivateMessageResponse'] + } + } + /** @description Bad Request */ + 400: { + headers: { + [name: string]: unknown + } + content: { + 'application/json': components['schemas']['DefaultError'] + } + } + 422: components['responses']['UNPROCESSABLE_CONTENT'] + } + } + delete?: never + options?: never + head?: never + patch?: never + trace?: never + } } export type webhooks = Record export interface components { @@ -3696,12 +4049,16 @@ export interface components { /** Format: html */ about_html?: string /** Format: url */ - avatar?: string + avatar?: string | null /** Format: url */ - banner?: string + banner?: string | null flair?: string - published: string - title?: string + /** + * Format: datetime + * @example 2025-06-07T02:29:07.980084Z + */ + published?: string + title?: string | null } PersonView: { activity_alert: boolean @@ -3762,12 +4119,12 @@ export interface components { title: string banned?: boolean /** Format: url */ - banner?: string + banner?: string | null /** Format: markdown */ description?: string /** Format: url */ - icon?: string - posting_warning?: string + icon?: string | null + posting_warning?: string | null /** * Format: datetime * @example 2025-06-07T02:29:07.980084Z @@ -3775,8 +4132,8 @@ export interface components { updated?: string } CommunityBlockView: { - community: components['schemas']['Community'] - person: components['schemas']['Person'] + community?: components['schemas']['Community'] + person?: components['schemas']['Person'] } CommunityFollowerView: { community: components['schemas']['Community'] @@ -3813,8 +4170,9 @@ export interface components { | 'Subscribed' | 'Popular' | 'Moderating' + | 'ModeratorView' /** @enum {string} */ - default_sort_type: + default_sort_type?: | 'Active' | 'Hot' | 'New' @@ -3830,6 +4188,7 @@ export interface components { | 'TopYear' | 'TopAll' | 'Scaled' + | 'Old' show_bot_accounts: boolean show_nsfl: boolean show_nsfw: boolean @@ -3948,7 +4307,7 @@ export interface components { * Format: url * @description Legacy tags that existed prior to 1.2 and some tags for remote communities might not have a defined ap_id */ - ap_id: string + ap_id: string | null } CommunityView: { activity_alert: boolean @@ -3975,6 +4334,16 @@ export interface components { published: string score: number upvotes: number + cross_posts: number + } + WidthHeight: { + width?: number + height?: number + } + MiniCrossPosts: { + post_id?: number + reply_count?: number + community_name?: string } Post: { /** Format: url */ @@ -4009,6 +4378,8 @@ export interface components { updated?: string /** Format: url */ url?: string + image_details?: components['schemas']['WidthHeight'] + cross_posts?: components['schemas']['MiniCrossPosts'][] } PostView: { banned_from_community: boolean @@ -4130,7 +4501,7 @@ export interface components { } ListCommunitiesResponse: { communities: components['schemas']['CommunityView'][] - next_page?: string + next_page?: string | null } FollowCommunityRequest: { community_id: number @@ -4152,12 +4523,12 @@ export interface components { name: string title: string /** Format: url */ - banner_url?: string + banner_url?: string | null /** Format: markdown */ description?: string discussion_languages?: number[] /** Format: url */ - icon_url?: string + icon_url?: string | null local_only?: boolean nsfw?: boolean restricted_to_mods?: boolean @@ -4167,12 +4538,12 @@ export interface components { community_id: number title?: string /** Format: url */ - banner_url?: string + banner_url?: string | null /** Format: markdown */ description?: string discussion_languages?: number[] /** Format: url */ - icon_url?: string + icon_url?: string | null local_only?: boolean nsfw?: boolean restricted_to_mods?: boolean @@ -4203,17 +4574,17 @@ export interface components { * Format: datetime * @example 2025-06-07T02:29:07.980084Z, null=permanent ban */ - expired_at?: string + expired_at?: string | null /** * Format: datetime * @example 2025-06-07T02:29:07.980084Z, null=permanent ban */ - expires_at?: string + expires_at?: string | null reason?: string } CommunityModerationBansListResponse: { items?: components['schemas']['CommunityModerationBanItem'][] - next_page?: string + next_page?: string | null } CommunityModerationUnbanRequest: { community_id: number @@ -4271,7 +4642,7 @@ export interface components { * Format: url * @description Legacy tags that existed prior to 1.2 and some tags for remote communities might not have a defined ap_id */ - ap_id: string + ap_id: string | null } CommunityFlairEditRequest: { flair_id: number @@ -4307,7 +4678,7 @@ export interface components { * Format: url * @description Legacy tags that existed prior to 1.2 and some tags for remote communities might not have a defined ap_id */ - ap_id: string + ap_id: string | null } CommunityFlairDeleteRequest: { flair_id: number @@ -4351,14 +4722,14 @@ export interface components { /** @description user_id of the feed creator/owner */ user_id: number /** Format: url */ - banner?: string + banner?: string | null /** Format: markdown */ - description?: string + description?: string | null /** Format: html */ - description_html?: string + description_html?: string | null /** Format: url */ - icon?: string - parent_feed_id?: number + icon?: string | null + parent_feed_id?: number | null } FeedListResponse: { feeds: components['schemas']['FeedView'][] @@ -4371,7 +4742,7 @@ export interface components { name: string show_posts_from_children: boolean title: string - parent_topic_id?: number + parent_topic_id?: number | null } TopicListResponse: { topics: components['schemas']['TopicView'][] @@ -4429,11 +4800,11 @@ export interface components { subscribed: 'Subscribed' | 'NotSubscribed' | 'Pending' } UserRepliesResponse: { - next_page: number + next_page?: string | null replies: components['schemas']['CommentReplyView'][] } UserMentionsResponse: { - next_page: number + next_page?: string | null replies: components['schemas']['CommentReplyView'][] } UserBlockRequest: { @@ -4461,14 +4832,14 @@ export interface components { * Format: url * @description Pass a null value to remove the image */ - avatar?: string + avatar?: string | null /** Format: markdown */ bio?: string /** * Format: url * @description Pass a null value to remove the image */ - cover?: string + cover?: string | null /** @enum {string} */ default_comment_sort_type?: 'Hot' | 'Top' | 'New' | 'Old' /** @enum {string} */ @@ -4518,7 +4889,7 @@ export interface components { /** @enum {string} */ status: 'All' | 'Unread' | 'Read' username: string - next_page: number + next_page?: string | null } UserNotificationStateRequest: { notif_id: number @@ -4535,14 +4906,14 @@ export interface components { UserSetFlairRequest: { community_id: number /** @description Either omit or set to null to remove existing flair */ - flair_text?: string + flair_text?: string | null } UserSetFlairResponse: { person_view: components['schemas']['PersonView'] } ListCommentsResponse: { comments: components['schemas']['CommentView'][] - next_page?: string + next_page?: string | null } LikeCommentRequest: { comment_id: number @@ -4578,7 +4949,11 @@ export interface components { body: string comment_id: number language_id?: number - distinguished?: boolean + /** + * @description Visibly mark reply as from a moderator in the web UI + * @default false + */ + distinguished: boolean } DeleteCommentRequest: { comment_id: number @@ -4598,7 +4973,7 @@ export interface components { id: number creator_id: number comment_id: number - original_comment_text: string + original_comment_text?: string reason?: string resolved: boolean /** @@ -4657,12 +5032,12 @@ export interface components { creator: components['schemas']['Person'] } ListCommentLikesResponse: { - comment_likes?: components['schemas']['CommentLikeView'][] - next_page?: string + comment_likes: components['schemas']['CommentLikeView'][] + next_page?: string | null } ListPostsResponse: { posts: components['schemas']['PostView'][] - next_page?: string + next_page?: string | null } GetPostResponse: { post_view: components['schemas']['PostView'] @@ -4690,12 +5065,13 @@ export interface components { } GetPostRepliesResponse: { comments?: components['schemas']['PostReplyView'][] - next_page?: string + next_page?: string | null } LikePostRequest: { post_id: number score: number private?: boolean + auth?: string } SavePostRequest: { post_id: number @@ -4739,7 +5115,11 @@ export interface components { original_post_body: string reason: string resolved: boolean - published: string + /** + * Format: datetime + * @example 2025-06-07T02:29:07.980084Z + */ + published?: string } PostReportView: { post_report: components['schemas']['PostReport'] @@ -4788,13 +5168,13 @@ export interface components { creator: components['schemas']['Person'] } ListPostLikesResponse: { - post_likes?: components['schemas']['PostLikeView'][] - next_page?: string + post_likes: components['schemas']['PostLikeView'][] + next_page?: string | null } PostSetFlairRequest: { post_id: number /** @description A list of all the flair id to assign to the post. Either pass an empty list or null to remove flair */ - flair_id_list?: number[] + flair_id_list?: number[] | null } PostSetFlairResponse: { banned_from_community: boolean @@ -4826,6 +5206,56 @@ export interface components { saved_only?: boolean q?: string } + PrivateMessage: { + id: number + creator_id: number + recipient_id: number + content: string + deleted: boolean + read: boolean + /** + * Format: datetime + * @example 2025-06-07T02:29:07.980084Z + */ + published: string + /** Format: url */ + ap_id: string + local: boolean + } + PrivateMessageView: { + private_message: components['schemas']['PrivateMessage'] + creator: components['schemas']['Person'] + recipient: components['schemas']['Person'] + } + ListPrivateMessagesResponse: { + private_messages: components['schemas']['PrivateMessageView'][] + } + GetPrivateMessageConversationResponse: { + private_messages: components['schemas']['PrivateMessageView'][] + } + CreatePrivateMessageRequest: { + content: string + recipient_id: number + } + PrivateMessageResponse: { + private_message_view: components['schemas']['PrivateMessageView'] + } + EditPrivateMessageRequest: { + private_message_id: number + content: string + } + MarkPrivateMessageAsReadRequest: { + private_message_id: number + read: boolean + } + DeletePrivateMessageRequest: { + private_message_id: number + deleted: boolean + } + ReportPrivateMessageRequest: { + private_message_id: number + reason: string + } } responses: { /** @description Unprocessable Content */ diff --git a/src/lib/client/types/schemas/GetPostsResponse.ts b/src/lib/client/types/schemas/GetPostsResponse.ts index d055fb80..3348090b 100644 --- a/src/lib/client/types/schemas/GetPostsResponse.ts +++ b/src/lib/client/types/schemas/GetPostsResponse.ts @@ -2,5 +2,5 @@ import type { PaginationCursor } from './schemas' import type { PostView } from './schemas' export interface GetPostsResponse { posts: Array - next_page?: PaginationCursor + next_page: PaginationCursor } diff --git a/src/lib/lemmy/feeds/feed.svelte.ts b/src/lib/lemmy/feeds/feed.svelte.ts index 400ac527..4a2e642c 100644 --- a/src/lib/lemmy/feeds/feed.svelte.ts +++ b/src/lib/lemmy/feeds/feed.svelte.ts @@ -56,7 +56,7 @@ export interface FeedTypes { { posts: PostView[] next_page?: string - params: GetPosts + params: GetPostss & { page_cursor: string } client: { itemHeights?: (number | null)[] lastSeen?: number @@ -69,7 +69,7 @@ export interface FeedTypes { posts: PostView[] community: GetCommunityResponse next_page?: string - params: GetPosts + params: GetPosts & { page_cursor: string } client: { itemHeights?: (number | null)[]; lastSeen?: number } }, ] @@ -110,7 +110,7 @@ export interface FeedTypes { { posts: PostView[] next_page?: string - params: GetPosts + params: GetPosts & { page_cursor: string } feed: Promise client: { itemHeights?: (number | null)[] @@ -123,7 +123,7 @@ export interface FeedTypes { { posts: PostView[] next_page?: string - params: GetPosts + params: GetPosts & { page_cursor: string } topic: Promise client: { itemHeights?: (number | null)[] diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 29bb728f..f5650f97 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -14,11 +14,14 @@ export async function load({ url, fetch, route }) { const listingType: ListingType = (url.searchParams.get('type') as ListingType) || settings.defaultSort.feed - const feedData = feed(route.id, async (params) => ({ - ...(await client({ func: fetch }).getPosts(params)), - params: params, - client: {}, - })).load({ + const feedData = feed(route.id, async (params) => { + const posts = await client({ func: fetch }).getPosts(params) + return { + ...posts, + params: { ...params, page_cursor: posts.next_page }, + client: {}, + } + }).load({ page_cursor: cursor, sort: sort, type_: listingType, diff --git a/src/routes/c/[name]/+page.svelte b/src/routes/c/[name]/+page.svelte index 4856b2a8..229beb33 100644 --- a/src/routes/c/[name]/+page.svelte +++ b/src/routes/c/[name]/+page.svelte @@ -51,13 +51,13 @@ {#snippet extended()} i.feeds.find((j) => j.id.toString() == p.feed_id!), ) + const postPromise = piefed.getPosts(p) + return { - ...(await piefed.getPosts(p)), + posts: (await postPromise).posts, + next_page: (await postPromise).next_page, feed: piefedFeedData, - params: p, + params: { ...p, page_cursor: (await postPromise).next_page }, client: {}, } }).load({ diff --git a/src/routes/topic/[id]/+page.ts b/src/routes/topic/[id]/+page.ts index cf9b9203..e77ff772 100644 --- a/src/routes/topic/[id]/+page.ts +++ b/src/routes/topic/[id]/+page.ts @@ -19,10 +19,12 @@ export async function load({ url, fetch, route, params }) { include_communities: true, }).then((i) => i.topics.find((j) => j.id.toString() == p.topic_id!)) + const posts = await piefed.getPosts(p) + return { - ...(await piefed.getPosts(p)), + ...posts, topic: piefedTopicData, - params: p, + params: { ...p, page_cursor: posts.next_page }, client: {}, } }).load({