From d0fbcf2ec2561608e2a9045dda19d234d24f660d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 15 May 2022 16:08:55 -0400 Subject: [PATCH] Adding mark post as read. Fixes #36 --- src/http.ts | 9 +++++++++ src/interfaces/api/post.ts | 9 +++++++++ src/interfaces/others.ts | 1 + src/websocket.ts | 8 ++++++++ 4 files changed, 27 insertions(+) diff --git a/src/http.ts b/src/http.ts index 29af416..50003c1 100644 --- a/src/http.ts +++ b/src/http.ts @@ -93,6 +93,7 @@ import { ListPostReports, ListPostReportsResponse, LockPost, + MarkPostAsRead, PostReportResponse, PostResponse, RemovePost, @@ -334,6 +335,14 @@ export class LemmyHttp { return this.wrapper(HttpType.Post, "/post/remove", form); } + /** + * Mark a post as read. + * `HTTP.POST /post/mark_as_read` + */ + async markPostAsRead(form: MarkPostAsRead): Promise { + return this.wrapper(HttpType.Post, "/post/mark_as_read", form); + } + /** * A moderator can lock a post ( IE disable new comments ). */ diff --git a/src/interfaces/api/post.ts b/src/interfaces/api/post.ts index 651bed4..0600cd1 100644 --- a/src/interfaces/api/post.ts +++ b/src/interfaces/api/post.ts @@ -95,6 +95,15 @@ export interface RemovePost { auth: string; } +/** + * Marks a post as read. + */ +export interface MarkPostAsRead { + post_id: number; + read: boolean; + auth: string; +} + /** * Only admins and mods can lock a post. */ diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index 72fce46..7676d7f 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -26,6 +26,7 @@ export enum UserOperation { RemovePost, LockPost, StickyPost, + MarkPostAsRead, SavePost, EditCommunity, DeleteCommunity, diff --git a/src/websocket.ts b/src/websocket.ts index 35f91b4..6c2da7c 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -61,6 +61,7 @@ import { GetSiteMetadata, ListPostReports, LockPost, + MarkPostAsRead, RemovePost, ResolvePostReport, SavePost, @@ -332,6 +333,13 @@ export class LemmyWebsocket { return wrapper(UserOperation.StickyPost, form); } + /** + * Mark a post as read. + */ + markPostAsRead(form: MarkPostAsRead) { + return wrapper(UserOperation.MarkPostAsRead, form); + } + /** * Save a post. */