Adding support for federated instances. Fixes #115

This commit is contained in:
Dessalines 2023-05-10 11:00:58 -04:00
parent 0078d575b3
commit aabd039a54
5 changed files with 32 additions and 7 deletions

View file

@ -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<any, GetCaptchaResponse>(
getCaptcha(form: GetCaptcha) {
return this.wrapper<GetCaptcha, GetCaptchaResponse>(
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.
*/

View file

@ -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;
}

View file

@ -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;
}

View file

@ -90,6 +90,7 @@ export enum UserOperation {
CreateCustomEmoji,
EditCustomEmoji,
DeleteCustomEmoji,
GetFederatedInstances,
}
export interface UploadImage {

View file

@ -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<MessageType>(op: UserOperation, data: MessageType) {