mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-29 15:51:12 +00:00
Adding private instance related endpoints.
This commit is contained in:
parent
5e4ff291c5
commit
207820783e
7 changed files with 215 additions and 36 deletions
59
src/http.ts
59
src/http.ts
|
@ -45,6 +45,7 @@ import {
|
|||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeleteAccountResponse,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetCaptchaResponse,
|
||||
|
@ -72,6 +73,8 @@ import {
|
|||
PrivateMessagesResponse,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
VerifyEmailResponse,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
|
@ -96,6 +99,7 @@ import {
|
|||
StickyPost,
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
|
@ -104,6 +108,11 @@ import {
|
|||
GetSiteConfig,
|
||||
GetSiteConfigResponse,
|
||||
GetSiteResponse,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
GetUnreadRegistrationApplicationCountResponse,
|
||||
ListRegistrationApplications,
|
||||
ListRegistrationApplicationsResponse,
|
||||
RegistrationApplicationResponse,
|
||||
ResolveObject,
|
||||
ResolveObjectResponse,
|
||||
SaveSiteConfig,
|
||||
|
@ -592,8 +601,8 @@ export class LemmyHttp {
|
|||
/**
|
||||
* Delete your account.
|
||||
*/
|
||||
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, "/user/delete_account", form);
|
||||
async deleteAccount(form: DeleteAccount): Promise<DeleteAccountResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/delete_account', form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -645,6 +654,13 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Get, "/user/unread_count", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify your email
|
||||
*/
|
||||
async verifyEmail(form: VerifyEmail): Promise<VerifyEmailResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/verify_email', form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an admin to your site.
|
||||
*/
|
||||
|
@ -652,6 +668,45 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Post, "/admin/add", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unread registration applications count.
|
||||
*/
|
||||
async getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount
|
||||
): Promise<GetUnreadRegistrationApplicationCountResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
'/admin/registration_application/count',
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the unread registration applications.
|
||||
*/
|
||||
async listRegistrationApplications(
|
||||
form: ListRegistrationApplications
|
||||
): Promise<ListRegistrationApplicationsResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
'/admin/registration_application/list',
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a registration application
|
||||
*/
|
||||
async approveRegistrationApplication(
|
||||
form: ApproveRegistrationApplication
|
||||
): Promise<RegistrationApplicationResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Put,
|
||||
'/admin/registration_application/approve',
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
private buildFullUrl(endpoint: string): string {
|
||||
return `${this.apiUrl}${endpoint}`;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ export interface Login {
|
|||
*/
|
||||
export interface Register {
|
||||
username: string;
|
||||
/**
|
||||
* Email is mandatory if email verification is enabled on the server
|
||||
*/
|
||||
email?: string;
|
||||
password: string;
|
||||
password_verify: string;
|
||||
|
@ -29,6 +32,10 @@ export interface Register {
|
|||
captcha_uuid?: string;
|
||||
captcha_answer?: string;
|
||||
honeypot?: string;
|
||||
/**
|
||||
* An answer is mandatory if require application is enabled on the server
|
||||
*/
|
||||
answer?: string;
|
||||
}
|
||||
|
||||
export interface GetCaptcha {}
|
||||
|
@ -106,7 +113,12 @@ export interface ChangePassword {
|
|||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
jwt: string;
|
||||
/**
|
||||
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
||||
*/
|
||||
jwt?: string;
|
||||
verify_email_sent: boolean;
|
||||
registration_created: boolean;
|
||||
}
|
||||
|
||||
export interface GetPersonDetails {
|
||||
|
@ -210,6 +222,8 @@ export interface DeleteAccount {
|
|||
auth: string;
|
||||
}
|
||||
|
||||
export interface DeleteAccountResponse {}
|
||||
|
||||
export interface PasswordReset {
|
||||
email: string;
|
||||
}
|
||||
|
@ -285,6 +299,12 @@ export interface GetUnreadCountResponse {
|
|||
private_messages: number;
|
||||
}
|
||||
|
||||
export interface VerifyEmail {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface VerifyEmailResponse {}
|
||||
|
||||
export interface BlockPerson {
|
||||
person_id: number;
|
||||
block: boolean;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import {
|
||||
CommentView,
|
||||
CommunityBlockView,
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
RegistrationApplicationView,
|
||||
CommentView,
|
||||
CommunityView,
|
||||
LocalUserSettingsView,
|
||||
ModAddCommunityView,
|
||||
|
@ -91,6 +92,10 @@ export interface CreateSite {
|
|||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -104,6 +109,10 @@ export interface EditSite {
|
|||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -177,3 +186,36 @@ export interface ResolveObjectResponse {
|
|||
community?: CommunityView;
|
||||
person?: PersonViewSafe;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplications {
|
||||
/**
|
||||
* Only shows the unread applications (IE those without an admin actor)
|
||||
*/
|
||||
unread_only?: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplicationsResponse {
|
||||
registration_applications: RegistrationApplicationView[];
|
||||
}
|
||||
|
||||
export interface ApproveRegistrationApplication {
|
||||
id: number;
|
||||
approve: boolean;
|
||||
deny_reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationResponse {
|
||||
registration_application: RegistrationApplicationView;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCount {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
||||
registration_applications: number;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ export enum UserOperation {
|
|||
EditSite,
|
||||
GetSite,
|
||||
AddAdmin,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
ListRegistrationApplications,
|
||||
ApproveRegistrationApplication,
|
||||
BanPerson,
|
||||
Search,
|
||||
ResolveObject,
|
||||
|
@ -75,6 +78,7 @@ export enum UserOperation {
|
|||
ListPostReports,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
VerifyEmail,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,8 @@ export interface LocalUserSettings {
|
|||
show_scores: boolean;
|
||||
show_read_posts: boolean;
|
||||
show_new_post_notifs: boolean;
|
||||
email_verified: boolean;
|
||||
accepted_application: boolean;
|
||||
}
|
||||
|
||||
export interface PersonSafe {
|
||||
|
@ -39,16 +41,20 @@ export interface Site {
|
|||
id: number;
|
||||
name: string;
|
||||
sidebar?: string;
|
||||
description?: string;
|
||||
creator_id: number;
|
||||
published: string;
|
||||
updated?: string;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
community_creation_admin_only: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
description?: string;
|
||||
community_creation_admin_only: boolean;
|
||||
require_email_verification: boolean;
|
||||
require_application: boolean;
|
||||
application_question?: string;
|
||||
private_instance: boolean;
|
||||
}
|
||||
|
||||
export interface PrivateMessage {
|
||||
|
@ -248,3 +254,12 @@ export interface PersonMention {
|
|||
read: boolean;
|
||||
published: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplication {
|
||||
id: number;
|
||||
local_user_id: number;
|
||||
answer: string;
|
||||
admin_id?: number;
|
||||
deny_reason?: string;
|
||||
published: string;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
Comment,
|
||||
CommentReport,
|
||||
CommunitySafe,
|
||||
LocalUserSettings,
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModBan,
|
||||
|
@ -20,13 +19,15 @@ import {
|
|||
ModRemovePost,
|
||||
ModStickyPost,
|
||||
ModTransferCommunity,
|
||||
PersonMention,
|
||||
PersonSafe,
|
||||
Post,
|
||||
PostReport,
|
||||
PrivateMessage,
|
||||
Site,
|
||||
} from "./source";
|
||||
PersonMention,
|
||||
PersonSafe,
|
||||
LocalUserSettings,
|
||||
RegistrationApplication,
|
||||
} from './source';
|
||||
|
||||
export interface PersonViewSafe {
|
||||
person: PersonSafe;
|
||||
|
@ -218,3 +219,10 @@ export interface CommunityView {
|
|||
blocked: boolean;
|
||||
counts: CommunityAggregates;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationView {
|
||||
registration_application: RegistrationApplication;
|
||||
creator_local_user: LocalUserSettings;
|
||||
creator: PersonSafe;
|
||||
admin?: PersonSafe;
|
||||
}
|
||||
|
|
|
@ -24,30 +24,6 @@ import {
|
|||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
BlockPerson,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPersonDetails,
|
||||
GetPersonMentions,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
|
@ -65,18 +41,46 @@ import {
|
|||
StickyPost,
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
GetSite,
|
||||
GetSiteConfig,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
ListRegistrationApplications,
|
||||
ResolveObject,
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
TransferSite,
|
||||
} from "./interfaces/api/site";
|
||||
import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
|
||||
import { UserOperation } from "./interfaces/others";
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetPersonDetails,
|
||||
GetPersonMentions,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
ChangePassword,
|
||||
BlockPerson,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
VerifyEmail,
|
||||
} from './interfaces/api/person';
|
||||
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
||||
import { UserOperation } from './interfaces/others';
|
||||
|
||||
/**
|
||||
* Helps build lemmy websocket message requests, that you can use in your Websocket sends.
|
||||
|
@ -404,6 +408,29 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.AddAdmin, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unread registration applications count.
|
||||
*/
|
||||
getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount
|
||||
) {
|
||||
return wrapper(UserOperation.GetUnreadRegistrationApplicationCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the unread registration applications.
|
||||
*/
|
||||
listRegistrationApplications(form: ListRegistrationApplications) {
|
||||
return wrapper(UserOperation.ListRegistrationApplications, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a registration application
|
||||
*/
|
||||
approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
||||
return wrapper(UserOperation.ApproveRegistrationApplication, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details for a person.
|
||||
*/
|
||||
|
@ -515,6 +542,14 @@ export class LemmyWebsocket {
|
|||
getUnreadCount(form: GetUnreadCount) {
|
||||
return wrapper(UserOperation.GetUnreadCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify your email
|
||||
*/
|
||||
verifyEmail(form: VerifyEmail) {
|
||||
return wrapper(UserOperation.VerifyEmail, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete your account.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue