Merge branch 'v2_api'
This commit is contained in:
commit
52fbba26e5
17 changed files with 1623 additions and 1345 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "lemmy-js-client",
|
||||
"description": "A javascript / typescript client for Lemmy",
|
||||
"version": "1.0.16",
|
||||
"version": "0.9.0-rc.12",
|
||||
"author": "Dessalines <tyhou13@gmx.com>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/index.js",
|
||||
|
|
295
src/http.ts
295
src/http.ts
|
@ -1,92 +1,97 @@
|
|||
import fetch from 'node-fetch';
|
||||
import {
|
||||
MessageType,
|
||||
LoginForm,
|
||||
RegisterForm,
|
||||
CommunityForm,
|
||||
DeleteCommunityForm,
|
||||
RemoveCommunityForm,
|
||||
PostForm,
|
||||
DeletePostForm,
|
||||
RemovePostForm,
|
||||
LockPostForm,
|
||||
StickyPostForm,
|
||||
SavePostForm,
|
||||
CommentForm,
|
||||
DeleteCommentForm,
|
||||
RemoveCommentForm,
|
||||
MarkCommentAsReadForm,
|
||||
SaveCommentForm,
|
||||
CommentLikeForm,
|
||||
GetPostForm,
|
||||
GetPostsForm,
|
||||
CreatePostLikeForm,
|
||||
GetCommunityForm,
|
||||
FollowCommunityForm,
|
||||
GetFollowedCommunitiesForm,
|
||||
GetUserDetailsForm,
|
||||
ListCommunitiesForm,
|
||||
GetModlogForm,
|
||||
BanFromCommunityForm,
|
||||
AddModToCommunityForm,
|
||||
TransferCommunityForm,
|
||||
AddAdminForm,
|
||||
TransferSiteForm,
|
||||
BanUserForm,
|
||||
SiteForm,
|
||||
GetRepliesForm,
|
||||
GetUserMentionsForm,
|
||||
MarkUserMentionAsReadForm,
|
||||
SearchForm,
|
||||
UserSettingsForm,
|
||||
DeleteAccountForm,
|
||||
PasswordResetForm,
|
||||
PasswordChangeForm,
|
||||
PrivateMessageForm,
|
||||
EditPrivateMessageForm,
|
||||
DeletePrivateMessageForm,
|
||||
MarkPrivateMessageAsReadForm,
|
||||
GetPrivateMessagesForm,
|
||||
GetCommentsForm,
|
||||
UserJoinForm,
|
||||
GetSiteConfig,
|
||||
GetSiteForm,
|
||||
SiteConfigForm,
|
||||
MarkAllAsReadForm,
|
||||
GetSiteResponse,
|
||||
GetSiteConfigResponse,
|
||||
SiteResponse,
|
||||
LoginResponse,
|
||||
ListCategoriesResponse,
|
||||
GetModlogResponse,
|
||||
SearchResponse,
|
||||
PostResponse,
|
||||
CommentResponse,
|
||||
CommunityResponse,
|
||||
GetRepliesResponse,
|
||||
BanUserResponse,
|
||||
GetPostResponse,
|
||||
AddAdminResponse,
|
||||
GetPostsResponse,
|
||||
UserJoinResponse,
|
||||
GetCaptchaResponse,
|
||||
CreateComment,
|
||||
CreateCommentLike,
|
||||
DeleteComment,
|
||||
EditComment,
|
||||
GetComments,
|
||||
GetCommentsResponse,
|
||||
UserDetailsResponse,
|
||||
UserMentionResponse,
|
||||
GetUserMentionsResponse,
|
||||
GetCommunityResponse,
|
||||
PrivateMessageResponse,
|
||||
ListCommunitiesResponse,
|
||||
PrivateMessagesResponse,
|
||||
BanFromCommunityResponse,
|
||||
MarkCommentAsRead,
|
||||
RemoveComment,
|
||||
SaveComment,
|
||||
} from './interfaces/api/comment';
|
||||
import {
|
||||
AddModToCommunity,
|
||||
AddModToCommunityResponse,
|
||||
BanFromCommunity,
|
||||
BanFromCommunityResponse,
|
||||
CommunityResponse,
|
||||
CreateCommunity,
|
||||
DeleteCommunity,
|
||||
EditCommunity,
|
||||
FollowCommunity,
|
||||
GetCommunity,
|
||||
GetCommunityResponse,
|
||||
GetFollowedCommunities,
|
||||
GetFollowedCommunitiesResponse,
|
||||
ListCommunities,
|
||||
ListCommunitiesResponse,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from './interfaces/api/community';
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
DeletePost,
|
||||
EditPost,
|
||||
GetPost,
|
||||
GetPostResponse,
|
||||
GetPosts,
|
||||
GetPostsResponse,
|
||||
LockPost,
|
||||
PostResponse,
|
||||
RemovePost,
|
||||
SavePost,
|
||||
StickyPost,
|
||||
} from './interfaces/api/post';
|
||||
import {
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
GetModlogResponse,
|
||||
GetSite,
|
||||
GetSiteConfig,
|
||||
GetSiteConfigResponse,
|
||||
GetSiteResponse,
|
||||
ListCategoriesResponse,
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
SearchResponse,
|
||||
SiteResponse,
|
||||
TransferSite,
|
||||
} from './interfaces/api/site';
|
||||
import {
|
||||
AddAdmin,
|
||||
AddAdminResponse,
|
||||
BanUser,
|
||||
BanUserResponse,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetCaptchaResponse,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetRepliesResponse,
|
||||
GetUserDetails,
|
||||
GetUserDetailsResponse,
|
||||
GetUserMentions,
|
||||
GetUserMentionsResponse,
|
||||
Login,
|
||||
LoginResponse,
|
||||
MarkAllAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
MarkUserMentionAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
PasswordResetResponse,
|
||||
PostJoinForm,
|
||||
PostJoinResponse,
|
||||
CommunityJoinForm,
|
||||
CommunityJoinResponse,
|
||||
} from './interfaces';
|
||||
PrivateMessageResponse,
|
||||
PrivateMessagesResponse,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
UserMentionResponse,
|
||||
} from './interfaces/api/user';
|
||||
|
||||
enum HttpType {
|
||||
Get = 'GET',
|
||||
|
@ -106,19 +111,19 @@ export class LemmyHttp {
|
|||
}
|
||||
}
|
||||
|
||||
async getSite(form: GetSiteForm): Promise<GetSiteResponse> {
|
||||
async getSite(form: GetSite): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Get, '/site', form);
|
||||
}
|
||||
|
||||
async createSite(form: SiteForm): Promise<SiteResponse> {
|
||||
async createSite(form: CreateSite): Promise<SiteResponse> {
|
||||
return this.wrapper(HttpType.Post, '/site', form);
|
||||
}
|
||||
|
||||
async editSite(form: SiteForm): Promise<SiteResponse> {
|
||||
async editSite(form: EditSite): Promise<SiteResponse> {
|
||||
return this.wrapper(HttpType.Put, '/site', form);
|
||||
}
|
||||
|
||||
async transferSite(form: TransferSiteForm): Promise<GetSiteResponse> {
|
||||
async transferSite(form: TransferSite): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Post, '/site/transfer', form);
|
||||
}
|
||||
|
||||
|
@ -126,7 +131,7 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Get, '/site/config', form);
|
||||
}
|
||||
|
||||
async saveSiteConfig(form: SiteConfigForm): Promise<GetSiteConfigResponse> {
|
||||
async saveSiteConfig(form: SaveSiteConfig): Promise<GetSiteConfigResponse> {
|
||||
return this.wrapper(HttpType.Put, '/site/config', form);
|
||||
}
|
||||
|
||||
|
@ -134,213 +139,199 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Get, '/categories', {});
|
||||
}
|
||||
|
||||
async getModlog(form: GetModlogForm): Promise<GetModlogResponse> {
|
||||
async getModlog(form: GetModlog): Promise<GetModlogResponse> {
|
||||
return this.wrapper(HttpType.Get, '/modlog', form);
|
||||
}
|
||||
|
||||
async search(form: SearchForm): Promise<SearchResponse> {
|
||||
async search(form: Search): Promise<SearchResponse> {
|
||||
return this.wrapper(HttpType.Get, '/search', form);
|
||||
}
|
||||
|
||||
async createCommunity(form: CommunityForm): Promise<CommunityResponse> {
|
||||
async createCommunity(form: CreateCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community', form);
|
||||
}
|
||||
|
||||
async getCommunity(form: GetCommunityForm): Promise<GetCommunityResponse> {
|
||||
async getCommunity(form: GetCommunity): Promise<GetCommunityResponse> {
|
||||
return this.wrapper(HttpType.Get, '/community', form);
|
||||
}
|
||||
|
||||
async editCommunity(form: CommunityForm): Promise<CommunityResponse> {
|
||||
async editCommunity(form: EditCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Put, '/community', form);
|
||||
}
|
||||
|
||||
async listCommunities(
|
||||
form: ListCommunitiesForm
|
||||
form: ListCommunities
|
||||
): Promise<ListCommunitiesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/community/list', form);
|
||||
}
|
||||
|
||||
async followCommunity(form: FollowCommunityForm): Promise<CommunityResponse> {
|
||||
async followCommunity(form: FollowCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/follow', form);
|
||||
}
|
||||
|
||||
async deleteCommunity(form: DeleteCommunityForm): Promise<CommunityResponse> {
|
||||
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/delete', form);
|
||||
}
|
||||
|
||||
async removeCommunity(form: RemoveCommunityForm): Promise<CommunityResponse> {
|
||||
async removeCommunity(form: RemoveCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/remove', form);
|
||||
}
|
||||
|
||||
async transferCommunity(
|
||||
form: TransferCommunityForm
|
||||
form: TransferCommunity
|
||||
): Promise<GetCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/transfer', form);
|
||||
}
|
||||
|
||||
async banFromCommunity(
|
||||
form: BanFromCommunityForm
|
||||
form: BanFromCommunity
|
||||
): Promise<BanFromCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/ban_user', form);
|
||||
}
|
||||
|
||||
async addModToCommunity(
|
||||
form: AddModToCommunityForm
|
||||
form: AddModToCommunity
|
||||
): Promise<AddModToCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/mod', form);
|
||||
}
|
||||
|
||||
async createPost(form: PostForm): Promise<PostResponse> {
|
||||
async createPost(form: CreatePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post', form);
|
||||
}
|
||||
|
||||
async getPost(form: GetPostForm): Promise<GetPostResponse> {
|
||||
async getPost(form: GetPost): Promise<GetPostResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post', form);
|
||||
}
|
||||
|
||||
async editPost(form: PostForm): Promise<PostResponse> {
|
||||
async editPost(form: EditPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post', form);
|
||||
}
|
||||
|
||||
async deletePost(form: DeletePostForm): Promise<PostResponse> {
|
||||
async deletePost(form: DeletePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/delete', form);
|
||||
}
|
||||
|
||||
async removePost(form: RemovePostForm): Promise<PostResponse> {
|
||||
async removePost(form: RemovePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/remove', form);
|
||||
}
|
||||
|
||||
async lockPost(form: LockPostForm): Promise<PostResponse> {
|
||||
async lockPost(form: LockPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/lock', form);
|
||||
}
|
||||
|
||||
async stickyPost(form: StickyPostForm): Promise<PostResponse> {
|
||||
async stickyPost(form: StickyPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/sticky', form);
|
||||
}
|
||||
|
||||
async getPosts(form: GetPostsForm): Promise<GetPostsResponse> {
|
||||
async getPosts(form: GetPosts): Promise<GetPostsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/list', form);
|
||||
}
|
||||
|
||||
async likePost(form: CreatePostLikeForm): Promise<PostResponse> {
|
||||
async likePost(form: CreatePostLike): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/like', form);
|
||||
}
|
||||
|
||||
async savePost(form: SavePostForm): Promise<PostResponse> {
|
||||
async savePost(form: SavePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post/save', form);
|
||||
}
|
||||
|
||||
async createComment(form: CommentForm): Promise<CommentResponse> {
|
||||
async createComment(form: CreateComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment', form);
|
||||
}
|
||||
|
||||
async editComment(form: CommentForm): Promise<CommentResponse> {
|
||||
async editComment(form: EditComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment', form);
|
||||
}
|
||||
|
||||
async deleteComment(form: DeleteCommentForm): Promise<CommentResponse> {
|
||||
async deleteComment(form: DeleteComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/delete', form);
|
||||
}
|
||||
|
||||
async removeComment(form: RemoveCommentForm): Promise<CommentResponse> {
|
||||
async removeComment(form: RemoveComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/remove', form);
|
||||
}
|
||||
|
||||
async markCommentAsRead(
|
||||
form: MarkCommentAsReadForm
|
||||
): Promise<CommentResponse> {
|
||||
async markCommentAsRead(form: MarkCommentAsRead): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/mark_as_read', form);
|
||||
}
|
||||
|
||||
async likeComment(form: CommentLikeForm): Promise<CommentResponse> {
|
||||
async likeComment(form: CreateCommentLike): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/like', form);
|
||||
}
|
||||
|
||||
async saveComment(form: SaveCommentForm): Promise<CommentResponse> {
|
||||
async saveComment(form: SaveComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment/save', form);
|
||||
}
|
||||
|
||||
async getComments(form: GetCommentsForm): Promise<GetCommentsResponse> {
|
||||
async getComments(form: GetComments): Promise<GetCommentsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/comment/list', form);
|
||||
}
|
||||
|
||||
async getPrivateMessages(
|
||||
form: GetPrivateMessagesForm
|
||||
form: GetPrivateMessages
|
||||
): Promise<PrivateMessagesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/private_message/list', form);
|
||||
}
|
||||
|
||||
async createPrivateMessage(
|
||||
form: PrivateMessageForm
|
||||
form: CreatePrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message', form);
|
||||
}
|
||||
|
||||
async editPrivateMessage(
|
||||
form: EditPrivateMessageForm
|
||||
form: EditPrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Put, '/private_message', form);
|
||||
}
|
||||
|
||||
async deletePrivateMessage(
|
||||
form: DeletePrivateMessageForm
|
||||
form: DeletePrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message/delete', form);
|
||||
}
|
||||
|
||||
async markPrivateMessageAsRead(
|
||||
form: MarkPrivateMessageAsReadForm
|
||||
form: MarkPrivateMessageAsRead
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message/mark_as_read', form);
|
||||
}
|
||||
|
||||
async register(form: RegisterForm): Promise<LoginResponse> {
|
||||
async register(form: Register): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/register', form);
|
||||
}
|
||||
|
||||
async login(form: LoginForm): Promise<LoginResponse> {
|
||||
async login(form: Login): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/login', form);
|
||||
}
|
||||
|
||||
async getUserDetails(form: GetUserDetailsForm): Promise<UserDetailsResponse> {
|
||||
async getUserDetails(form: GetUserDetails): Promise<GetUserDetailsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user', form);
|
||||
}
|
||||
|
||||
async getUserMentions(
|
||||
form: GetUserMentionsForm
|
||||
form: GetUserMentions
|
||||
): Promise<GetUserMentionsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/mention', form);
|
||||
}
|
||||
|
||||
async markUserMentionAsRead(
|
||||
form: MarkUserMentionAsReadForm
|
||||
form: MarkUserMentionAsRead
|
||||
): Promise<UserMentionResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/mention/mark_as_read', form);
|
||||
}
|
||||
|
||||
async getReplies(form: GetRepliesForm): Promise<GetRepliesResponse> {
|
||||
async getReplies(form: GetReplies): Promise<GetRepliesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/replies', form);
|
||||
}
|
||||
|
||||
async getFollowedCommunities(
|
||||
form: GetFollowedCommunitiesForm
|
||||
form: GetFollowedCommunities
|
||||
): Promise<GetFollowedCommunitiesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/followed_communities', form);
|
||||
}
|
||||
|
||||
async userJoin(form: UserJoinForm): Promise<UserJoinResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/join', form);
|
||||
}
|
||||
|
||||
async postJoin(form: PostJoinForm): Promise<PostJoinResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/join', form);
|
||||
}
|
||||
|
||||
async communityJoin(form: CommunityJoinForm): Promise<CommunityJoinResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/join', form);
|
||||
}
|
||||
|
||||
async banUser(form: BanUserForm): Promise<BanUserResponse> {
|
||||
async banUser(form: BanUser): Promise<BanUserResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/ban', form);
|
||||
}
|
||||
|
||||
|
@ -348,27 +339,27 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
||||
}
|
||||
|
||||
async deleteAccount(form: DeleteAccountForm): Promise<LoginResponse> {
|
||||
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/delete_account', form);
|
||||
}
|
||||
|
||||
async passwordReset(form: PasswordResetForm): Promise<PasswordResetResponse> {
|
||||
async passwordReset(form: PasswordReset): Promise<PasswordResetResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/password_reset', form);
|
||||
}
|
||||
|
||||
async passwordChange(form: PasswordChangeForm): Promise<LoginResponse> {
|
||||
async passwordChange(form: PasswordChange): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/password_change', form);
|
||||
}
|
||||
|
||||
async markAllAsRead(form: MarkAllAsReadForm): Promise<LoginResponse> {
|
||||
async markAllAsRead(form: MarkAllAsRead): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/mark_all_as_read', form);
|
||||
}
|
||||
|
||||
async saveUserSettings(form: UserSettingsForm): Promise<LoginResponse> {
|
||||
async saveUserSettings(form: SaveUserSettings): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Put, '/user/save_user_settings', form);
|
||||
}
|
||||
|
||||
async addAdmin(form: AddAdminForm): Promise<AddAdminResponse> {
|
||||
async addAdmin(form: AddAdmin): Promise<AddAdminResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/add', form);
|
||||
}
|
||||
|
||||
|
@ -376,11 +367,11 @@ export class LemmyHttp {
|
|||
return `${this.baseUrl}${endpoint}`;
|
||||
}
|
||||
|
||||
private async wrapper<Res>(
|
||||
private async wrapper<ResponseType, MessageType>(
|
||||
type_: HttpType,
|
||||
endpoint: string,
|
||||
form: MessageType
|
||||
): Promise<Res> {
|
||||
): Promise<ResponseType> {
|
||||
if (type_ == HttpType.Get) {
|
||||
let getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
|
||||
return fetch(getUrl, {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export * from './interfaces';
|
||||
export * from './websocket';
|
||||
export * from './http';
|
||||
export * from './websocket';
|
||||
|
|
1076
src/interfaces.ts
1076
src/interfaces.ts
File diff suppressed because it is too large
Load diff
43
src/interfaces/aggregates.ts
Normal file
43
src/interfaces/aggregates.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
export interface UserAggregates {
|
||||
id: number;
|
||||
user_id: number;
|
||||
post_count: number;
|
||||
post_score: number;
|
||||
comment_count: number;
|
||||
comment_score: number;
|
||||
}
|
||||
|
||||
export interface SiteAggregates {
|
||||
id: number;
|
||||
site_id: number;
|
||||
users: number;
|
||||
posts: number;
|
||||
comments: number;
|
||||
communities: number;
|
||||
}
|
||||
|
||||
export interface PostAggregates {
|
||||
id: number;
|
||||
post_id: number;
|
||||
comments: number;
|
||||
score: number;
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
newest_comment_time: string;
|
||||
}
|
||||
|
||||
export interface CommunityAggregates {
|
||||
id: number;
|
||||
community_id: number;
|
||||
subscribers: number;
|
||||
posts: number;
|
||||
comments: number;
|
||||
}
|
||||
|
||||
export interface CommentAggregates {
|
||||
id: number;
|
||||
comment_id: number;
|
||||
score: number;
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
}
|
115
src/interfaces/api/comment.ts
Normal file
115
src/interfaces/api/comment.ts
Normal file
|
@ -0,0 +1,115 @@
|
|||
import { CommentReportView, CommentView } from '../views';
|
||||
|
||||
export interface CreateComment {
|
||||
content: string;
|
||||
parent_id?: number;
|
||||
post_id: number;
|
||||
form_id?: string; // An optional front end ID, to tell which is coming back
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface EditComment {
|
||||
content: string;
|
||||
comment_id: number;
|
||||
form_id?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the creator can delete the comment.
|
||||
*/
|
||||
export interface DeleteComment {
|
||||
comment_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only a mod or admin can remove the comment.
|
||||
*/
|
||||
export interface RemoveComment {
|
||||
comment_id: number;
|
||||
removed: boolean;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the recipient can do this.
|
||||
*/
|
||||
export interface MarkCommentAsRead {
|
||||
comment_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface SaveComment {
|
||||
comment_id: number;
|
||||
save: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface CommentResponse {
|
||||
comment_view: CommentView;
|
||||
recipient_ids: number[];
|
||||
form_id?: string; // An optional front end ID, to tell which is coming back
|
||||
}
|
||||
|
||||
export interface CreateCommentLike {
|
||||
comment_id: number;
|
||||
score: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment listing types are `All, Subscribed, Community`
|
||||
*
|
||||
* `community_name` can only be used for local communities. To get posts for a federated community, pass `community_id` instead.
|
||||
*/
|
||||
export interface GetComments {
|
||||
type_: string;
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
community_name?: string;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetCommentsResponse {
|
||||
comments: CommentView[];
|
||||
}
|
||||
|
||||
export interface CreateCommentReport {
|
||||
comment_id: number;
|
||||
reason: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface CreateCommentReportResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface ResolveCommentReport {
|
||||
report_id: number;
|
||||
resolved: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ResolveCommentReportResponse {
|
||||
// TODO this should probably return the view
|
||||
report_id: number;
|
||||
resolved: boolean;
|
||||
}
|
||||
|
||||
export interface ListCommentReports {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
/// if no community is given, it returns reports for all communities moderated by the auth user
|
||||
community?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ListCommentReportsResponse {
|
||||
comments: CommentReportView[];
|
||||
}
|
121
src/interfaces/api/community.ts
Normal file
121
src/interfaces/api/community.ts
Normal file
|
@ -0,0 +1,121 @@
|
|||
import {
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
UserViewSafe,
|
||||
} from '../views';
|
||||
|
||||
export interface GetCommunity {
|
||||
id?: number;
|
||||
name?: string;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetCommunityResponse {
|
||||
community_view: CommunityView;
|
||||
moderators: CommunityModeratorView[];
|
||||
online: number;
|
||||
}
|
||||
|
||||
export interface CreateCommunity {
|
||||
name: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
category_id: number;
|
||||
nsfw: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface CommunityResponse {
|
||||
community_view: CommunityView;
|
||||
}
|
||||
|
||||
export interface ListCommunities {
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface ListCommunitiesResponse {
|
||||
communities: CommunityView[];
|
||||
}
|
||||
|
||||
export interface BanFromCommunity {
|
||||
community_id: number;
|
||||
user_id: number;
|
||||
ban: boolean;
|
||||
remove_data: boolean; // Removes/Restores their comments and posts for that community
|
||||
reason?: string;
|
||||
expires?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface BanFromCommunityResponse {
|
||||
user_view: UserViewSafe;
|
||||
banned: boolean;
|
||||
}
|
||||
|
||||
export interface AddModToCommunity {
|
||||
community_id: number;
|
||||
user_id: number;
|
||||
added: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface AddModToCommunityResponse {
|
||||
moderators: CommunityModeratorView[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Only mods can edit a community.
|
||||
*/
|
||||
export interface EditCommunity {
|
||||
community_id: number;
|
||||
title: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
category_id: number;
|
||||
nsfw: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface DeleteCommunity {
|
||||
community_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins can remove a community.
|
||||
*/
|
||||
export interface RemoveCommunity {
|
||||
community_id: number;
|
||||
removed: boolean;
|
||||
reason?: string;
|
||||
expires?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface FollowCommunity {
|
||||
community_id: number;
|
||||
follow: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetFollowedCommunities {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetFollowedCommunitiesResponse {
|
||||
communities: CommunityFollowerView[];
|
||||
}
|
||||
|
||||
export interface TransferCommunity {
|
||||
community_id: number;
|
||||
user_id: number;
|
||||
auth: string;
|
||||
}
|
6
src/interfaces/api/index.ts
Normal file
6
src/interfaces/api/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export * from './comment';
|
||||
export * from './community';
|
||||
export * from './post';
|
||||
export * from './site';
|
||||
export * from './user';
|
||||
export * from './websocket';
|
142
src/interfaces/api/post.ts
Normal file
142
src/interfaces/api/post.ts
Normal file
|
@ -0,0 +1,142 @@
|
|||
import {
|
||||
CommunityView,
|
||||
CommentView,
|
||||
CommunityModeratorView,
|
||||
PostReportView,
|
||||
PostView,
|
||||
} from '../views';
|
||||
|
||||
export interface CreatePost {
|
||||
name: string;
|
||||
url?: string;
|
||||
body?: string;
|
||||
nsfw: boolean;
|
||||
community_id: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PostResponse {
|
||||
post_view: PostView;
|
||||
}
|
||||
|
||||
export interface GetPost {
|
||||
id: number;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetPostResponse {
|
||||
post_view: PostView;
|
||||
community_view: CommunityView;
|
||||
comments: CommentView[];
|
||||
moderators: CommunityModeratorView[];
|
||||
online: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Post listing types are `All, Subscribed, Community`
|
||||
*
|
||||
* `community_name` can only be used for local communities. To get posts for a federated community, pass `community_id` instead.
|
||||
*/
|
||||
export interface GetPosts {
|
||||
type_: string;
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
community_name?: string;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetPostsResponse {
|
||||
posts: PostView[];
|
||||
}
|
||||
|
||||
/**
|
||||
* `score` can be 0, -1, or 1
|
||||
*/
|
||||
export interface CreatePostLike {
|
||||
post_id: number;
|
||||
score: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface EditPost {
|
||||
post_id: number;
|
||||
name: string;
|
||||
url?: string;
|
||||
body?: string;
|
||||
nsfw: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface DeletePost {
|
||||
post_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can remove a post.
|
||||
*/
|
||||
export interface RemovePost {
|
||||
post_id: number;
|
||||
removed: boolean;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can lock a post.
|
||||
*/
|
||||
export interface LockPost {
|
||||
post_id: number;
|
||||
locked: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can sticky a post.
|
||||
*/
|
||||
export interface StickyPost {
|
||||
post_id: number;
|
||||
stickied: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface SavePost {
|
||||
post_id: number;
|
||||
save: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface CreatePostReport {
|
||||
post_id: number;
|
||||
reason: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface CreatePostReportResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface ResolvePostReport {
|
||||
report_id: number;
|
||||
resolved: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ResolvePostReportResponse {
|
||||
report_id: number;
|
||||
resolved: boolean;
|
||||
}
|
||||
|
||||
export interface ListPostReports {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ListPostReportsResponse {
|
||||
posts: PostReportView[];
|
||||
}
|
122
src/interfaces/api/site.ts
Normal file
122
src/interfaces/api/site.ts
Normal file
|
@ -0,0 +1,122 @@
|
|||
import { Category, UserSafeSettings } from '../source';
|
||||
import {
|
||||
CommentView,
|
||||
CommunityView,
|
||||
ModAddCommunityView,
|
||||
ModAddView,
|
||||
ModBanFromCommunityView,
|
||||
ModBanView,
|
||||
ModLockPostView,
|
||||
ModRemoveCommentView,
|
||||
ModRemoveCommunityView,
|
||||
ModRemovePostView,
|
||||
ModStickyPostView,
|
||||
PostView,
|
||||
SiteView,
|
||||
UserViewSafe,
|
||||
} from '../views';
|
||||
|
||||
export interface ListCategories {}
|
||||
|
||||
export interface ListCategoriesResponse {
|
||||
categories: Category[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Search types are `All, Comments, Posts, Communities, Users, Url`
|
||||
*/
|
||||
export interface Search {
|
||||
q: string;
|
||||
type_: string;
|
||||
community_id?: number;
|
||||
community_name?: string;
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
type_: string;
|
||||
comments: CommentView[];
|
||||
posts: PostView[];
|
||||
communities: CommunityView[];
|
||||
users: UserViewSafe[];
|
||||
}
|
||||
|
||||
export interface GetModlog {
|
||||
mod_user_id?: number;
|
||||
community_id?: number;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface GetModlogResponse {
|
||||
removed_posts: ModRemovePostView[];
|
||||
locked_posts: ModLockPostView[];
|
||||
stickied_posts: ModStickyPostView[];
|
||||
removed_comments: ModRemoveCommentView[];
|
||||
removed_communities: ModRemoveCommunityView[];
|
||||
banned_from_community: ModBanFromCommunityView[];
|
||||
banned: ModBanView[];
|
||||
added_to_community: ModAddCommunityView[];
|
||||
added: ModAddView[];
|
||||
}
|
||||
|
||||
export interface CreateSite {
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface EditSite {
|
||||
name: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetSite {
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface SiteResponse {
|
||||
site_view: SiteView;
|
||||
}
|
||||
|
||||
export interface GetSiteResponse {
|
||||
site_view?: SiteView; // Because the site might not be set up y,
|
||||
admins: UserViewSafe[];
|
||||
banned: UserViewSafe[];
|
||||
online: number;
|
||||
version: string;
|
||||
my_user?: UserSafeSettings; // Gives back your user and settings if logged in
|
||||
federated_instances: string[];
|
||||
}
|
||||
|
||||
export interface TransferSite {
|
||||
user_id: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetSiteConfig {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetSiteConfigResponse {
|
||||
config_hjson: string;
|
||||
}
|
||||
|
||||
export interface SaveSiteConfig {
|
||||
config_hjson: string;
|
||||
auth: string;
|
||||
}
|
223
src/interfaces/api/user.ts
Normal file
223
src/interfaces/api/user.ts
Normal file
|
@ -0,0 +1,223 @@
|
|||
import {
|
||||
CommentView,
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
UserMentionView,
|
||||
UserViewSafe,
|
||||
} from '../views';
|
||||
|
||||
export interface Login {
|
||||
username_or_email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the first user will be able to be the admin.
|
||||
*/
|
||||
export interface Register {
|
||||
username: string;
|
||||
email?: string;
|
||||
password: string;
|
||||
password_verify: string;
|
||||
show_nsfw: boolean;
|
||||
captcha_uuid?: string; // Only checked if these are enabled in the server
|
||||
captcha_answer?: string;
|
||||
}
|
||||
|
||||
export interface GetCaptcha {}
|
||||
|
||||
export interface GetCaptchaResponse {
|
||||
ok?: CaptchaResponse; // Will be undefined if captchas are disabled
|
||||
}
|
||||
|
||||
export interface CaptchaResponse {
|
||||
png: string; // A Base64 encoded png
|
||||
wav?: string; // A Base64 encoded wav aud,
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
export interface SaveUserSettings {
|
||||
show_nsfw: boolean;
|
||||
theme: string; // Default 'default'
|
||||
default_sort_type: number; // The Sort types from above, zero indexed as a number
|
||||
default_listing_type: number; // Post listing types are `All, Subscribed, Community`
|
||||
lang: string;
|
||||
avatar?: string;
|
||||
banner?: string;
|
||||
preferred_username?: string;
|
||||
email?: string;
|
||||
bio?: string;
|
||||
matrix_user_id?: string;
|
||||
new_password?: string;
|
||||
new_password_verify?: string;
|
||||
old_password?: string;
|
||||
show_avatars: boolean;
|
||||
send_notifications_to_email: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
jwt: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* `username` can only be used for local users. To get details for a federated user, pass `user_id` instead.
|
||||
*/
|
||||
export interface GetUserDetails {
|
||||
user_id?: number;
|
||||
username?: string;
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
saved_only: boolean;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetUserDetailsResponse {
|
||||
user_view: UserViewSafe;
|
||||
follows: CommunityFollowerView[];
|
||||
moderates: CommunityModeratorView[];
|
||||
comments: CommentView[];
|
||||
posts: PostView[];
|
||||
}
|
||||
|
||||
export interface GetRepliesResponse {
|
||||
replies: CommentView[];
|
||||
}
|
||||
|
||||
export interface GetUserMentionsResponse {
|
||||
mentions: UserMentionView[];
|
||||
}
|
||||
|
||||
export interface MarkAllAsRead {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface AddAdmin {
|
||||
user_id: number;
|
||||
added: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface AddAdminResponse {
|
||||
admins: UserViewSafe[];
|
||||
}
|
||||
|
||||
export interface BanUser {
|
||||
user_id: number;
|
||||
ban: boolean;
|
||||
remove_data: boolean; // Removes/Restores their comments, posts, and communities
|
||||
reason?: string;
|
||||
expires?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface BanUserResponse {
|
||||
user_view: UserViewSafe;
|
||||
banned: boolean;
|
||||
}
|
||||
|
||||
export interface GetReplies {
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
unread_only: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetUserMentions {
|
||||
sort: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
unread_only: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface MarkUserMentionAsRead {
|
||||
user_mention_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface UserMentionResponse {
|
||||
user_mention_view: UserMentionView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes your posts and comments
|
||||
*/
|
||||
export interface DeleteAccount {
|
||||
password: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PasswordReset {
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface PasswordResetResponse {}
|
||||
|
||||
export interface PasswordChange {
|
||||
token: string;
|
||||
password: string;
|
||||
password_verify: string;
|
||||
}
|
||||
|
||||
export interface CreatePrivateMessage {
|
||||
content: string;
|
||||
recipient_id: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface EditPrivateMessage {
|
||||
private_message_id: number;
|
||||
content: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface DeletePrivateMessage {
|
||||
private_message_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface MarkPrivateMessageAsRead {
|
||||
private_message_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetPrivateMessages {
|
||||
unread_only: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PrivateMessagesResponse {
|
||||
private_messages: PrivateMessageView[];
|
||||
}
|
||||
|
||||
export interface PrivateMessageResponse {
|
||||
private_message_view: PrivateMessageView;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
|
||||
*/
|
||||
export interface GetReportCount {
|
||||
community?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetReportCountResponse {
|
||||
community?: number;
|
||||
comment_reports: number;
|
||||
post_reports: number;
|
||||
}
|
34
src/interfaces/api/websocket.ts
Normal file
34
src/interfaces/api/websocket.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
export interface UserJoin {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface UserJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main / frontpage community is `community_id: 0`.
|
||||
*/
|
||||
export interface CommunityJoin {
|
||||
community_id: number;
|
||||
}
|
||||
|
||||
export interface CommunityJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
||||
|
||||
export interface ModJoin {
|
||||
community_id: number;
|
||||
}
|
||||
|
||||
export interface ModJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
||||
|
||||
export interface PostJoin {
|
||||
post_id: number;
|
||||
}
|
||||
|
||||
export interface PostJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
5
src/interfaces/index.ts
Normal file
5
src/interfaces/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export * from './api';
|
||||
export * from './aggregates';
|
||||
export * from './others';
|
||||
export * from './source';
|
||||
export * from './views';
|
101
src/interfaces/others.ts
Normal file
101
src/interfaces/others.ts
Normal file
|
@ -0,0 +1,101 @@
|
|||
export enum UserOperation {
|
||||
Login,
|
||||
Register,
|
||||
GetCaptcha,
|
||||
CreateCommunity,
|
||||
CreatePost,
|
||||
ListCommunities,
|
||||
ListCategories,
|
||||
GetPost,
|
||||
GetCommunity,
|
||||
CreateComment,
|
||||
EditComment,
|
||||
DeleteComment,
|
||||
RemoveComment,
|
||||
MarkCommentAsRead,
|
||||
SaveComment,
|
||||
CreateCommentLike,
|
||||
GetPosts,
|
||||
CreatePostLike,
|
||||
EditPost,
|
||||
DeletePost,
|
||||
RemovePost,
|
||||
LockPost,
|
||||
StickyPost,
|
||||
SavePost,
|
||||
EditCommunity,
|
||||
DeleteCommunity,
|
||||
RemoveCommunity,
|
||||
FollowCommunity,
|
||||
GetFollowedCommunities,
|
||||
GetUserDetails,
|
||||
GetReplies,
|
||||
GetUserMentions,
|
||||
MarkUserMentionAsRead,
|
||||
GetModlog,
|
||||
BanFromCommunity,
|
||||
AddModToCommunity,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetSite,
|
||||
AddAdmin,
|
||||
BanUser,
|
||||
Search,
|
||||
MarkAllAsRead,
|
||||
SaveUserSettings,
|
||||
TransferCommunity,
|
||||
TransferSite,
|
||||
DeleteAccount,
|
||||
PasswordReset,
|
||||
PasswordChange,
|
||||
CreatePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
DeletePrivateMessage,
|
||||
MarkPrivateMessageAsRead,
|
||||
GetPrivateMessages,
|
||||
UserJoin,
|
||||
GetComments,
|
||||
GetSiteConfig,
|
||||
SaveSiteConfig,
|
||||
PostJoin,
|
||||
CommunityJoin,
|
||||
}
|
||||
|
||||
export enum SortType {
|
||||
Active = 'Active',
|
||||
Hot = 'Hot',
|
||||
New = 'New',
|
||||
TopDay = 'TopDay',
|
||||
TopWeek = 'TopWeek',
|
||||
TopMonth = 'TopMonth',
|
||||
TopYear = 'TopYear',
|
||||
TopAll = 'TopAll',
|
||||
}
|
||||
|
||||
export enum ListingType {
|
||||
All = 'All',
|
||||
Local = 'Local',
|
||||
Subscribed = 'Subscribed',
|
||||
Community = 'Community',
|
||||
}
|
||||
|
||||
export enum SearchType {
|
||||
All = 'All',
|
||||
Comments = 'Comments',
|
||||
Posts = 'Posts',
|
||||
Communities = 'Communities',
|
||||
Users = 'Users',
|
||||
Url = 'Url',
|
||||
}
|
||||
|
||||
export interface WebSocketResponse<ResponseType> {
|
||||
op: UserOperation;
|
||||
data: ResponseType;
|
||||
}
|
||||
|
||||
export interface WebSocketJsonResponse<ResponseType> {
|
||||
op?: string;
|
||||
data?: ResponseType;
|
||||
error?: string;
|
||||
reconnect?: boolean;
|
||||
}
|
254
src/interfaces/source.ts
Normal file
254
src/interfaces/source.ts
Normal file
|
@ -0,0 +1,254 @@
|
|||
import { ListingType, SortType } from './others';
|
||||
|
||||
export interface UserSafe {
|
||||
id: number;
|
||||
name: string;
|
||||
preferred_username?: string;
|
||||
avatar?: string;
|
||||
admin: boolean;
|
||||
banned: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
matrix_user_id?: string;
|
||||
actor_id: string;
|
||||
bio?: string;
|
||||
local: boolean;
|
||||
banner?: string;
|
||||
deleted: boolean;
|
||||
}
|
||||
|
||||
export interface UserSafeSettings {
|
||||
id: number;
|
||||
name: string;
|
||||
preferred_username?: string;
|
||||
email?: string;
|
||||
avatar?: string;
|
||||
admin: boolean;
|
||||
banned: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
show_nsfw: boolean;
|
||||
theme: string;
|
||||
default_sort_type: number;
|
||||
default_listing_type: number;
|
||||
lang: string;
|
||||
show_avatars: boolean;
|
||||
send_notifications_to_email: boolean;
|
||||
matrix_user_id?: string;
|
||||
actor_id: string;
|
||||
bio?: string;
|
||||
local: boolean;
|
||||
last_refreshed_at: string;
|
||||
banner?: string;
|
||||
deleted: boolean;
|
||||
}
|
||||
|
||||
export interface Site {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
creator_id: number;
|
||||
published: string;
|
||||
updated?: string;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
}
|
||||
|
||||
export interface PrivateMessage {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
recipient_id: number;
|
||||
content: string;
|
||||
deleted: boolean;
|
||||
read: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
ap_id: string;
|
||||
local: boolean;
|
||||
}
|
||||
|
||||
export interface PostReport {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
post_id: number;
|
||||
original_post_name: string;
|
||||
original_post_url?: string;
|
||||
original_post_body?: string;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
resolver_id?: number;
|
||||
published: string;
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
export interface Post {
|
||||
id: number;
|
||||
name: string;
|
||||
url?: string;
|
||||
body?: string;
|
||||
creator_id: number;
|
||||
community_id: number;
|
||||
removed: boolean;
|
||||
locked: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
deleted: boolean;
|
||||
nsfw: boolean;
|
||||
stickied: boolean;
|
||||
embed_title?: string;
|
||||
embed_description?: string;
|
||||
embed_html?: string;
|
||||
thumbnail_url?: string;
|
||||
ap_id: string;
|
||||
local: boolean;
|
||||
}
|
||||
|
||||
export interface PasswordResetRequest {
|
||||
id: number;
|
||||
user_id: number;
|
||||
token_encrypted: string;
|
||||
published: string;
|
||||
}
|
||||
|
||||
export interface ModRemovePost {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
post_id: number;
|
||||
reason?: string;
|
||||
removed?: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModLockPost {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
post_id: number;
|
||||
locked?: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModStickyPost {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
post_id: number;
|
||||
stickied?: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModRemoveComment {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
comment_id: number;
|
||||
reason?: string;
|
||||
removed?: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModRemoveCommunity {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
community_id: number;
|
||||
reason?: string;
|
||||
removed?: boolean;
|
||||
expires?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModBanFromCommunity {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
other_user_id: number;
|
||||
community_id: number;
|
||||
reason?: string;
|
||||
banned?: boolean;
|
||||
expires?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModBan {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
other_user_id: number;
|
||||
reason?: string;
|
||||
banned?: boolean;
|
||||
expires?: string;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModAddCommunity {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
other_user_id: number;
|
||||
community_id: number;
|
||||
removed?: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModAdd {
|
||||
id: number;
|
||||
mod_user_id: number;
|
||||
other_user_id: number;
|
||||
removed?: boolean;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface CommunitySafe {
|
||||
id: number;
|
||||
name: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
category_id: number;
|
||||
creator_id: number;
|
||||
removed: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
deleted: boolean;
|
||||
nsfw: boolean;
|
||||
actor_id: string;
|
||||
local: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
}
|
||||
|
||||
export interface CommentReport {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
comment_id: number;
|
||||
original_comment_text: string;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
resolver_id?: number;
|
||||
published: string;
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
post_id: number;
|
||||
parent_id?: number;
|
||||
content: string;
|
||||
removed: boolean;
|
||||
read: boolean; // Whether the recipient has read the comment or not
|
||||
published: string;
|
||||
updated?: string;
|
||||
deleted: boolean;
|
||||
ap_id: string;
|
||||
local: boolean;
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface UserMention {
|
||||
id: number;
|
||||
recipient_id: number;
|
||||
comment_id: number;
|
||||
read: boolean;
|
||||
published: string;
|
||||
}
|
188
src/interfaces/views.ts
Normal file
188
src/interfaces/views.ts
Normal file
|
@ -0,0 +1,188 @@
|
|||
import {
|
||||
CommentAggregates,
|
||||
CommunityAggregates,
|
||||
PostAggregates,
|
||||
SiteAggregates,
|
||||
UserAggregates,
|
||||
} from './aggregates';
|
||||
import {
|
||||
Category,
|
||||
Comment,
|
||||
CommentReport,
|
||||
CommunitySafe,
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModBan,
|
||||
ModBanFromCommunity,
|
||||
ModLockPost,
|
||||
ModRemoveComment,
|
||||
ModRemoveCommunity,
|
||||
ModRemovePost,
|
||||
ModStickyPost,
|
||||
Post,
|
||||
PostReport,
|
||||
PrivateMessage,
|
||||
Site,
|
||||
UserMention,
|
||||
UserSafe,
|
||||
} from './source';
|
||||
|
||||
export interface UserViewSafe {
|
||||
user: UserSafe;
|
||||
counts: UserAggregates;
|
||||
}
|
||||
|
||||
export interface UserMentionView {
|
||||
user_mention: UserMention;
|
||||
comment: Comment;
|
||||
creator: UserSafe;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
recipient: UserSafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
my_vote?: number;
|
||||
}
|
||||
|
||||
export interface SiteView {
|
||||
site: Site;
|
||||
creator: UserSafe;
|
||||
counts: SiteAggregates;
|
||||
}
|
||||
|
||||
export interface PrivateMessageView {
|
||||
private_message: PrivateMessage;
|
||||
creator: UserSafe;
|
||||
recipient: UserSafe;
|
||||
}
|
||||
|
||||
export interface PostView {
|
||||
post: Post;
|
||||
creator: UserSafe;
|
||||
community: CommunitySafe;
|
||||
creator_banned_from_community: boolean;
|
||||
counts: PostAggregates;
|
||||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
read: boolean;
|
||||
my_vote?: number;
|
||||
}
|
||||
|
||||
export interface PostReportView {
|
||||
post_report: PostReport;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
creator: UserSafe;
|
||||
post_creator: UserSafe;
|
||||
resolver?: UserSafe;
|
||||
}
|
||||
|
||||
export interface CommentView {
|
||||
comment: Comment;
|
||||
creator: UserSafe;
|
||||
recipient?: UserSafe;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
my_vote?: number;
|
||||
}
|
||||
|
||||
export interface CommentReportView {
|
||||
comment_report: CommentReport;
|
||||
comment: Comment;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
creator: UserSafe;
|
||||
comment_creator: UserSafe;
|
||||
resolver?: UserSafe;
|
||||
}
|
||||
|
||||
export interface ModAddCommunityView {
|
||||
mod_add_community: ModAddCommunity;
|
||||
moderator: UserSafe;
|
||||
community: CommunitySafe;
|
||||
modded_user: UserSafe;
|
||||
}
|
||||
|
||||
export interface ModAddView {
|
||||
mod_add: ModAdd;
|
||||
moderator: UserSafe;
|
||||
modded_user: UserSafe;
|
||||
}
|
||||
|
||||
export interface ModBanFromCommunityView {
|
||||
mod_ban_from_community: ModBanFromCommunity;
|
||||
moderator: UserSafe;
|
||||
community: CommunitySafe;
|
||||
banned_user: UserSafe;
|
||||
}
|
||||
|
||||
export interface ModBanView {
|
||||
mod_ban: ModBan;
|
||||
moderator: UserSafe;
|
||||
banned_user: UserSafe;
|
||||
}
|
||||
|
||||
export interface ModLockPostView {
|
||||
mod_lock_post: ModLockPost;
|
||||
moderator: UserSafe;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModRemoveCommentView {
|
||||
mod_remove_comment: ModRemoveComment;
|
||||
moderator: UserSafe;
|
||||
comment: Comment;
|
||||
commenter: UserSafe;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModRemoveCommunityView {
|
||||
mod_remove_community: ModRemoveCommunity;
|
||||
moderator: UserSafe;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModRemovePostView {
|
||||
mod_remove_post: ModRemovePost;
|
||||
moderator: UserSafe;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModStickyPostView {
|
||||
mod_sticky_post: ModStickyPost;
|
||||
moderator: UserSafe;
|
||||
post: Post;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface CommunityFollowerView {
|
||||
community: CommunitySafe;
|
||||
follower: UserSafe;
|
||||
}
|
||||
|
||||
export interface CommunityModeratorView {
|
||||
community: CommunitySafe;
|
||||
moderator: UserSafe;
|
||||
}
|
||||
|
||||
export interface CommunityUserBanView {
|
||||
community: CommunitySafe;
|
||||
user: UserSafe;
|
||||
}
|
||||
|
||||
export interface CommunityView {
|
||||
community: CommunitySafe;
|
||||
creator: UserSafe;
|
||||
category: Category;
|
||||
subscribed: boolean;
|
||||
counts: CommunityAggregates;
|
||||
}
|
239
src/websocket.ts
239
src/websocket.ts
|
@ -1,114 +1,123 @@
|
|||
import {
|
||||
MessageType,
|
||||
LoginForm,
|
||||
RegisterForm,
|
||||
UserOperation,
|
||||
CommunityForm,
|
||||
DeleteCommunityForm,
|
||||
RemoveCommunityForm,
|
||||
PostForm,
|
||||
DeletePostForm,
|
||||
RemovePostForm,
|
||||
LockPostForm,
|
||||
StickyPostForm,
|
||||
SavePostForm,
|
||||
CommentForm,
|
||||
DeleteCommentForm,
|
||||
RemoveCommentForm,
|
||||
MarkCommentAsReadForm,
|
||||
SaveCommentForm,
|
||||
CommentLikeForm,
|
||||
GetPostForm,
|
||||
GetPostsForm,
|
||||
CreatePostLikeForm,
|
||||
GetCommunityForm,
|
||||
FollowCommunityForm,
|
||||
GetFollowedCommunitiesForm,
|
||||
GetUserDetailsForm,
|
||||
ListCommunitiesForm,
|
||||
GetModlogForm,
|
||||
BanFromCommunityForm,
|
||||
AddModToCommunityForm,
|
||||
TransferCommunityForm,
|
||||
AddAdminForm,
|
||||
TransferSiteForm,
|
||||
BanUserForm,
|
||||
SiteForm,
|
||||
GetRepliesForm,
|
||||
GetUserMentionsForm,
|
||||
MarkUserMentionAsReadForm,
|
||||
SearchForm,
|
||||
UserSettingsForm,
|
||||
DeleteAccountForm,
|
||||
PasswordResetForm,
|
||||
PasswordChangeForm,
|
||||
PrivateMessageForm,
|
||||
EditPrivateMessageForm,
|
||||
DeletePrivateMessageForm,
|
||||
MarkPrivateMessageAsReadForm,
|
||||
GetPrivateMessagesForm,
|
||||
GetCommentsForm,
|
||||
UserJoinForm,
|
||||
CreateComment,
|
||||
CreateCommentLike,
|
||||
DeleteComment,
|
||||
EditComment,
|
||||
GetComments,
|
||||
MarkCommentAsRead,
|
||||
RemoveComment,
|
||||
SaveComment,
|
||||
} from './interfaces/api/comment';
|
||||
import {
|
||||
AddModToCommunity,
|
||||
BanFromCommunity,
|
||||
CreateCommunity,
|
||||
DeleteCommunity,
|
||||
EditCommunity,
|
||||
FollowCommunity,
|
||||
GetCommunity,
|
||||
GetFollowedCommunities,
|
||||
ListCommunities,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from './interfaces/api/community';
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
DeletePost,
|
||||
EditPost,
|
||||
GetPost,
|
||||
GetPosts,
|
||||
LockPost,
|
||||
RemovePost,
|
||||
SavePost,
|
||||
StickyPost,
|
||||
} from './interfaces/api/post';
|
||||
import {
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
GetSite,
|
||||
GetSiteConfig,
|
||||
GetSiteForm,
|
||||
SiteConfigForm,
|
||||
MarkAllAsReadForm,
|
||||
PostJoinForm,
|
||||
CommunityJoinForm,
|
||||
} from './interfaces';
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
TransferSite,
|
||||
} from './interfaces/api/site';
|
||||
import {
|
||||
AddAdmin,
|
||||
BanUser,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetUserDetails,
|
||||
GetUserMentions,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
MarkUserMentionAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
} from './interfaces/api/user';
|
||||
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
||||
import { UserOperation } from './interfaces/others';
|
||||
|
||||
export class LemmyWebsocket {
|
||||
constructor() {}
|
||||
|
||||
login(form: LoginForm): string {
|
||||
login(form: Login): string {
|
||||
return wrapper(UserOperation.Login, form);
|
||||
}
|
||||
|
||||
userJoin(form: UserJoinForm): string {
|
||||
userJoin(form: UserJoin): string {
|
||||
return wrapper(UserOperation.UserJoin, form);
|
||||
}
|
||||
|
||||
postJoin(form: PostJoinForm): string {
|
||||
postJoin(form: PostJoin): string {
|
||||
return wrapper(UserOperation.PostJoin, form);
|
||||
}
|
||||
|
||||
communityJoin(form: CommunityJoinForm): string {
|
||||
communityJoin(form: CommunityJoin): string {
|
||||
return wrapper(UserOperation.CommunityJoin, form);
|
||||
}
|
||||
|
||||
register(registerForm: RegisterForm) {
|
||||
return wrapper(UserOperation.Register, registerForm);
|
||||
register(register: Register) {
|
||||
return wrapper(UserOperation.Register, register);
|
||||
}
|
||||
|
||||
getCaptcha() {
|
||||
return wrapper(UserOperation.GetCaptcha, {});
|
||||
}
|
||||
|
||||
createCommunity(form: CommunityForm) {
|
||||
createCommunity(form: CreateCommunity) {
|
||||
return wrapper(UserOperation.CreateCommunity, form);
|
||||
}
|
||||
|
||||
editCommunity(form: CommunityForm) {
|
||||
editCommunity(form: EditCommunity) {
|
||||
return wrapper(UserOperation.EditCommunity, form);
|
||||
}
|
||||
|
||||
deleteCommunity(form: DeleteCommunityForm) {
|
||||
deleteCommunity(form: DeleteCommunity) {
|
||||
return wrapper(UserOperation.DeleteCommunity, form);
|
||||
}
|
||||
|
||||
removeCommunity(form: RemoveCommunityForm) {
|
||||
removeCommunity(form: RemoveCommunity) {
|
||||
return wrapper(UserOperation.RemoveCommunity, form);
|
||||
}
|
||||
|
||||
followCommunity(form: FollowCommunityForm) {
|
||||
followCommunity(form: FollowCommunity) {
|
||||
return wrapper(UserOperation.FollowCommunity, form);
|
||||
}
|
||||
|
||||
listCommunities(form: ListCommunitiesForm) {
|
||||
listCommunities(form: ListCommunities) {
|
||||
return wrapper(UserOperation.ListCommunities, form);
|
||||
}
|
||||
|
||||
getFollowedCommunities(form: GetFollowedCommunitiesForm) {
|
||||
getFollowedCommunities(form: GetFollowedCommunities) {
|
||||
return wrapper(UserOperation.GetFollowedCommunities, form);
|
||||
}
|
||||
|
||||
|
@ -116,135 +125,135 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.ListCategories, {});
|
||||
}
|
||||
|
||||
createPost(form: PostForm) {
|
||||
createPost(form: CreatePost) {
|
||||
return wrapper(UserOperation.CreatePost, form);
|
||||
}
|
||||
|
||||
getPost(form: GetPostForm) {
|
||||
getPost(form: GetPost) {
|
||||
return wrapper(UserOperation.GetPost, form);
|
||||
}
|
||||
|
||||
getCommunity(form: GetCommunityForm) {
|
||||
getCommunity(form: GetCommunity) {
|
||||
return wrapper(UserOperation.GetCommunity, form);
|
||||
}
|
||||
|
||||
createComment(form: CommentForm) {
|
||||
createComment(form: CreateComment) {
|
||||
return wrapper(UserOperation.CreateComment, form);
|
||||
}
|
||||
|
||||
editComment(form: CommentForm) {
|
||||
editComment(form: EditComment) {
|
||||
return wrapper(UserOperation.EditComment, form);
|
||||
}
|
||||
|
||||
deleteComment(form: DeleteCommentForm) {
|
||||
deleteComment(form: DeleteComment) {
|
||||
return wrapper(UserOperation.DeleteComment, form);
|
||||
}
|
||||
|
||||
removeComment(form: RemoveCommentForm) {
|
||||
removeComment(form: RemoveComment) {
|
||||
return wrapper(UserOperation.RemoveComment, form);
|
||||
}
|
||||
|
||||
markCommentAsRead(form: MarkCommentAsReadForm) {
|
||||
markCommentAsRead(form: MarkCommentAsRead) {
|
||||
return wrapper(UserOperation.MarkCommentAsRead, form);
|
||||
}
|
||||
|
||||
likeComment(form: CommentLikeForm) {
|
||||
likeComment(form: CreateCommentLike) {
|
||||
return wrapper(UserOperation.CreateCommentLike, form);
|
||||
}
|
||||
|
||||
saveComment(form: SaveCommentForm) {
|
||||
saveComment(form: SaveComment) {
|
||||
return wrapper(UserOperation.SaveComment, form);
|
||||
}
|
||||
|
||||
getPosts(form: GetPostsForm) {
|
||||
getPosts(form: GetPosts) {
|
||||
return wrapper(UserOperation.GetPosts, form);
|
||||
}
|
||||
|
||||
getComments(form: GetCommentsForm) {
|
||||
getComments(form: GetComments) {
|
||||
return wrapper(UserOperation.GetComments, form);
|
||||
}
|
||||
|
||||
likePost(form: CreatePostLikeForm) {
|
||||
likePost(form: CreatePostLike) {
|
||||
return wrapper(UserOperation.CreatePostLike, form);
|
||||
}
|
||||
|
||||
editPost(form: PostForm) {
|
||||
editPost(form: EditPost) {
|
||||
return wrapper(UserOperation.EditPost, form);
|
||||
}
|
||||
|
||||
deletePost(form: DeletePostForm) {
|
||||
deletePost(form: DeletePost) {
|
||||
return wrapper(UserOperation.DeletePost, form);
|
||||
}
|
||||
|
||||
removePost(form: RemovePostForm) {
|
||||
removePost(form: RemovePost) {
|
||||
return wrapper(UserOperation.RemovePost, form);
|
||||
}
|
||||
|
||||
lockPost(form: LockPostForm) {
|
||||
lockPost(form: LockPost) {
|
||||
return wrapper(UserOperation.LockPost, form);
|
||||
}
|
||||
|
||||
stickyPost(form: StickyPostForm) {
|
||||
stickyPost(form: StickyPost) {
|
||||
return wrapper(UserOperation.StickyPost, form);
|
||||
}
|
||||
|
||||
savePost(form: SavePostForm) {
|
||||
savePost(form: SavePost) {
|
||||
return wrapper(UserOperation.SavePost, form);
|
||||
}
|
||||
|
||||
banFromCommunity(form: BanFromCommunityForm) {
|
||||
banFromCommunity(form: BanFromCommunity) {
|
||||
return wrapper(UserOperation.BanFromCommunity, form);
|
||||
}
|
||||
|
||||
addModToCommunity(form: AddModToCommunityForm) {
|
||||
addModToCommunity(form: AddModToCommunity) {
|
||||
return wrapper(UserOperation.AddModToCommunity, form);
|
||||
}
|
||||
|
||||
transferCommunity(form: TransferCommunityForm) {
|
||||
transferCommunity(form: TransferCommunity) {
|
||||
return wrapper(UserOperation.TransferCommunity, form);
|
||||
}
|
||||
|
||||
transferSite(form: TransferSiteForm) {
|
||||
transferSite(form: TransferSite) {
|
||||
return wrapper(UserOperation.TransferSite, form);
|
||||
}
|
||||
|
||||
banUser(form: BanUserForm) {
|
||||
banUser(form: BanUser) {
|
||||
return wrapper(UserOperation.BanUser, form);
|
||||
}
|
||||
|
||||
addAdmin(form: AddAdminForm) {
|
||||
addAdmin(form: AddAdmin) {
|
||||
return wrapper(UserOperation.AddAdmin, form);
|
||||
}
|
||||
|
||||
getUserDetails(form: GetUserDetailsForm) {
|
||||
getUserDetails(form: GetUserDetails) {
|
||||
return wrapper(UserOperation.GetUserDetails, form);
|
||||
}
|
||||
|
||||
getReplies(form: GetRepliesForm) {
|
||||
getReplies(form: GetReplies) {
|
||||
return wrapper(UserOperation.GetReplies, form);
|
||||
}
|
||||
|
||||
getUserMentions(form: GetUserMentionsForm) {
|
||||
getUserMentions(form: GetUserMentions) {
|
||||
return wrapper(UserOperation.GetUserMentions, form);
|
||||
}
|
||||
|
||||
markUserMentionAsRead(form: MarkUserMentionAsReadForm) {
|
||||
markUserMentionAsRead(form: MarkUserMentionAsRead) {
|
||||
return wrapper(UserOperation.MarkUserMentionAsRead, form);
|
||||
}
|
||||
|
||||
getModlog(form: GetModlogForm) {
|
||||
getModlog(form: GetModlog) {
|
||||
return wrapper(UserOperation.GetModlog, form);
|
||||
}
|
||||
|
||||
createSite(form: SiteForm) {
|
||||
createSite(form: CreateSite) {
|
||||
return wrapper(UserOperation.CreateSite, form);
|
||||
}
|
||||
|
||||
editSite(form: SiteForm) {
|
||||
editSite(form: EditSite) {
|
||||
return wrapper(UserOperation.EditSite, form);
|
||||
}
|
||||
|
||||
getSite(form: GetSiteForm = {}) {
|
||||
getSite(form: GetSite = {}) {
|
||||
return wrapper(UserOperation.GetSite, form);
|
||||
}
|
||||
|
||||
|
@ -252,56 +261,56 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.GetSiteConfig, form);
|
||||
}
|
||||
|
||||
search(form: SearchForm) {
|
||||
search(form: Search) {
|
||||
return wrapper(UserOperation.Search, form);
|
||||
}
|
||||
|
||||
markAllAsRead(form: MarkAllAsReadForm) {
|
||||
markAllAsRead(form: MarkAllAsRead) {
|
||||
return wrapper(UserOperation.MarkAllAsRead, form);
|
||||
}
|
||||
|
||||
saveUserSettings(form: UserSettingsForm) {
|
||||
saveUserSettings(form: SaveUserSettings) {
|
||||
return wrapper(UserOperation.SaveUserSettings, form);
|
||||
}
|
||||
|
||||
deleteAccount(form: DeleteAccountForm) {
|
||||
deleteAccount(form: DeleteAccount) {
|
||||
return wrapper(UserOperation.DeleteAccount, form);
|
||||
}
|
||||
|
||||
passwordReset(form: PasswordResetForm) {
|
||||
passwordReset(form: PasswordReset) {
|
||||
return wrapper(UserOperation.PasswordReset, form);
|
||||
}
|
||||
|
||||
passwordChange(form: PasswordChangeForm) {
|
||||
passwordChange(form: PasswordChange) {
|
||||
return wrapper(UserOperation.PasswordChange, form);
|
||||
}
|
||||
|
||||
createPrivateMessage(form: PrivateMessageForm) {
|
||||
createPrivateMessage(form: CreatePrivateMessage) {
|
||||
return wrapper(UserOperation.CreatePrivateMessage, form);
|
||||
}
|
||||
|
||||
editPrivateMessage(form: EditPrivateMessageForm) {
|
||||
editPrivateMessage(form: EditPrivateMessage) {
|
||||
return wrapper(UserOperation.EditPrivateMessage, form);
|
||||
}
|
||||
|
||||
deletePrivateMessage(form: DeletePrivateMessageForm) {
|
||||
deletePrivateMessage(form: DeletePrivateMessage) {
|
||||
return wrapper(UserOperation.DeletePrivateMessage, form);
|
||||
}
|
||||
|
||||
markPrivateMessageAsRead(form: MarkPrivateMessageAsReadForm) {
|
||||
markPrivateMessageAsRead(form: MarkPrivateMessageAsRead) {
|
||||
return wrapper(UserOperation.MarkPrivateMessageAsRead, form);
|
||||
}
|
||||
|
||||
getPrivateMessages(form: GetPrivateMessagesForm) {
|
||||
getPrivateMessages(form: GetPrivateMessages) {
|
||||
return wrapper(UserOperation.GetPrivateMessages, form);
|
||||
}
|
||||
|
||||
saveSiteConfig(form: SiteConfigForm) {
|
||||
saveSiteConfig(form: SaveSiteConfig) {
|
||||
return wrapper(UserOperation.SaveSiteConfig, form);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapper(op: UserOperation, data: MessageType) {
|
||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||
let send = { op: UserOperation[op], data: data };
|
||||
console.log(send);
|
||||
return JSON.stringify(send);
|
||||
|
|
Loading…
Reference in a new issue