From 001d1ffed6238b926fb998326349f178f018e890 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Tue, 17 Aug 2021 20:24:00 -0400 Subject: [PATCH] Adding GetSiteMetadata --- src/http.ts | 8 ++++++++ src/interfaces/api/post.ts | 9 +++++++++ src/interfaces/others.ts | 8 ++++++++ src/websocket.ts | 5 +++++ 4 files changed, 30 insertions(+) diff --git a/src/http.ts b/src/http.ts index ede9b4c..4026e12 100644 --- a/src/http.ts +++ b/src/http.ts @@ -39,6 +39,8 @@ import { GetPostResponse, GetPosts, GetPostsResponse, + GetSiteMetadata, + GetSiteMetadataResponse, LockPost, PostResponse, RemovePost, @@ -238,6 +240,12 @@ export class LemmyHttp { return this.wrapper(HttpType.Put, '/post/save', form); } + async getSiteMetadata( + form: GetSiteMetadata + ): Promise { + return this.wrapper(HttpType.Get, '/post/site_metadata', form); + } + async createComment(form: CreateComment): Promise { return this.wrapper(HttpType.Post, '/comment', form); } diff --git a/src/interfaces/api/post.ts b/src/interfaces/api/post.ts index 32afea5..6562b28 100644 --- a/src/interfaces/api/post.ts +++ b/src/interfaces/api/post.ts @@ -1,3 +1,4 @@ +import { SiteMetadata } from '..'; import { CommunityView, CommentView, @@ -141,3 +142,11 @@ export interface ListPostReports { export interface ListPostReportsResponse { posts: PostReportView[]; } + +export interface GetSiteMetadata { + url: string; +} + +export interface GetSiteMetadataResponse { + metadata: SiteMetadata; +} diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index edbaef5..618df11 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -64,6 +64,7 @@ export enum UserOperation { PostJoin, CommunityJoin, ChangePassword, + GetSiteMetadata, } export enum SortType { @@ -106,3 +107,10 @@ export interface WebSocketJsonResponse { error?: string; reconnect?: boolean; } + +export interface SiteMetadata { + title?: string; + description?: string; + image?: string; + html?: string; +} diff --git a/src/websocket.ts b/src/websocket.ts index 239ce1e..d8083d4 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -28,6 +28,7 @@ import { EditPost, GetPost, GetPosts, + GetSiteMetadata, LockPost, RemovePost, SavePost, @@ -201,6 +202,10 @@ export class LemmyWebsocket { return wrapper(UserOperation.SavePost, form); } + getSiteMetadata(form: GetSiteMetadata) { + return wrapper(UserOperation.GetSiteMetadata, form); + } + banFromCommunity(form: BanFromCommunity) { return wrapper(UserOperation.BanFromCommunity, form); }