diff --git a/src/http.ts b/src/http.ts index b3c3975..c9b4397 100644 --- a/src/http.ts +++ b/src/http.ts @@ -90,6 +90,7 @@ import { CreatePostReport, DeletePost, EditPost, + FeaturePost, GetPost, GetPostResponse, GetPosts, @@ -105,7 +106,6 @@ import { RemovePost, ResolvePostReport, SavePost, - StickyPost, } from "./interfaces/api/post"; import { ApproveRegistrationApplication, @@ -441,12 +441,12 @@ export class LemmyHttp { } /** - * A moderator can sticky a post ( IE stick it to the top of a community ). + * A moderator can feature a community post ( IE stick it to the top of a community ). * - * `HTTP.POST /post/sticky` + * `HTTP.POST /post/feature` */ - async stickyPost(form: StickyPost) { - return this.wrapper(HttpType.Post, "/post/sticky", form, PostResponse); + async featurePost(form: FeaturePost) { + return this.wrapper(HttpType.Post, "/post/feature", form, PostResponse); } /** diff --git a/src/interfaces/aggregates.ts b/src/interfaces/aggregates.ts index 115f1f2..d3c64fa 100644 --- a/src/interfaces/aggregates.ts +++ b/src/interfaces/aggregates.ts @@ -53,6 +53,8 @@ export interface PostAggregates { */ newest_comment_time_necro: string; newest_comment_time: string; + featured_community: boolean; + featured_local: boolean; } /** diff --git a/src/interfaces/api/post.ts b/src/interfaces/api/post.ts index fbbf2bb..5ba1d35 100644 --- a/src/interfaces/api/post.ts +++ b/src/interfaces/api/post.ts @@ -2,7 +2,12 @@ import { Option } from "@sniptt/monads"; import { Expose, Transform, Type } from "class-transformer"; import "reflect-metadata"; import { toOption, toUndefined } from "../../utils"; -import { ListingType, SiteMetadata, SortType } from "../others"; +import { + ListingType, + PostFeatureType, + SiteMetadata, + SortType, +} from "../others"; import { CommunityModeratorView, CommunityView, @@ -218,14 +223,15 @@ export class LockPost { } /** - * Only admins and mods can sticky a post. + * Only admins and mods can feature a community post. */ -export class StickyPost { +export class FeaturePost { post_id: number; - stickied: boolean; + featured: boolean; + feature_type: PostFeatureType; auth: string; - constructor(init: StickyPost) { + constructor(init: FeaturePost) { Object.assign(this, init); } } diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index a843f9c..da66f34 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -19,11 +19,11 @@ import { ModAddView, ModBanFromCommunityView, ModBanView, + ModFeaturePostView, ModLockPostView, ModRemoveCommentView, ModRemoveCommunityView, ModRemovePostView, - ModStickyPostView, ModTransferCommunityView, PersonBlockView, PersonViewSafe, @@ -133,8 +133,8 @@ export class GetModlogResponse { removed_posts: ModRemovePostView[]; @Type(() => ModLockPostView) locked_posts: ModLockPostView[]; - @Type(() => ModStickyPostView) - stickied_posts: ModStickyPostView[]; + @Type(() => ModFeaturePostView) + featured_posts: ModFeaturePostView[]; @Type(() => ModRemoveCommentView) removed_comments: ModRemoveCommentView[]; @Type(() => ModRemoveCommunityView) diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index fd587b6..933d2ef 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -27,7 +27,7 @@ export enum UserOperation { DeletePost, RemovePost, LockPost, - StickyPost, + FeaturePost, MarkPostAsRead, SavePost, EditCommunity, @@ -192,7 +192,7 @@ export enum ModlogActionType { All = "All", ModRemovePost = "ModRemovePost", ModLockPost = "ModLockPost", - ModStickyPost = "ModStickyPost", + ModFeaturePost = "ModFeaturePost", ModRemoveComment = "ModRemoveComment", ModRemoveCommunity = "ModRemoveCommunity", ModBanFromCommunity = "ModBanFromCommunity", @@ -216,6 +216,14 @@ export enum SubscribedType { Pending = "Pending", } +/** + * Different Subscribed states + */ +export enum PostFeatureType { + Local = "Local", + Community = "Community", +} + /** * A holder for a site's metadata ( such as opengraph tags ), used for post links. */ diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index c77c4ad..03ccfe8 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -229,7 +229,6 @@ export class Post { updated: Option; deleted: boolean; nsfw: boolean; - stickied: boolean; @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() @@ -249,6 +248,8 @@ export class Post { ap_id: string; local: boolean; language_id: number; + featured_community: boolean; + featured_local: boolean; } export class PasswordResetRequest { @@ -284,14 +285,12 @@ export class ModLockPost { when_: string; } -export class ModStickyPost { +export class ModFeaturePost { id: number; mod_person_id: number; post_id: number; - @Transform(({ value }) => toOption(value), { toClassOnly: true }) - @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) - @Expose() - stickied: Option; + featured: boolean; + is_featured_community: boolean; when_: string; } diff --git a/src/interfaces/views.ts b/src/interfaces/views.ts index 0c2ebfd..79c3cd9 100644 --- a/src/interfaces/views.ts +++ b/src/interfaces/views.ts @@ -26,11 +26,11 @@ import { ModAddCommunity, ModBan, ModBanFromCommunity, + ModFeaturePost, ModLockPost, ModRemoveComment, ModRemoveCommunity, ModRemovePost, - ModStickyPost, ModTransferCommunity, PersonMention, PersonSafe, @@ -342,9 +342,9 @@ export class ModRemovePostView { community: CommunitySafe; } -export class ModStickyPostView { - @Type(() => ModStickyPost) - mod_sticky_post: ModStickyPost; +export class ModFeaturePostView { + @Type(() => ModFeaturePost) + mod_feature_post: ModFeaturePost; @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() diff --git a/src/websocket.ts b/src/websocket.ts index 71947be..e70adb6 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -60,6 +60,7 @@ import { CreatePostReport, DeletePost, EditPost, + FeaturePost, GetPost, GetPosts, GetSiteMetadata, @@ -69,7 +70,6 @@ import { RemovePost, ResolvePostReport, SavePost, - StickyPost, } from "./interfaces/api/post"; import { ApproveRegistrationApplication, @@ -333,10 +333,10 @@ export class LemmyWebsocket { } /** - * A moderator can sticky a post ( IE stick it to the top of a community ). + * A moderator can feature a post ( IE stick it to the top of a community ). */ - stickyPost(form: StickyPost) { - return wrapper(UserOperation.StickyPost, form); + featurePost(form: FeaturePost) { + return wrapper(UserOperation.FeaturePost, form); } /**