diff --git a/src/http.ts b/src/http.ts index 94f19a5..ede9b4c 100644 --- a/src/http.ts +++ b/src/http.ts @@ -89,6 +89,7 @@ import { PrivateMessagesResponse, Register, SaveUserSettings, + ChangePassword, PersonMentionResponse, } from './interfaces/api/person'; @@ -363,6 +364,10 @@ export class LemmyHttp { return this.wrapper(HttpType.Put, '/user/save_user_settings', form); } + async changePassword(form: ChangePassword): Promise { + return this.wrapper(HttpType.Put, '/user/change_password', form); + } + async addAdmin(form: AddAdmin): Promise { return this.wrapper(HttpType.Post, '/admin/add', form); } diff --git a/src/interfaces/api/person.ts b/src/interfaces/api/person.ts index c42aea9..64c42d4 100644 --- a/src/interfaces/api/person.ts +++ b/src/interfaces/api/person.ts @@ -50,14 +50,18 @@ export interface SaveUserSettings { email?: string; bio?: string; matrix_user_id?: string; - new_password?: string; // If setting a new password, you need all 3 password fields - new_password_verify?: string; - old_password?: string; show_avatars: boolean; send_notifications_to_email: boolean; auth: string; } +export interface ChangePassword { + new_password: string; + new_password_verify: string; + old_password: string; + auth: string; +} + /** * The `jwt` string should be stored and used anywhere `auth` is called for. */ diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index 077b64f..edbaef5 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -63,6 +63,7 @@ export enum UserOperation { SaveSiteConfig, PostJoin, CommunityJoin, + ChangePassword, } export enum SortType { diff --git a/src/websocket.ts b/src/websocket.ts index abaa89f..239ce1e 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -62,6 +62,7 @@ import { PasswordReset, Register, SaveUserSettings, + ChangePassword, } from './interfaces/api/person'; import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket'; import { UserOperation } from './interfaces/others'; @@ -272,6 +273,10 @@ export class LemmyWebsocket { return wrapper(UserOperation.SaveUserSettings, form); } + changePassword(form: ChangePassword) { + return wrapper(UserOperation.ChangePassword, form); + } + deleteAccount(form: DeleteAccount) { return wrapper(UserOperation.DeleteAccount, form); }