From f32772c2e1102c4996d028f81fdeb7f50f16aec4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 23 Aug 2021 16:15:24 -0400 Subject: [PATCH] Resolve endpoint (#28) * Adding ResolveObject to the API. Fixes #27 * v0.11.4-rc.13 * v0.11.4-rc.14 * Forgot to add the websocket * v0.11.4-rc.15 --- package.json | 2 +- src/http.ts | 9 +++++++++ src/interfaces/api/site.ts | 12 ++++++++++++ src/interfaces/others.ts | 1 + src/websocket.ts | 8 ++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ffef482..4a42adf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.11.4-rc.12", + "version": "0.11.4-rc.15", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/http.ts b/src/http.ts index 509a1e9..f305944 100644 --- a/src/http.ts +++ b/src/http.ts @@ -56,6 +56,8 @@ import { GetSiteConfig, GetSiteConfigResponse, GetSiteResponse, + ResolveObject, + ResolveObjectResponse, SaveSiteConfig, Search, SearchResponse, @@ -181,6 +183,13 @@ export class LemmyHttp { return this.wrapper(HttpType.Get, '/search', form); } + /** + * Fetch a non-local / federated object. + */ + async resolveObject(form: ResolveObject): Promise { + return this.wrapper(HttpType.Get, '/resolve_object', form); + } + /** * Create a new community. */ diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index ec3e96c..aaa3c72 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -167,3 +167,15 @@ export interface FederatedInstances { allowed?: string[]; blocked?: string[]; } + +export interface ResolveObject { + q: string; + auth?: string; +} + +export interface ResolveObjectResponse { + comment?: CommentView; + post?: PostView; + community?: CommunityView; + person?: PersonViewSafe; +} diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index c163d2f..2d381a9 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -44,6 +44,7 @@ export enum UserOperation { AddAdmin, BanPerson, Search, + ResolveObject, MarkAllAsRead, SaveUserSettings, TransferCommunity, diff --git a/src/websocket.ts b/src/websocket.ts index 07034de..8e40545 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -40,6 +40,7 @@ import { GetModlog, GetSite, GetSiteConfig, + ResolveObject, SaveSiteConfig, Search, TransferSite, @@ -423,6 +424,13 @@ export class LemmyWebsocket { return wrapper(UserOperation.Search, form); } + /** + * Fetch a non-local / federated object. + */ + resolveObject(form: ResolveObject) { + return wrapper(UserOperation.ResolveObject, form); + } + /** * Mark all replies as read. */