From 32b5582df2f6203451fbdd856938ba01eadcb77b Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 3 Jan 2025 14:36:11 -0500 Subject: [PATCH] Combined reports (#419) * Adding list reports. * 0.20.0-reports-combined.0 * Fix comment. * Use internal tagging. * 0.20.0-reports-combined.1 * 0.20.0-reports-combined.2 * 0.20.0-reports-combined.3 --- package.json | 2 +- src/http.ts | 65 +++++-------------- src/index.ts | 12 ++-- src/types/AdminAllowInstance.ts | 2 +- src/types/AdminBlockInstance.ts | 2 +- src/types/AuthenticateWithOauth.ts | 2 +- src/types/GetPosts.ts | 1 + src/types/GetReportCountResponse.ts | 8 +-- src/types/ListCommentReportsResponse.ts | 9 --- src/types/ListPostReports.ts | 20 ------ src/types/ListPrivateMessageReports.ts | 13 ---- .../ListPrivateMessageReportsResponse.ts | 9 --- .../{ListCommentReports.ts => ListReports.ts} | 11 ++-- ...ortsResponse.ts => ListReportsResponse.ts} | 4 +- src/types/ReportCombined.ts | 16 +++++ src/types/ReportCombinedId.ts | 6 ++ src/types/ReportCombinedPaginationCursor.ts | 6 ++ src/types/ReportCombinedView.ts | 9 +++ 18 files changed, 72 insertions(+), 125 deletions(-) delete mode 100644 src/types/ListCommentReportsResponse.ts delete mode 100644 src/types/ListPostReports.ts delete mode 100644 src/types/ListPrivateMessageReports.ts delete mode 100644 src/types/ListPrivateMessageReportsResponse.ts rename src/types/{ListCommentReports.ts => ListReports.ts} (65%) rename src/types/{ListPostReportsResponse.ts => ListReportsResponse.ts} (51%) create mode 100644 src/types/ReportCombined.ts create mode 100644 src/types/ReportCombinedId.ts create mode 100644 src/types/ReportCombinedPaginationCursor.ts create mode 100644 src/types/ReportCombinedView.ts diff --git a/package.json b/package.json index 06a3cf4..6ed77ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.20.0-api-v4.17", + "version": "0.20.0-reports-combined.3", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/http.ts b/src/http.ts index 31ac0ca..c0b7294 100644 --- a/src/http.ts +++ b/src/http.ts @@ -76,14 +76,8 @@ import { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse"; import { GetSiteResponse } from "./types/GetSiteResponse"; import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse"; import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse"; -import { ListCommentReports } from "./types/ListCommentReports"; -import { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; import { ListCommunities } from "./types/ListCommunities"; import { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; -import { ListPostReports } from "./types/ListPostReports"; -import { ListPostReportsResponse } from "./types/ListPostReportsResponse"; -import { ListPrivateMessageReports } from "./types/ListPrivateMessageReports"; -import { ListPrivateMessageReportsResponse } from "./types/ListPrivateMessageReportsResponse"; import { ListRegistrationApplications } from "./types/ListRegistrationApplications"; import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationApplicationsResponse"; import { LockPost } from "./types/LockPost"; @@ -159,6 +153,8 @@ import { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPen import { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse"; import { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows"; import { CommunityId } from "./types/CommunityId"; +import { ListReports } from "./types/ListReports"; +import { ListReportsResponse } from "./types/ListReportsResponse"; import { MyUserInfo } from "./types/MyUserInfo"; import { UserBlockInstanceParams } from "./types/UserBlockInstanceParams"; import { AdminAllowInstanceParams } from "./types/AdminAllowInstanceParams"; @@ -874,20 +870,6 @@ export class LemmyHttp { ); } - /** - * List post reports. - * - * `HTTP.GET /post/report/list` - */ - listPostReports(form: ListPostReports, options?: RequestOptions) { - return this.#wrapper( - HttpType.Get, - "/post/report/list", - form, - options, - ); - } - /** * Fetch metadata for any given site. * @@ -1087,20 +1069,6 @@ export class LemmyHttp { ); } - /** - * List comment reports. - * - * `HTTP.GET /comment/report/list` - */ - listCommentReports(form: ListCommentReports, options?: RequestOptions) { - return this.#wrapper( - HttpType.Get, - "/comment/report/list", - form, - options, - ); - } - /** * Get / fetch private messages. * @@ -1204,21 +1172,6 @@ export class LemmyHttp { >(HttpType.Put, "/private_message/report/resolve", form, options); } - /** - * List private message reports. - * - * `HTTP.GET /private_message/report/list` - */ - listPrivateMessageReports( - form: ListPrivateMessageReports, - options?: RequestOptions, - ) { - return this.#wrapper< - ListPrivateMessageReports, - ListPrivateMessageReportsResponse - >(HttpType.Get, "/private_message/report/list", form, options); - } - /** * Register a new user. * @@ -1830,6 +1783,20 @@ export class LemmyHttp { ); } + /** + * List user reports. + * + * `HTTP.GET /report/list` + */ + listReports(form: ListReports, options?: RequestOptions) { + return this.#wrapper( + HttpType.Get, + "/report/list", + form, + options, + ); + } + /** * Block an instance as user. * diff --git a/src/index.ts b/src/index.ts index eb60cf4..72acbd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -147,8 +147,6 @@ export { LemmyErrorType } from "./types/LemmyErrorType"; export { LinkMetadata } from "./types/LinkMetadata"; export { ListCommentLikes } from "./types/ListCommentLikes"; export { ListCommentLikesResponse } from "./types/ListCommentLikesResponse"; -export { ListCommentReports } from "./types/ListCommentReports"; -export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; export { ListCommunities } from "./types/ListCommunities"; export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; export { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows"; @@ -160,12 +158,10 @@ export { ListMedia } from "./types/ListMedia"; export { ListMediaResponse } from "./types/ListMediaResponse"; export { ListPostLikes } from "./types/ListPostLikes"; export { ListPostLikesResponse } from "./types/ListPostLikesResponse"; -export { ListPostReports } from "./types/ListPostReports"; -export { ListPostReportsResponse } from "./types/ListPostReportsResponse"; -export { ListPrivateMessageReports } from "./types/ListPrivateMessageReports"; -export { ListPrivateMessageReportsResponse } from "./types/ListPrivateMessageReportsResponse"; export { ListRegistrationApplications } from "./types/ListRegistrationApplications"; export { ListRegistrationApplicationsResponse } from "./types/ListRegistrationApplicationsResponse"; +export { ListReports } from "./types/ListReports"; +export { ListReportsResponse } from "./types/ListReportsResponse"; export { ListTaglines } from "./types/ListTaglines"; export { ListTaglinesResponse } from "./types/ListTaglinesResponse"; export { ListingType } from "./types/ListingType"; @@ -265,6 +261,10 @@ export { RegistrationMode } from "./types/RegistrationMode"; export { RemoveComment } from "./types/RemoveComment"; export { RemoveCommunity } from "./types/RemoveCommunity"; export { RemovePost } from "./types/RemovePost"; +export { ReportCombined } from "./types/ReportCombined"; +export { ReportCombinedId } from "./types/ReportCombinedId"; +export { ReportCombinedPaginationCursor } from "./types/ReportCombinedPaginationCursor"; +export { ReportCombinedView } from "./types/ReportCombinedView"; export { ResolveCommentReport } from "./types/ResolveCommentReport"; export { ResolveObject } from "./types/ResolveObject"; export { ResolveObjectResponse } from "./types/ResolveObjectResponse"; diff --git a/src/types/AdminAllowInstance.ts b/src/types/AdminAllowInstance.ts index 3d347cd..d4fdd74 100644 --- a/src/types/AdminAllowInstance.ts +++ b/src/types/AdminAllowInstance.ts @@ -8,5 +8,5 @@ export type AdminAllowInstance = { admin_person_id: PersonId; allowed: boolean; reason?: string; - published: string; + when_: string; }; diff --git a/src/types/AdminBlockInstance.ts b/src/types/AdminBlockInstance.ts index 98b0758..e51008e 100644 --- a/src/types/AdminBlockInstance.ts +++ b/src/types/AdminBlockInstance.ts @@ -9,5 +9,5 @@ export type AdminBlockInstance = { blocked: boolean; reason?: string; expires?: string; - published: string; + when_: string; }; diff --git a/src/types/AuthenticateWithOauth.ts b/src/types/AuthenticateWithOauth.ts index bc8585b..c1f6440 100644 --- a/src/types/AuthenticateWithOauth.ts +++ b/src/types/AuthenticateWithOauth.ts @@ -6,7 +6,6 @@ import type { OAuthProviderId } from "./OAuthProviderId"; */ export type AuthenticateWithOauth = { code: string; - pkce_code_verifier?: string; oauth_provider_id: OAuthProviderId; redirect_uri: string; show_nsfw?: boolean; @@ -18,4 +17,5 @@ export type AuthenticateWithOauth = { * An answer is mandatory if require application is enabled on the server */ answer?: string; + pkce_code_verifier?: string; }; diff --git a/src/types/GetPosts.ts b/src/types/GetPosts.ts index 58b9429..77b15dd 100644 --- a/src/types/GetPosts.ts +++ b/src/types/GetPosts.ts @@ -38,4 +38,5 @@ export type GetPosts = { */ no_comments_only?: boolean; page_cursor?: PaginationCursor; + page_back?: boolean; }; diff --git a/src/types/GetReportCountResponse.ts b/src/types/GetReportCountResponse.ts index 356f643..2a6d2ec 100644 --- a/src/types/GetReportCountResponse.ts +++ b/src/types/GetReportCountResponse.ts @@ -1,12 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { CommunityId } from "./CommunityId"; /** * A response for the number of reports. */ -export type GetReportCountResponse = { - community_id?: CommunityId; - comment_reports: number; - post_reports: number; - private_message_reports?: number; -}; +export type GetReportCountResponse = { count: number }; diff --git a/src/types/ListCommentReportsResponse.ts b/src/types/ListCommentReportsResponse.ts deleted file mode 100644 index 7bfbbef..0000000 --- a/src/types/ListCommentReportsResponse.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { CommentReportView } from "./CommentReportView"; - -/** - * The comment report list response. - */ -export type ListCommentReportsResponse = { - comment_reports: Array; -}; diff --git a/src/types/ListPostReports.ts b/src/types/ListPostReports.ts deleted file mode 100644 index 0964ab9..0000000 --- a/src/types/ListPostReports.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { CommunityId } from "./CommunityId"; -import type { PostId } from "./PostId"; - -/** - * List post reports. - */ -export type ListPostReports = { - page?: number; - limit?: number; - /** - * Only shows the unresolved reports - */ - unresolved_only?: boolean; - /** - * if no community is given, it returns reports for all communities moderated by the auth user - */ - community_id?: CommunityId; - post_id?: PostId; -}; diff --git a/src/types/ListPrivateMessageReports.ts b/src/types/ListPrivateMessageReports.ts deleted file mode 100644 index 7c43dd0..0000000 --- a/src/types/ListPrivateMessageReports.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * List private message reports. - */ -export type ListPrivateMessageReports = { - page?: number; - limit?: number; - /** - * Only shows the unresolved reports - */ - unresolved_only?: boolean; -}; diff --git a/src/types/ListPrivateMessageReportsResponse.ts b/src/types/ListPrivateMessageReportsResponse.ts deleted file mode 100644 index a574280..0000000 --- a/src/types/ListPrivateMessageReportsResponse.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { PrivateMessageReportView } from "./PrivateMessageReportView"; - -/** - * The response for list private message reports. - */ -export type ListPrivateMessageReportsResponse = { - private_message_reports: Array; -}; diff --git a/src/types/ListCommentReports.ts b/src/types/ListReports.ts similarity index 65% rename from src/types/ListCommentReports.ts rename to src/types/ListReports.ts index 8cb33dc..00f8838 100644 --- a/src/types/ListCommentReports.ts +++ b/src/types/ListReports.ts @@ -1,14 +1,11 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { CommentId } from "./CommentId"; import type { CommunityId } from "./CommunityId"; +import type { ReportCombinedPaginationCursor } from "./ReportCombinedPaginationCursor"; /** - * List comment reports. + * List reports. */ -export type ListCommentReports = { - comment_id?: CommentId; - page?: number; - limit?: number; +export type ListReports = { /** * Only shows the unresolved reports */ @@ -17,4 +14,6 @@ export type ListCommentReports = { * if no community is given, it returns reports for all communities moderated by the auth user */ community_id?: CommunityId; + page_cursor?: ReportCombinedPaginationCursor; + page_back?: boolean; }; diff --git a/src/types/ListPostReportsResponse.ts b/src/types/ListReportsResponse.ts similarity index 51% rename from src/types/ListPostReportsResponse.ts rename to src/types/ListReportsResponse.ts index 94e7ca1..afced0d 100644 --- a/src/types/ListPostReportsResponse.ts +++ b/src/types/ListReportsResponse.ts @@ -1,7 +1,7 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { PostReportView } from "./PostReportView"; +import type { ReportCombinedView } from "./ReportCombinedView"; /** * The post reports response. */ -export type ListPostReportsResponse = { post_reports: Array }; +export type ListReportsResponse = { reports: Array }; diff --git a/src/types/ReportCombined.ts b/src/types/ReportCombined.ts new file mode 100644 index 0000000..4e0788e --- /dev/null +++ b/src/types/ReportCombined.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommentReportId } from "./CommentReportId"; +import type { PostReportId } from "./PostReportId"; +import type { PrivateMessageReportId } from "./PrivateMessageReportId"; +import type { ReportCombinedId } from "./ReportCombinedId"; + +/** + * A combined reports table. + */ +export type ReportCombined = { + id: ReportCombinedId; + published: string; + post_report_id?: PostReportId; + comment_report_id?: CommentReportId; + private_message_report_id?: PrivateMessageReportId; +}; diff --git a/src/types/ReportCombinedId.ts b/src/types/ReportCombinedId.ts new file mode 100644 index 0000000..d54a905 --- /dev/null +++ b/src/types/ReportCombinedId.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * The report combined id + */ +export type ReportCombinedId = number; diff --git a/src/types/ReportCombinedPaginationCursor.ts b/src/types/ReportCombinedPaginationCursor.ts new file mode 100644 index 0000000..312df7f --- /dev/null +++ b/src/types/ReportCombinedPaginationCursor.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * like PaginationCursor but for the report_combined table + */ +export type ReportCombinedPaginationCursor = string; diff --git a/src/types/ReportCombinedView.ts b/src/types/ReportCombinedView.ts new file mode 100644 index 0000000..b8d4420 --- /dev/null +++ b/src/types/ReportCombinedView.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommentReportView } from "./CommentReportView"; +import type { PostReportView } from "./PostReportView"; +import type { PrivateMessageReportView } from "./PrivateMessageReportView"; + +export type ReportCombinedView = + | ({ type_: "Post" } & PostReportView) + | ({ type_: "Comment" } & CommentReportView) + | ({ type_: "PrivateMessage" } & PrivateMessageReportView);