Skip to content

Commit

Permalink
Resolve endpoint (#28)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dessalines authored Aug 23, 2021
1 parent 0fb3e3b commit f32772c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <tyhou13@gmx.com>",
"license": "AGPL-3.0",
"main": "./dist/index.js",
Expand Down
9 changes: 9 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import {
GetSiteConfig,
GetSiteConfigResponse,
GetSiteResponse,
ResolveObject,
ResolveObjectResponse,
SaveSiteConfig,
Search,
SearchResponse,
Expand Down Expand Up @@ -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<ResolveObjectResponse> {
return this.wrapper(HttpType.Get, '/resolve_object', form);
}

/**
* Create a new community.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/interfaces/api/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/interfaces/others.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export enum UserOperation {
AddAdmin,
BanPerson,
Search,
ResolveObject,
MarkAllAsRead,
SaveUserSettings,
TransferCommunity,
Expand Down
8 changes: 8 additions & 0 deletions src/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
GetModlog,
GetSite,
GetSiteConfig,
ResolveObject,
SaveSiteConfig,
Search,
TransferSite,
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit f32772c

Please sign in to comment.