Skip to content

Commit

Permalink
Adding mark post as read. Fixes #36 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines authored May 22, 2022
1 parent f67a5c1 commit 357bf2f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import {
ListPostReports,
ListPostReportsResponse,
LockPost,
MarkPostAsRead,
PostReportResponse,
PostResponse,
RemovePost,
Expand Down Expand Up @@ -362,6 +363,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<PostResponse> {
return this.wrapper(HttpType.Post, "/post/mark_as_read", form);
}

/**
* A moderator can lock a post ( IE disable new comments ).
* `HTTP.POST /post/lock`
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/api/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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.
*/
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/others.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum UserOperation {
RemovePost,
LockPost,
StickyPost,
MarkPostAsRead,
SavePost,
EditCommunity,
DeleteCommunity,
Expand Down
8 changes: 8 additions & 0 deletions src/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
GetSiteMetadata,
ListPostReports,
LockPost,
MarkPostAsRead,
RemovePost,
ResolvePostReport,
SavePost,
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 357bf2f

Please sign in to comment.