diff --git a/src/http.ts b/src/http.ts index 9b5ac1b..474af47 100644 --- a/src/http.ts +++ b/src/http.ts @@ -82,6 +82,10 @@ import { AddModToCommunityResponse, GetFollowedCommunitiesResponse, PasswordResetResponse, + PostJoinForm, + PostJoinResponse, + CommunityJoinForm, + CommunityJoinResponse, } from './interfaces'; enum HttpType { @@ -323,6 +327,14 @@ export class LemmyHttp { return this.wrapper(HttpType.Post, '/user/join', form); } + async postJoin(form: PostJoinForm): Promise { + return this.wrapper(HttpType.Post, '/post/join', form); + } + + async communityJoin(form: CommunityJoinForm): Promise { + return this.wrapper(HttpType.Post, '/community/join', form); + } + async banUser(form: BanUserForm): Promise { return this.wrapper(HttpType.Post, '/user/ban', form); } diff --git a/src/interfaces.ts b/src/interfaces.ts index 608e2d8..515abec 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -57,6 +57,8 @@ export enum UserOperation { GetComments, GetSiteConfig, SaveSiteConfig, + PostJoin, + CommunityJoin, } export enum SortType { @@ -961,7 +963,25 @@ export interface UserJoinForm { } export interface UserJoinResponse { - user_id: number; + joined: boolean; +} + +export interface PostJoinForm { + post_id: number; + auth: string; +} + +export interface PostJoinResponse { + joined: boolean; +} + +export interface CommunityJoinForm { + community_id: number; + auth: string; +} + +export interface CommunityJoinResponse { + joined: boolean; } export type MessageType = diff --git a/src/websocket.ts b/src/websocket.ts index 9405599..76d139b 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -53,6 +53,8 @@ import { GetSiteForm, SiteConfigForm, MarkAllAsReadForm, + PostJoinForm, + CommunityJoinForm, } from './interfaces'; export class LemmyWebsocket { @@ -66,6 +68,14 @@ export class LemmyWebsocket { return wrapper(UserOperation.UserJoin, form); } + postJoin(form: PostJoinForm): string { + return wrapper(UserOperation.PostJoin, form); + } + + communityJoin(form: CommunityJoinForm): string { + return wrapper(UserOperation.CommunityJoin, form); + } + register(registerForm: RegisterForm) { return wrapper(UserOperation.Register, registerForm); }