From 533e222a0ce27a3cb318a4861f75e4b17f25c0ec Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Wed, 12 Apr 2023 23:48:54 +0000 Subject: [PATCH] Add getComment to client (#111) --- src/http.ts | 14 ++++++++++++++ src/interfaces/api/comment.ts | 5 +++++ src/interfaces/others.ts | 1 + src/websocket.ts | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/src/http.ts b/src/http.ts index 1eb01f7..6e41886 100644 --- a/src/http.ts +++ b/src/http.ts @@ -9,6 +9,7 @@ import { CreateCommentReport, DeleteComment, EditComment, + GetComment, GetComments, GetCommentsResponse, ListCommentReports, @@ -673,6 +674,19 @@ export class LemmyHttp { ); } + /** + * Get / fetch comment. + * + * `HTTP.GET /comment` + */ + getComment(form: GetComment) { + return this.wrapper( + HttpType.Get, + "/comment", + form + ); + } + /** * Report a comment. * diff --git a/src/interfaces/api/comment.ts b/src/interfaces/api/comment.ts index d72d6ac..f55ed8e 100644 --- a/src/interfaces/api/comment.ts +++ b/src/interfaces/api/comment.ts @@ -92,6 +92,11 @@ export interface GetCommentsResponse { comments: CommentView[]; } +export interface GetComment { + id: number; + auth?: string; +} + export interface CreateCommentReport { comment_id: number; reason: string; diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index 59824c5..e7f893d 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -67,6 +67,7 @@ export enum UserOperation { GetPrivateMessages, UserJoin, GetComments, + GetComment, PostJoin, CommunityJoin, ChangePassword, diff --git a/src/websocket.ts b/src/websocket.ts index 2a6b933..61ca2d3 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -4,6 +4,7 @@ import { CreateCommentReport, DeleteComment, EditComment, + GetComment, GetComments, ListCommentReports, RemoveComment, @@ -301,6 +302,13 @@ export class LemmyWebsocket { return wrapper(UserOperation.GetComments, form); } + /** + * Get / fetch comment. + */ + getComment(form: GetComment) { + return wrapper(UserOperation.GetComment, form); + } + /** * Like / vote on a post. */