From 431b34e93880212eddef7103eb2894ff50bc2f50 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 10 May 2023 11:02:29 -0400 Subject: [PATCH] Adding support for federated instances. Fixes #115 (#116) --- src/http.ts | 17 ++++++++++++++--- src/types/GetCaptcha.ts | 4 +++- src/types/GetFederatedInstances.ts | 4 +++- src/types/others.ts | 1 + src/websocket.ts | 13 +++++++++++-- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/http.ts b/src/http.ts index 26e5b28..cf07fed 100644 --- a/src/http.ts +++ b/src/http.ts @@ -45,12 +45,14 @@ import { EditSite } from "./types/EditSite"; import { FeaturePost } from "./types/FeaturePost"; import { FollowCommunity } from "./types/FollowCommunity"; import { GetBannedPersons } from "./types/GetBannedPersons"; +import { GetCaptcha } from "./types/GetCaptcha"; import { GetCaptchaResponse } from "./types/GetCaptchaResponse"; import { GetComment } from "./types/GetComment"; import { GetComments } from "./types/GetComments"; import { GetCommentsResponse } from "./types/GetCommentsResponse"; import { GetCommunity } from "./types/GetCommunity"; import { GetCommunityResponse } from "./types/GetCommunityResponse"; +import { GetFederatedInstances } from "./types/GetFederatedInstances"; import { GetModlog } from "./types/GetModlog"; import { GetModlogResponse } from "./types/GetModlogResponse"; import { GetPersonDetails } from "./types/GetPersonDetails"; @@ -936,11 +938,11 @@ export class LemmyHttp { * * `HTTP.GET /user/get_captcha` */ - getCaptcha() { - return this.wrapper( + getCaptcha(form: GetCaptcha) { + return this.wrapper( HttpType.Get, "/user/get_captcha", - {} + form ); } @@ -1191,6 +1193,15 @@ export class LemmyHttp { return this.wrapper(HttpType.Post, "/custom_emoji/delete", form); } + /** + * Fetch federated instances. + * + * `HTTP.Get /federated_instances` + */ + async getFederatedInstances(form: GetFederatedInstances) { + return this.wrapper(HttpType.Get, "/federated_instances", form); + } + /** * Upload an image to the server. */ diff --git a/src/types/GetCaptcha.ts b/src/types/GetCaptcha.ts index 6f134e7..faaf6cb 100644 --- a/src/types/GetCaptcha.ts +++ b/src/types/GetCaptcha.ts @@ -1,3 +1,5 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type GetCaptcha = null; +export interface GetCaptcha { + auth?: string; +} diff --git a/src/types/GetFederatedInstances.ts b/src/types/GetFederatedInstances.ts index 5d7b03d..bf3b6c7 100644 --- a/src/types/GetFederatedInstances.ts +++ b/src/types/GetFederatedInstances.ts @@ -1,3 +1,5 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type GetFederatedInstances = null; +export interface GetFederatedInstances { + auth?: string; +} diff --git a/src/types/others.ts b/src/types/others.ts index abcca6b..0909c33 100644 --- a/src/types/others.ts +++ b/src/types/others.ts @@ -90,6 +90,7 @@ export enum UserOperation { CreateCustomEmoji, EditCustomEmoji, DeleteCustomEmoji, + GetFederatedInstances, } export interface UploadImage { diff --git a/src/websocket.ts b/src/websocket.ts index f5a14e4..a33add4 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -33,9 +33,11 @@ import { EditSite } from "./types/EditSite"; import { FeaturePost } from "./types/FeaturePost"; import { FollowCommunity } from "./types/FollowCommunity"; import { GetBannedPersons } from "./types/GetBannedPersons"; +import { GetCaptcha } from "./types/GetCaptcha"; import { GetComment } from "./types/GetComment"; import { GetComments } from "./types/GetComments"; import { GetCommunity } from "./types/GetCommunity"; +import { GetFederatedInstances } from "./types/GetFederatedInstances"; import { GetModlog } from "./types/GetModlog"; import { GetPersonDetails } from "./types/GetPersonDetails"; import { GetPersonMentions } from "./types/GetPersonMentions"; @@ -141,8 +143,8 @@ export class LemmyWebsocket { /** * Fetch a Captcha. */ - getCaptcha() { - return wrapper(UserOperation.GetCaptcha, {}); + getCaptcha(form: GetCaptcha) { + return wrapper(UserOperation.GetCaptcha, form); } /** @@ -706,6 +708,13 @@ export class LemmyWebsocket { deleteCustomEmoji(form: DeleteCustomEmoji) { return wrapper(UserOperation.DeleteCustomEmoji, form); } + + /** + * Fetch federated instances. + */ + getFederatedInstances(form: GetFederatedInstances) { + return wrapper(UserOperation.GetFederatedInstances, form); + } } function wrapper(op: UserOperation, data: MessageType) {