From 57332bad9934658c5f23302128dabc8e9034729e Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 29 Feb 2024 10:13:22 -0500 Subject: [PATCH] Adding hide post. --- src/http.ts | 14 ++++++++++++++ src/index.ts | 1 + src/types/GetPosts.ts | 1 + src/types/HidePost.ts | 7 +++++++ src/types/LemmyErrorType.ts | 1 + src/types/MarkPostAsRead.ts | 3 +-- src/types/PostView.ts | 1 + 7 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/types/HidePost.ts diff --git a/src/http.ts b/src/http.ts index 15b8f8d..337399f 100644 --- a/src/http.ts +++ b/src/http.ts @@ -138,6 +138,7 @@ import { ListPostLikes } from "./types/ListPostLikes"; import { ListPostLikesResponse } from "./types/ListPostLikesResponse"; import { ListCommentLikes } from "./types/ListCommentLikes"; import { ListCommentLikesResponse } from "./types/ListCommentLikesResponse"; +import { HidePost } from "./types/HidePost"; enum HttpType { Get = "GET", @@ -567,6 +568,19 @@ export class LemmyHttp { ); } + /** + * Hide a post from list views. + * + * `HTTP.POST /post/hide` + */ + hidePost(form: HidePost) { + return this.#wrapper( + HttpType.Post, + "/post/hide", + form, + ); + } + /** * A moderator can lock a post ( IE disable new comments ). * diff --git a/src/index.ts b/src/index.ts index 0657657..e1191c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,6 +110,7 @@ export { GetSiteResponse } from "./types/GetSiteResponse"; export { GetUnreadCountResponse } from "./types/GetUnreadCountResponse"; export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse"; export { HideCommunity } from "./types/HideCommunity"; +export { HidePost } from "./types/HidePost"; export { Instance } from "./types/Instance"; export { InstanceBlockView } from "./types/InstanceBlockView"; export { InstanceId } from "./types/InstanceId"; diff --git a/src/types/GetPosts.ts b/src/types/GetPosts.ts index eb852e0..065837a 100644 --- a/src/types/GetPosts.ts +++ b/src/types/GetPosts.ts @@ -14,5 +14,6 @@ export interface GetPosts { saved_only?: boolean; liked_only?: boolean; disliked_only?: boolean; + show_hidden?: boolean; page_cursor?: PaginationCursor; } diff --git a/src/types/HidePost.ts b/src/types/HidePost.ts new file mode 100644 index 0000000..b0a3da9 --- /dev/null +++ b/src/types/HidePost.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PostId } from "./PostId"; + +export interface HidePost { + post_ids: Array; + hide: boolean; +} diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index 857b894..b0836e3 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -112,6 +112,7 @@ export type LemmyErrorType = | { error: "couldnt_like_post" } | { error: "couldnt_save_post" } | { error: "couldnt_mark_post_as_read" } + | { error: "couldnt_hide_post" } | { error: "couldnt_update_community" } | { error: "couldnt_update_replies" } | { error: "couldnt_update_person_mentions" } diff --git a/src/types/MarkPostAsRead.ts b/src/types/MarkPostAsRead.ts index 3879374..979997e 100644 --- a/src/types/MarkPostAsRead.ts +++ b/src/types/MarkPostAsRead.ts @@ -2,7 +2,6 @@ import type { PostId } from "./PostId"; export interface MarkPostAsRead { - post_id?: PostId; - post_ids?: Array; + post_ids: Array; read: boolean; } diff --git a/src/types/PostView.ts b/src/types/PostView.ts index 28bc00f..0318974 100644 --- a/src/types/PostView.ts +++ b/src/types/PostView.ts @@ -16,6 +16,7 @@ export interface PostView { subscribed: SubscribedType; saved: boolean; read: boolean; + hidden: boolean; creator_blocked: boolean; my_vote?: number; unread_comments: /* integer */ number;