mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 20:31: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,
|
CreatePostReport,
|
||||||
DeletePost,
|
DeletePost,
|
||||||
EditPost,
|
EditPost,
|
||||||
|
FeaturePost,
|
||||||
GetPost,
|
GetPost,
|
||||||
GetPostResponse,
|
GetPostResponse,
|
||||||
GetPosts,
|
GetPosts,
|
||||||
|
@ -105,7 +106,6 @@ import {
|
||||||
RemovePost,
|
RemovePost,
|
||||||
ResolvePostReport,
|
ResolvePostReport,
|
||||||
SavePost,
|
SavePost,
|
||||||
StickyPost,
|
|
||||||
} from "./interfaces/api/post";
|
} from "./interfaces/api/post";
|
||||||
import {
|
import {
|
||||||
ApproveRegistrationApplication,
|
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) {
|
async featurePost(form: FeaturePost) {
|
||||||
return this.wrapper(HttpType.Post, "/post/sticky", form, PostResponse);
|
return this.wrapper(HttpType.Post, "/post/feature", form, PostResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,6 +53,8 @@ export interface PostAggregates {
|
||||||
*/
|
*/
|
||||||
newest_comment_time_necro: string;
|
newest_comment_time_necro: string;
|
||||||
newest_comment_time: 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 { Expose, Transform, Type } from "class-transformer";
|
||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { toOption, toUndefined } from "../../utils";
|
import { toOption, toUndefined } from "../../utils";
|
||||||
import { ListingType, SiteMetadata, SortType } from "../others";
|
import {
|
||||||
|
ListingType,
|
||||||
|
PostFeatureType,
|
||||||
|
SiteMetadata,
|
||||||
|
SortType,
|
||||||
|
} from "../others";
|
||||||
import {
|
import {
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
CommunityView,
|
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;
|
post_id: number;
|
||||||
stickied: boolean;
|
featured: boolean;
|
||||||
|
feature_type: PostFeatureType;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
constructor(init: StickyPost) {
|
constructor(init: FeaturePost) {
|
||||||
Object.assign(this, init);
|
Object.assign(this, init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@ import {
|
||||||
ModAddView,
|
ModAddView,
|
||||||
ModBanFromCommunityView,
|
ModBanFromCommunityView,
|
||||||
ModBanView,
|
ModBanView,
|
||||||
|
ModFeaturePostView,
|
||||||
ModLockPostView,
|
ModLockPostView,
|
||||||
ModRemoveCommentView,
|
ModRemoveCommentView,
|
||||||
ModRemoveCommunityView,
|
ModRemoveCommunityView,
|
||||||
ModRemovePostView,
|
ModRemovePostView,
|
||||||
ModStickyPostView,
|
|
||||||
ModTransferCommunityView,
|
ModTransferCommunityView,
|
||||||
PersonBlockView,
|
PersonBlockView,
|
||||||
PersonViewSafe,
|
PersonViewSafe,
|
||||||
|
@ -133,8 +133,8 @@ export class GetModlogResponse {
|
||||||
removed_posts: ModRemovePostView[];
|
removed_posts: ModRemovePostView[];
|
||||||
@Type(() => ModLockPostView)
|
@Type(() => ModLockPostView)
|
||||||
locked_posts: ModLockPostView[];
|
locked_posts: ModLockPostView[];
|
||||||
@Type(() => ModStickyPostView)
|
@Type(() => ModFeaturePostView)
|
||||||
stickied_posts: ModStickyPostView[];
|
featured_posts: ModFeaturePostView[];
|
||||||
@Type(() => ModRemoveCommentView)
|
@Type(() => ModRemoveCommentView)
|
||||||
removed_comments: ModRemoveCommentView[];
|
removed_comments: ModRemoveCommentView[];
|
||||||
@Type(() => ModRemoveCommunityView)
|
@Type(() => ModRemoveCommunityView)
|
||||||
|
|
|
@ -27,7 +27,7 @@ export enum UserOperation {
|
||||||
DeletePost,
|
DeletePost,
|
||||||
RemovePost,
|
RemovePost,
|
||||||
LockPost,
|
LockPost,
|
||||||
StickyPost,
|
FeaturePost,
|
||||||
MarkPostAsRead,
|
MarkPostAsRead,
|
||||||
SavePost,
|
SavePost,
|
||||||
EditCommunity,
|
EditCommunity,
|
||||||
|
@ -192,7 +192,7 @@ export enum ModlogActionType {
|
||||||
All = "All",
|
All = "All",
|
||||||
ModRemovePost = "ModRemovePost",
|
ModRemovePost = "ModRemovePost",
|
||||||
ModLockPost = "ModLockPost",
|
ModLockPost = "ModLockPost",
|
||||||
ModStickyPost = "ModStickyPost",
|
ModFeaturePost = "ModFeaturePost",
|
||||||
ModRemoveComment = "ModRemoveComment",
|
ModRemoveComment = "ModRemoveComment",
|
||||||
ModRemoveCommunity = "ModRemoveCommunity",
|
ModRemoveCommunity = "ModRemoveCommunity",
|
||||||
ModBanFromCommunity = "ModBanFromCommunity",
|
ModBanFromCommunity = "ModBanFromCommunity",
|
||||||
|
@ -216,6 +216,14 @@ export enum SubscribedType {
|
||||||
Pending = "Pending",
|
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.
|
* 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>;
|
updated: Option<string>;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
nsfw: boolean;
|
nsfw: boolean;
|
||||||
stickied: boolean;
|
|
||||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
@Expose()
|
@Expose()
|
||||||
|
@ -249,6 +248,8 @@ export class Post {
|
||||||
ap_id: string;
|
ap_id: string;
|
||||||
local: boolean;
|
local: boolean;
|
||||||
language_id: number;
|
language_id: number;
|
||||||
|
featured_community: boolean;
|
||||||
|
featured_local: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PasswordResetRequest {
|
export class PasswordResetRequest {
|
||||||
|
@ -284,14 +285,12 @@ export class ModLockPost {
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ModStickyPost {
|
export class ModFeaturePost {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
featured: boolean;
|
||||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
is_featured_community: boolean;
|
||||||
@Expose()
|
|
||||||
stickied: Option<boolean>;
|
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,11 @@ import {
|
||||||
ModAddCommunity,
|
ModAddCommunity,
|
||||||
ModBan,
|
ModBan,
|
||||||
ModBanFromCommunity,
|
ModBanFromCommunity,
|
||||||
|
ModFeaturePost,
|
||||||
ModLockPost,
|
ModLockPost,
|
||||||
ModRemoveComment,
|
ModRemoveComment,
|
||||||
ModRemoveCommunity,
|
ModRemoveCommunity,
|
||||||
ModRemovePost,
|
ModRemovePost,
|
||||||
ModStickyPost,
|
|
||||||
ModTransferCommunity,
|
ModTransferCommunity,
|
||||||
PersonMention,
|
PersonMention,
|
||||||
PersonSafe,
|
PersonSafe,
|
||||||
|
@ -342,9 +342,9 @@ export class ModRemovePostView {
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ModStickyPostView {
|
export class ModFeaturePostView {
|
||||||
@Type(() => ModStickyPost)
|
@Type(() => ModFeaturePost)
|
||||||
mod_sticky_post: ModStickyPost;
|
mod_feature_post: ModFeaturePost;
|
||||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
@Expose()
|
@Expose()
|
||||||
|
|
|
@ -60,6 +60,7 @@ import {
|
||||||
CreatePostReport,
|
CreatePostReport,
|
||||||
DeletePost,
|
DeletePost,
|
||||||
EditPost,
|
EditPost,
|
||||||
|
FeaturePost,
|
||||||
GetPost,
|
GetPost,
|
||||||
GetPosts,
|
GetPosts,
|
||||||
GetSiteMetadata,
|
GetSiteMetadata,
|
||||||
|
@ -69,7 +70,6 @@ import {
|
||||||
RemovePost,
|
RemovePost,
|
||||||
ResolvePostReport,
|
ResolvePostReport,
|
||||||
SavePost,
|
SavePost,
|
||||||
StickyPost,
|
|
||||||
} from "./interfaces/api/post";
|
} from "./interfaces/api/post";
|
||||||
import {
|
import {
|
||||||
ApproveRegistrationApplication,
|
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) {
|
featurePost(form: FeaturePost) {
|
||||||
return wrapper(UserOperation.StickyPost, form);
|
return wrapper(UserOperation.FeaturePost, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue