mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 12:21:12 +00:00
Add FeaturePost support (#88)
* Add FeaturePost support * Make featured not optional
This commit is contained in:
parent
a4ed93ae16
commit
60c5c85cd7
8 changed files with 44 additions and 29 deletions
10
src/http.ts
10
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,6 +53,8 @@ export interface PostAggregates {
|
|||
*/
|
||||
newest_comment_time_necro: string;
|
||||
newest_comment_time: string;
|
||||
featured_community: boolean;
|
||||
featured_local: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -229,7 +229,6 @@ export class Post {
|
|||
updated: Option<string>;
|
||||
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<boolean>;
|
||||
featured: boolean;
|
||||
is_featured_community: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue