Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined reports #419

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"license": "AGPL-3.0",
"main": "./dist/index.js",
Expand Down
65 changes: 16 additions & 49 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -874,20 +870,6 @@ export class LemmyHttp {
);
}

/**
* List post reports.
*
* `HTTP.GET /post/report/list`
*/
listPostReports(form: ListPostReports, options?: RequestOptions) {
return this.#wrapper<ListPostReports, ListPostReportsResponse>(
HttpType.Get,
"/post/report/list",
form,
options,
);
}

/**
* Fetch metadata for any given site.
*
Expand Down Expand Up @@ -1087,20 +1069,6 @@ export class LemmyHttp {
);
}

/**
* List comment reports.
*
* `HTTP.GET /comment/report/list`
*/
listCommentReports(form: ListCommentReports, options?: RequestOptions) {
return this.#wrapper<ListCommentReports, ListCommentReportsResponse>(
HttpType.Get,
"/comment/report/list",
form,
options,
);
}

/**
* Get / fetch private messages.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -1830,6 +1783,20 @@ export class LemmyHttp {
);
}

/**
* List user reports.
*
* `HTTP.GET /report/list`
*/
listReports(form: ListReports, options?: RequestOptions) {
return this.#wrapper<ListReports, ListReportsResponse>(
HttpType.Get,
"/report/list",
form,
options,
);
}

/**
* Block an instance as user.
*
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/types/AdminAllowInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export type AdminAllowInstance = {
admin_person_id: PersonId;
allowed: boolean;
reason?: string;
published: string;
when_: string;
};
2 changes: 1 addition & 1 deletion src/types/AdminBlockInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export type AdminBlockInstance = {
blocked: boolean;
reason?: string;
expires?: string;
published: string;
when_: string;
};
2 changes: 1 addition & 1 deletion src/types/AuthenticateWithOauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
1 change: 1 addition & 0 deletions src/types/GetPosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export type GetPosts = {
*/
no_comments_only?: boolean;
page_cursor?: PaginationCursor;
page_back?: boolean;
};
8 changes: 1 addition & 7 deletions src/types/GetReportCountResponse.ts
Original file line number Diff line number Diff line change
@@ -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 };
9 changes: 0 additions & 9 deletions src/types/ListCommentReportsResponse.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/types/ListPostReports.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/types/ListPrivateMessageReports.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/types/ListPrivateMessageReportsResponse.ts

This file was deleted.

11 changes: 5 additions & 6 deletions src/types/ListCommentReports.ts → src/types/ListReports.ts
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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;
};
Original file line number Diff line number Diff line change
@@ -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<PostReportView> };
export type ListReportsResponse = { reports: Array<ReportCombinedView> };
16 changes: 16 additions & 0 deletions src/types/ReportCombined.ts
Original file line number Diff line number Diff line change
@@ -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;
};
6 changes: 6 additions & 0 deletions src/types/ReportCombinedId.ts
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions src/types/ReportCombinedPaginationCursor.ts
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions src/types/ReportCombinedView.ts
Original file line number Diff line number Diff line change
@@ -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);