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,
|
ChangePassword,
|
||||||
CreatePrivateMessage,
|
CreatePrivateMessage,
|
||||||
DeleteAccount,
|
DeleteAccount,
|
||||||
|
DeleteAccountResponse,
|
||||||
DeletePrivateMessage,
|
DeletePrivateMessage,
|
||||||
EditPrivateMessage,
|
EditPrivateMessage,
|
||||||
GetCaptchaResponse,
|
GetCaptchaResponse,
|
||||||
|
@ -72,6 +73,8 @@ import {
|
||||||
PrivateMessagesResponse,
|
PrivateMessagesResponse,
|
||||||
Register,
|
Register,
|
||||||
SaveUserSettings,
|
SaveUserSettings,
|
||||||
|
VerifyEmail,
|
||||||
|
VerifyEmailResponse,
|
||||||
} from "./interfaces/api/person";
|
} from "./interfaces/api/person";
|
||||||
import {
|
import {
|
||||||
CreatePost,
|
CreatePost,
|
||||||
|
@ -96,6 +99,7 @@ import {
|
||||||
StickyPost,
|
StickyPost,
|
||||||
} from "./interfaces/api/post";
|
} from "./interfaces/api/post";
|
||||||
import {
|
import {
|
||||||
|
ApproveRegistrationApplication,
|
||||||
CreateSite,
|
CreateSite,
|
||||||
EditSite,
|
EditSite,
|
||||||
GetModlog,
|
GetModlog,
|
||||||
|
@ -104,6 +108,11 @@ import {
|
||||||
GetSiteConfig,
|
GetSiteConfig,
|
||||||
GetSiteConfigResponse,
|
GetSiteConfigResponse,
|
||||||
GetSiteResponse,
|
GetSiteResponse,
|
||||||
|
GetUnreadRegistrationApplicationCount,
|
||||||
|
GetUnreadRegistrationApplicationCountResponse,
|
||||||
|
ListRegistrationApplications,
|
||||||
|
ListRegistrationApplicationsResponse,
|
||||||
|
RegistrationApplicationResponse,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
ResolveObjectResponse,
|
ResolveObjectResponse,
|
||||||
SaveSiteConfig,
|
SaveSiteConfig,
|
||||||
|
@ -592,8 +601,8 @@ export class LemmyHttp {
|
||||||
/**
|
/**
|
||||||
* Delete your account.
|
* Delete your account.
|
||||||
*/
|
*/
|
||||||
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> {
|
async deleteAccount(form: DeleteAccount): Promise<DeleteAccountResponse> {
|
||||||
return this.wrapper(HttpType.Post, "/user/delete_account", form);
|
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);
|
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.
|
* Add an admin to your site.
|
||||||
*/
|
*/
|
||||||
|
@ -652,6 +668,45 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Post, "/admin/add", form);
|
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 {
|
private buildFullUrl(endpoint: string): string {
|
||||||
return `${this.apiUrl}${endpoint}`;
|
return `${this.apiUrl}${endpoint}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ export interface Login {
|
||||||
*/
|
*/
|
||||||
export interface Register {
|
export interface Register {
|
||||||
username: string;
|
username: string;
|
||||||
|
/**
|
||||||
|
* Email is mandatory if email verification is enabled on the server
|
||||||
|
*/
|
||||||
email?: string;
|
email?: string;
|
||||||
password: string;
|
password: string;
|
||||||
password_verify: string;
|
password_verify: string;
|
||||||
|
@ -29,6 +32,10 @@ export interface Register {
|
||||||
captcha_uuid?: string;
|
captcha_uuid?: string;
|
||||||
captcha_answer?: string;
|
captcha_answer?: string;
|
||||||
honeypot?: string;
|
honeypot?: string;
|
||||||
|
/**
|
||||||
|
* An answer is mandatory if require application is enabled on the server
|
||||||
|
*/
|
||||||
|
answer?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetCaptcha {}
|
export interface GetCaptcha {}
|
||||||
|
@ -106,7 +113,12 @@ export interface ChangePassword {
|
||||||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||||
*/
|
*/
|
||||||
export interface LoginResponse {
|
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 {
|
export interface GetPersonDetails {
|
||||||
|
@ -210,6 +222,8 @@ export interface DeleteAccount {
|
||||||
auth: string;
|
auth: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DeleteAccountResponse {}
|
||||||
|
|
||||||
export interface PasswordReset {
|
export interface PasswordReset {
|
||||||
email: string;
|
email: string;
|
||||||
}
|
}
|
||||||
|
@ -285,6 +299,12 @@ export interface GetUnreadCountResponse {
|
||||||
private_messages: number;
|
private_messages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface VerifyEmail {
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VerifyEmailResponse {}
|
||||||
|
|
||||||
export interface BlockPerson {
|
export interface BlockPerson {
|
||||||
person_id: number;
|
person_id: number;
|
||||||
block: boolean;
|
block: boolean;
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import {
|
import {
|
||||||
CommentView,
|
|
||||||
CommunityBlockView,
|
CommunityBlockView,
|
||||||
CommunityFollowerView,
|
CommunityFollowerView,
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
|
RegistrationApplicationView,
|
||||||
|
CommentView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
LocalUserSettingsView,
|
LocalUserSettingsView,
|
||||||
ModAddCommunityView,
|
ModAddCommunityView,
|
||||||
|
@ -91,6 +92,10 @@ export interface CreateSite {
|
||||||
open_registration?: boolean;
|
open_registration?: boolean;
|
||||||
enable_nsfw?: boolean;
|
enable_nsfw?: boolean;
|
||||||
community_creation_admin_only?: boolean;
|
community_creation_admin_only?: boolean;
|
||||||
|
require_email_verification?: boolean;
|
||||||
|
require_application?: boolean;
|
||||||
|
application_question?: string;
|
||||||
|
private_instance?: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +109,10 @@ export interface EditSite {
|
||||||
open_registration?: boolean;
|
open_registration?: boolean;
|
||||||
enable_nsfw?: boolean;
|
enable_nsfw?: boolean;
|
||||||
community_creation_admin_only?: boolean;
|
community_creation_admin_only?: boolean;
|
||||||
|
require_email_verification?: boolean;
|
||||||
|
require_application?: boolean;
|
||||||
|
application_question?: string;
|
||||||
|
private_instance?: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,3 +186,36 @@ export interface ResolveObjectResponse {
|
||||||
community?: CommunityView;
|
community?: CommunityView;
|
||||||
person?: PersonViewSafe;
|
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,
|
EditSite,
|
||||||
GetSite,
|
GetSite,
|
||||||
AddAdmin,
|
AddAdmin,
|
||||||
|
GetUnreadRegistrationApplicationCount,
|
||||||
|
ListRegistrationApplications,
|
||||||
|
ApproveRegistrationApplication,
|
||||||
BanPerson,
|
BanPerson,
|
||||||
Search,
|
Search,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
|
@ -75,6 +78,7 @@ export enum UserOperation {
|
||||||
ListPostReports,
|
ListPostReports,
|
||||||
GetReportCount,
|
GetReportCount,
|
||||||
GetUnreadCount,
|
GetUnreadCount,
|
||||||
|
VerifyEmail,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,6 +13,8 @@ export interface LocalUserSettings {
|
||||||
show_scores: boolean;
|
show_scores: boolean;
|
||||||
show_read_posts: boolean;
|
show_read_posts: boolean;
|
||||||
show_new_post_notifs: boolean;
|
show_new_post_notifs: boolean;
|
||||||
|
email_verified: boolean;
|
||||||
|
accepted_application: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonSafe {
|
export interface PersonSafe {
|
||||||
|
@ -39,16 +41,20 @@ export interface Site {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
sidebar?: string;
|
sidebar?: string;
|
||||||
description?: string;
|
|
||||||
creator_id: number;
|
creator_id: number;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
updated?: string;
|
||||||
enable_downvotes: boolean;
|
enable_downvotes: boolean;
|
||||||
open_registration: boolean;
|
open_registration: boolean;
|
||||||
enable_nsfw: boolean;
|
enable_nsfw: boolean;
|
||||||
community_creation_admin_only: boolean;
|
|
||||||
icon?: string;
|
icon?: string;
|
||||||
banner?: 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 {
|
export interface PrivateMessage {
|
||||||
|
@ -248,3 +254,12 @@ export interface PersonMention {
|
||||||
read: boolean;
|
read: boolean;
|
||||||
published: string;
|
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,
|
Comment,
|
||||||
CommentReport,
|
CommentReport,
|
||||||
CommunitySafe,
|
CommunitySafe,
|
||||||
LocalUserSettings,
|
|
||||||
ModAdd,
|
ModAdd,
|
||||||
ModAddCommunity,
|
ModAddCommunity,
|
||||||
ModBan,
|
ModBan,
|
||||||
|
@ -20,13 +19,15 @@ import {
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModStickyPost,
|
ModStickyPost,
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
PersonMention,
|
|
||||||
PersonSafe,
|
|
||||||
Post,
|
Post,
|
||||||
PostReport,
|
PostReport,
|
||||||
PrivateMessage,
|
PrivateMessage,
|
||||||
Site,
|
Site,
|
||||||
} from "./source";
|
PersonMention,
|
||||||
|
PersonSafe,
|
||||||
|
LocalUserSettings,
|
||||||
|
RegistrationApplication,
|
||||||
|
} from './source';
|
||||||
|
|
||||||
export interface PersonViewSafe {
|
export interface PersonViewSafe {
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
|
@ -218,3 +219,10 @@ export interface CommunityView {
|
||||||
blocked: boolean;
|
blocked: boolean;
|
||||||
counts: CommunityAggregates;
|
counts: CommunityAggregates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RegistrationApplicationView {
|
||||||
|
registration_application: RegistrationApplication;
|
||||||
|
creator_local_user: LocalUserSettings;
|
||||||
|
creator: PersonSafe;
|
||||||
|
admin?: PersonSafe;
|
||||||
|
}
|
||||||
|
|
|
@ -24,30 +24,6 @@ import {
|
||||||
RemoveCommunity,
|
RemoveCommunity,
|
||||||
TransferCommunity,
|
TransferCommunity,
|
||||||
} from "./interfaces/api/community";
|
} 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 {
|
import {
|
||||||
CreatePost,
|
CreatePost,
|
||||||
CreatePostLike,
|
CreatePostLike,
|
||||||
|
@ -65,18 +41,46 @@ import {
|
||||||
StickyPost,
|
StickyPost,
|
||||||
} from "./interfaces/api/post";
|
} from "./interfaces/api/post";
|
||||||
import {
|
import {
|
||||||
|
ApproveRegistrationApplication,
|
||||||
CreateSite,
|
CreateSite,
|
||||||
EditSite,
|
EditSite,
|
||||||
GetModlog,
|
GetModlog,
|
||||||
GetSite,
|
GetSite,
|
||||||
GetSiteConfig,
|
GetSiteConfig,
|
||||||
|
GetUnreadRegistrationApplicationCount,
|
||||||
|
ListRegistrationApplications,
|
||||||
ResolveObject,
|
ResolveObject,
|
||||||
SaveSiteConfig,
|
SaveSiteConfig,
|
||||||
Search,
|
Search,
|
||||||
TransferSite,
|
TransferSite,
|
||||||
} from "./interfaces/api/site";
|
} from "./interfaces/api/site";
|
||||||
import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
|
import {
|
||||||
import { UserOperation } from "./interfaces/others";
|
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.
|
* 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);
|
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.
|
* Get the details for a person.
|
||||||
*/
|
*/
|
||||||
|
@ -515,6 +542,14 @@ export class LemmyWebsocket {
|
||||||
getUnreadCount(form: GetUnreadCount) {
|
getUnreadCount(form: GetUnreadCount) {
|
||||||
return wrapper(UserOperation.GetUnreadCount, form);
|
return wrapper(UserOperation.GetUnreadCount, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify your email
|
||||||
|
*/
|
||||||
|
verifyEmail(form: VerifyEmail) {
|
||||||
|
return wrapper(UserOperation.VerifyEmail, form);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete your account.
|
* Delete your account.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue