mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-26 06:11:14 +00:00
Initial commit of API v2
This commit is contained in:
parent
ce29b6cdf4
commit
2f777a91fd
13 changed files with 1612 additions and 1529 deletions
294
src/http.ts
294
src/http.ts
|
@ -1,92 +1,104 @@
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import {
|
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,
|
CommentResponse,
|
||||||
CommunityResponse,
|
CreateComment,
|
||||||
GetRepliesResponse,
|
CreateCommentLike,
|
||||||
BanUserResponse,
|
DeleteComment,
|
||||||
GetPostResponse,
|
EditComment,
|
||||||
AddAdminResponse,
|
GetComments,
|
||||||
GetPostsResponse,
|
|
||||||
UserJoinResponse,
|
|
||||||
GetCaptchaResponse,
|
|
||||||
GetCommentsResponse,
|
GetCommentsResponse,
|
||||||
UserDetailsResponse,
|
MarkCommentAsRead,
|
||||||
UserMentionResponse,
|
RemoveComment,
|
||||||
GetUserMentionsResponse,
|
SaveComment,
|
||||||
GetCommunityResponse,
|
} from './interfaces/api/comment';
|
||||||
PrivateMessageResponse,
|
import {
|
||||||
ListCommunitiesResponse,
|
AddModToCommunity,
|
||||||
PrivateMessagesResponse,
|
|
||||||
BanFromCommunityResponse,
|
|
||||||
AddModToCommunityResponse,
|
AddModToCommunityResponse,
|
||||||
GetFollowedCommunitiesResponse,
|
BanFromCommunity,
|
||||||
PasswordResetResponse,
|
BanFromCommunityResponse,
|
||||||
PostJoinForm,
|
CommunityJoin,
|
||||||
PostJoinResponse,
|
|
||||||
CommunityJoinForm,
|
|
||||||
CommunityJoinResponse,
|
CommunityJoinResponse,
|
||||||
} from './interfaces';
|
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,
|
||||||
|
PostJoin,
|
||||||
|
PostJoinResponse,
|
||||||
|
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,
|
||||||
|
PrivateMessageResponse,
|
||||||
|
PrivateMessagesResponse,
|
||||||
|
Register,
|
||||||
|
SaveUserSettings,
|
||||||
|
UserJoin,
|
||||||
|
UserJoinResponse,
|
||||||
|
UserMentionResponse,
|
||||||
|
} from './interfaces/api/user';
|
||||||
|
import { MessageType } from './interfaces/others';
|
||||||
|
|
||||||
enum HttpType {
|
enum HttpType {
|
||||||
Get = 'GET',
|
Get = 'GET',
|
||||||
|
@ -106,19 +118,19 @@ export class LemmyHttp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSite(form: GetSiteForm): Promise<GetSiteResponse> {
|
async getSite(form: GetSite): Promise<GetSiteResponse> {
|
||||||
return this.wrapper(HttpType.Get, '/site', form);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Post, '/site/transfer', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +138,7 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Get, '/site/config', form);
|
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);
|
return this.wrapper(HttpType.Put, '/site/config', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,213 +146,211 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Get, '/categories', {});
|
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);
|
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);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Put, '/community', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async listCommunities(
|
async listCommunities(
|
||||||
form: ListCommunitiesForm
|
form: ListCommunities
|
||||||
): Promise<ListCommunitiesResponse> {
|
): Promise<ListCommunitiesResponse> {
|
||||||
return this.wrapper(HttpType.Get, '/community/list', form);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Post, '/community/remove', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async transferCommunity(
|
async transferCommunity(
|
||||||
form: TransferCommunityForm
|
form: TransferCommunity
|
||||||
): Promise<GetCommunityResponse> {
|
): Promise<GetCommunityResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/community/transfer', form);
|
return this.wrapper(HttpType.Post, '/community/transfer', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async banFromCommunity(
|
async banFromCommunity(
|
||||||
form: BanFromCommunityForm
|
form: BanFromCommunity
|
||||||
): Promise<BanFromCommunityResponse> {
|
): Promise<BanFromCommunityResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/community/ban_user', form);
|
return this.wrapper(HttpType.Post, '/community/ban_user', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addModToCommunity(
|
async addModToCommunity(
|
||||||
form: AddModToCommunityForm
|
form: AddModToCommunity
|
||||||
): Promise<AddModToCommunityResponse> {
|
): Promise<AddModToCommunityResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/community/mod', form);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Post, '/comment/remove', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async markCommentAsRead(
|
async markCommentAsRead(form: MarkCommentAsRead): Promise<CommentResponse> {
|
||||||
form: MarkCommentAsReadForm
|
|
||||||
): Promise<CommentResponse> {
|
|
||||||
return this.wrapper(HttpType.Post, '/comment/mark_as_read', form);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Get, '/comment/list', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPrivateMessages(
|
async getPrivateMessages(
|
||||||
form: GetPrivateMessagesForm
|
form: GetPrivateMessages
|
||||||
): Promise<PrivateMessagesResponse> {
|
): Promise<PrivateMessagesResponse> {
|
||||||
return this.wrapper(HttpType.Get, '/private_message/list', form);
|
return this.wrapper(HttpType.Get, '/private_message/list', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createPrivateMessage(
|
async createPrivateMessage(
|
||||||
form: PrivateMessageForm
|
form: CreatePrivateMessage
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/private_message', form);
|
return this.wrapper(HttpType.Post, '/private_message', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editPrivateMessage(
|
async editPrivateMessage(
|
||||||
form: EditPrivateMessageForm
|
form: EditPrivateMessage
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
return this.wrapper(HttpType.Put, '/private_message', form);
|
return this.wrapper(HttpType.Put, '/private_message', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async deletePrivateMessage(
|
async deletePrivateMessage(
|
||||||
form: DeletePrivateMessageForm
|
form: DeletePrivateMessage
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/private_message/delete', form);
|
return this.wrapper(HttpType.Post, '/private_message/delete', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async markPrivateMessageAsRead(
|
async markPrivateMessageAsRead(
|
||||||
form: MarkPrivateMessageAsReadForm
|
form: MarkPrivateMessageAsRead
|
||||||
): Promise<PrivateMessageResponse> {
|
): Promise<PrivateMessageResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/private_message/mark_as_read', form);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Get, '/user', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserMentions(
|
async getUserMentions(
|
||||||
form: GetUserMentionsForm
|
form: GetUserMentions
|
||||||
): Promise<GetUserMentionsResponse> {
|
): Promise<GetUserMentionsResponse> {
|
||||||
return this.wrapper(HttpType.Get, '/user/mention', form);
|
return this.wrapper(HttpType.Get, '/user/mention', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async markUserMentionAsRead(
|
async markUserMentionAsRead(
|
||||||
form: MarkUserMentionAsReadForm
|
form: MarkUserMentionAsRead
|
||||||
): Promise<UserMentionResponse> {
|
): Promise<UserMentionResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/user/mention/mark_as_read', form);
|
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);
|
return this.wrapper(HttpType.Get, '/user/replies', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFollowedCommunities(
|
async getFollowedCommunities(
|
||||||
form: GetFollowedCommunitiesForm
|
form: GetFollowedCommunities
|
||||||
): Promise<GetFollowedCommunitiesResponse> {
|
): Promise<GetFollowedCommunitiesResponse> {
|
||||||
return this.wrapper(HttpType.Get, '/user/followed_communities', form);
|
return this.wrapper(HttpType.Get, '/user/followed_communities', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async userJoin(form: UserJoinForm): Promise<UserJoinResponse> {
|
async userJoin(form: UserJoin): Promise<UserJoinResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/user/join', form);
|
return this.wrapper(HttpType.Post, '/user/join', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async postJoin(form: PostJoinForm): Promise<PostJoinResponse> {
|
async postJoin(form: PostJoin): Promise<PostJoinResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/post/join', form);
|
return this.wrapper(HttpType.Post, '/post/join', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async communityJoin(form: CommunityJoinForm): Promise<CommunityJoinResponse> {
|
async communityJoin(form: CommunityJoin): Promise<CommunityJoinResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/community/join', form);
|
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);
|
return this.wrapper(HttpType.Post, '/user/ban', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,27 +358,27 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
return this.wrapper(HttpType.Post, '/admin/add', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
export * from './interfaces';
|
|
||||||
export * from './websocket';
|
|
||||||
export * from './http';
|
|
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;
|
||||||
|
}
|
101
src/interfaces/api/comment.ts
Normal file
101
src/interfaces/api/comment.ts
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
import { CommentReportView, CommentView } from '../views';
|
||||||
|
|
||||||
|
export interface CreateComment {
|
||||||
|
content: string;
|
||||||
|
parent_id?: number;
|
||||||
|
post_id: number;
|
||||||
|
form_id?: string;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EditComment {
|
||||||
|
content: string;
|
||||||
|
edit_id: number;
|
||||||
|
form_id?: string;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteComment {
|
||||||
|
edit_id: number;
|
||||||
|
deleted: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RemoveComment {
|
||||||
|
edit_id: number;
|
||||||
|
removed: boolean;
|
||||||
|
reason?: string;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
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[]; // TODO another way to do this? Maybe a UserMention belongs to Comment
|
||||||
|
form_id?: string; // An optional front end ID, to tell which is coming ba,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateCommentLike {
|
||||||
|
comment_id: number;
|
||||||
|
score: number;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
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[];
|
||||||
|
}
|
131
src/interfaces/api/community.ts
Normal file
131
src/interfaces/api/community.ts
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
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;
|
||||||
|
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[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EditCommunity {
|
||||||
|
edit_id: number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
icon?: string;
|
||||||
|
banner?: string;
|
||||||
|
category_id: number;
|
||||||
|
nsfw: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeleteCommunity {
|
||||||
|
edit_id: number;
|
||||||
|
deleted: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RemoveCommunity {
|
||||||
|
edit_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommunityJoin {
|
||||||
|
community_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommunityJoinResponse {
|
||||||
|
joined: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModJoin {
|
||||||
|
community_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ModJoinResponse {
|
||||||
|
joined: boolean;
|
||||||
|
}
|
131
src/interfaces/api/post.ts
Normal file
131
src/interfaces/api/post.ts
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
import {
|
||||||
|
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;
|
||||||
|
comments: CommentView[];
|
||||||
|
moderators: CommunityModeratorView[];
|
||||||
|
online: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPosts {
|
||||||
|
type_: string;
|
||||||
|
sort: string;
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
community_id?: number;
|
||||||
|
community_name?: string;
|
||||||
|
auth?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPostsResponse {
|
||||||
|
posts: PostView[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreatePostLike {
|
||||||
|
post_id: number;
|
||||||
|
score: number;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EditPost {
|
||||||
|
edit_id: number;
|
||||||
|
name: string;
|
||||||
|
url?: string;
|
||||||
|
body?: string;
|
||||||
|
nsfw: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeletePost {
|
||||||
|
edit_id: number;
|
||||||
|
deleted: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RemovePost {
|
||||||
|
edit_id: number;
|
||||||
|
removed: boolean;
|
||||||
|
reason?: string;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LockPost {
|
||||||
|
edit_id: number;
|
||||||
|
locked: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StickyPost {
|
||||||
|
edit_id: number;
|
||||||
|
stickied: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SavePost {
|
||||||
|
post_id: number;
|
||||||
|
save: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PostJoin {
|
||||||
|
post_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PostJoinResponse {
|
||||||
|
joined: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
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[];
|
||||||
|
}
|
119
src/interfaces/api/site.ts
Normal file
119
src/interfaces/api/site.ts
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
import { Category, User_ } 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[];
|
||||||
|
}
|
||||||
|
|
||||||
|
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?: User_;
|
||||||
|
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;
|
||||||
|
}
|
219
src/interfaces/api/user.ts
Normal file
219
src/interfaces/api/user.ts
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
import {
|
||||||
|
CommentView,
|
||||||
|
CommunityFollowerView,
|
||||||
|
CommunityModeratorView,
|
||||||
|
PostView,
|
||||||
|
PrivateMessageView,
|
||||||
|
UserMentionView,
|
||||||
|
UserViewDangerous,
|
||||||
|
UserViewSafe,
|
||||||
|
} from '../views';
|
||||||
|
|
||||||
|
export interface Login {
|
||||||
|
username_or_email: string;
|
||||||
|
password: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Register {
|
||||||
|
username: string;
|
||||||
|
email?: string;
|
||||||
|
password: string;
|
||||||
|
password_verify: string;
|
||||||
|
admin: boolean;
|
||||||
|
show_nsfw: boolean;
|
||||||
|
captcha_uuid?: string;
|
||||||
|
captcha_answer?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetCaptcha {}
|
||||||
|
|
||||||
|
export interface GetCaptchaResponse {
|
||||||
|
ok?: CaptchaResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_sort_type: string;
|
||||||
|
default_listing_type: string;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginResponse {
|
||||||
|
jwt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
user_view_dangerous?: UserViewDangerous;
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
edit_id: number;
|
||||||
|
content: string;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeletePrivateMessage {
|
||||||
|
edit_id: number;
|
||||||
|
deleted: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MarkPrivateMessageAsRead {
|
||||||
|
edit_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserJoin {
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserJoinResponse {
|
||||||
|
joined: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetReportCount {
|
||||||
|
community?: number;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetReportCountResponse {
|
||||||
|
community?: number;
|
||||||
|
comment_reports: number;
|
||||||
|
post_reports: number;
|
||||||
|
}
|
266
src/interfaces/others.ts
Normal file
266
src/interfaces/others.ts
Normal file
|
@ -0,0 +1,266 @@
|
||||||
|
import {
|
||||||
|
CommentResponse,
|
||||||
|
CreateComment,
|
||||||
|
DeleteComment,
|
||||||
|
EditComment,
|
||||||
|
MarkCommentAsRead,
|
||||||
|
RemoveComment,
|
||||||
|
SaveComment,
|
||||||
|
} from './api/comment';
|
||||||
|
import {
|
||||||
|
AddModToCommunity,
|
||||||
|
AddModToCommunityResponse,
|
||||||
|
BanFromCommunity,
|
||||||
|
BanFromCommunityResponse,
|
||||||
|
CommunityJoin,
|
||||||
|
CommunityJoinResponse,
|
||||||
|
CommunityResponse,
|
||||||
|
CreateCommunity,
|
||||||
|
DeleteCommunity,
|
||||||
|
FollowCommunity,
|
||||||
|
GetCommunity,
|
||||||
|
GetFollowedCommunities,
|
||||||
|
GetFollowedCommunitiesResponse,
|
||||||
|
ListCommunities,
|
||||||
|
ListCommunitiesResponse,
|
||||||
|
RemoveCommunity,
|
||||||
|
TransferCommunity,
|
||||||
|
} from './api/community';
|
||||||
|
import {
|
||||||
|
CreatePostLike,
|
||||||
|
DeletePost,
|
||||||
|
GetPost,
|
||||||
|
GetPosts,
|
||||||
|
GetPostsResponse,
|
||||||
|
LockPost,
|
||||||
|
PostJoin,
|
||||||
|
PostJoinResponse,
|
||||||
|
PostResponse,
|
||||||
|
RemovePost,
|
||||||
|
StickyPost,
|
||||||
|
} from './api/post';
|
||||||
|
import {
|
||||||
|
CreateSite,
|
||||||
|
EditSite,
|
||||||
|
GetModlog,
|
||||||
|
GetModlogResponse,
|
||||||
|
GetSite,
|
||||||
|
GetSiteConfig,
|
||||||
|
GetSiteConfigResponse,
|
||||||
|
GetSiteResponse,
|
||||||
|
ListCategoriesResponse,
|
||||||
|
Search,
|
||||||
|
SearchResponse,
|
||||||
|
SiteResponse,
|
||||||
|
TransferSite,
|
||||||
|
} from './api/site';
|
||||||
|
import {
|
||||||
|
AddAdmin,
|
||||||
|
AddAdminResponse,
|
||||||
|
BanUser,
|
||||||
|
BanUserResponse,
|
||||||
|
DeleteAccount,
|
||||||
|
DeletePrivateMessage,
|
||||||
|
EditPrivateMessage,
|
||||||
|
GetCaptchaResponse,
|
||||||
|
GetPrivateMessages,
|
||||||
|
GetReplies,
|
||||||
|
GetRepliesResponse,
|
||||||
|
GetUserDetails,
|
||||||
|
GetUserMentions,
|
||||||
|
GetUserMentionsResponse,
|
||||||
|
Login,
|
||||||
|
LoginResponse,
|
||||||
|
MarkPrivateMessageAsRead,
|
||||||
|
MarkUserMentionAsRead,
|
||||||
|
PasswordChange,
|
||||||
|
PasswordReset,
|
||||||
|
PrivateMessageResponse,
|
||||||
|
PrivateMessagesResponse,
|
||||||
|
Register,
|
||||||
|
SaveUserSettings,
|
||||||
|
UserMentionResponse,
|
||||||
|
} from './api/user';
|
||||||
|
import { PrivateMessage } from './source';
|
||||||
|
|
||||||
|
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 type MessageType =
|
||||||
|
| Login
|
||||||
|
| Register
|
||||||
|
| CreateCommunity
|
||||||
|
| GetCommunity
|
||||||
|
| DeleteCommunity
|
||||||
|
| RemoveCommunity
|
||||||
|
| FollowCommunity
|
||||||
|
| ListCommunities
|
||||||
|
| GetFollowedCommunities
|
||||||
|
| DeletePost
|
||||||
|
| RemovePost
|
||||||
|
| LockPost
|
||||||
|
| StickyPost
|
||||||
|
| GetPost
|
||||||
|
| GetPosts
|
||||||
|
| GetCommunity
|
||||||
|
| CreateComment
|
||||||
|
| EditComment
|
||||||
|
| DeleteComment
|
||||||
|
| RemoveComment
|
||||||
|
| MarkCommentAsRead
|
||||||
|
| SaveComment
|
||||||
|
| CreatePostLike
|
||||||
|
| BanFromCommunity
|
||||||
|
| AddAdmin
|
||||||
|
| AddModToCommunity
|
||||||
|
| TransferCommunity
|
||||||
|
| TransferSite
|
||||||
|
| SaveComment
|
||||||
|
| BanUser
|
||||||
|
| GetUserDetails
|
||||||
|
| GetReplies
|
||||||
|
| GetUserMentions
|
||||||
|
| MarkUserMentionAsRead
|
||||||
|
| GetModlog
|
||||||
|
| CreateSite
|
||||||
|
| EditSite
|
||||||
|
| GetSite
|
||||||
|
| Search
|
||||||
|
| SaveUserSettings
|
||||||
|
| DeleteAccount
|
||||||
|
| PasswordReset
|
||||||
|
| PasswordChange
|
||||||
|
| PrivateMessage
|
||||||
|
| EditPrivateMessage
|
||||||
|
| DeletePrivateMessage
|
||||||
|
| MarkPrivateMessageAsRead
|
||||||
|
| GetPrivateMessages
|
||||||
|
| GetSiteConfig
|
||||||
|
| PostJoin
|
||||||
|
| CommunityJoin;
|
||||||
|
|
||||||
|
type ResponseType =
|
||||||
|
| SiteResponse
|
||||||
|
| GetFollowedCommunitiesResponse
|
||||||
|
| ListCommunitiesResponse
|
||||||
|
| GetPostsResponse
|
||||||
|
| PostResponse
|
||||||
|
| GetRepliesResponse
|
||||||
|
| GetUserMentionsResponse
|
||||||
|
| ListCategoriesResponse
|
||||||
|
| CommunityResponse
|
||||||
|
| CommentResponse
|
||||||
|
| UserMentionResponse
|
||||||
|
| LoginResponse
|
||||||
|
| GetCaptchaResponse
|
||||||
|
| GetModlogResponse
|
||||||
|
| SearchResponse
|
||||||
|
| BanFromCommunityResponse
|
||||||
|
| AddModToCommunityResponse
|
||||||
|
| BanUserResponse
|
||||||
|
| AddAdminResponse
|
||||||
|
| PrivateMessageResponse
|
||||||
|
| PrivateMessagesResponse
|
||||||
|
| GetSiteConfigResponse
|
||||||
|
| GetSiteResponse
|
||||||
|
| PostJoinResponse
|
||||||
|
| CommunityJoinResponse;
|
||||||
|
|
||||||
|
export interface WebSocketResponse {
|
||||||
|
op: UserOperation;
|
||||||
|
data: ResponseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebSocketJsonResponse {
|
||||||
|
op?: string;
|
||||||
|
data?: ResponseType;
|
||||||
|
error?: string;
|
||||||
|
reconnect?: boolean;
|
||||||
|
}
|
257
src/interfaces/source.ts
Normal file
257
src/interfaces/source.ts
Normal file
|
@ -0,0 +1,257 @@
|
||||||
|
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 User_ {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
preferred_username?: string;
|
||||||
|
password_encrypted: string;
|
||||||
|
email?: string;
|
||||||
|
avatar?: string;
|
||||||
|
admin: boolean;
|
||||||
|
banned: boolean;
|
||||||
|
published: string;
|
||||||
|
updated?: string;
|
||||||
|
show_nsfw: boolean;
|
||||||
|
theme: string;
|
||||||
|
default_sort_type: SortType;
|
||||||
|
default_listing_type: ListingType;
|
||||||
|
lang: string;
|
||||||
|
show_avatars: boolean;
|
||||||
|
send_notifications_to_email: boolean;
|
||||||
|
matrix_user_id?: string;
|
||||||
|
actor_id: string;
|
||||||
|
bio?: string;
|
||||||
|
local: boolean;
|
||||||
|
private_key?: string;
|
||||||
|
public_key?: string;
|
||||||
|
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;
|
||||||
|
}
|
193
src/interfaces/views.ts
Normal file
193
src/interfaces/views.ts
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
import {
|
||||||
|
CommentAggregates,
|
||||||
|
CommunityAggregates,
|
||||||
|
PostAggregates,
|
||||||
|
SiteAggregates,
|
||||||
|
UserAggregates,
|
||||||
|
} from './aggregates';
|
||||||
|
import {
|
||||||
|
Category,
|
||||||
|
CommentReport,
|
||||||
|
CommunitySafe,
|
||||||
|
ModAdd,
|
||||||
|
ModAddCommunity,
|
||||||
|
ModBan,
|
||||||
|
ModBanFromCommunity,
|
||||||
|
ModLockPost,
|
||||||
|
ModRemoveComment,
|
||||||
|
ModRemoveCommunity,
|
||||||
|
ModRemovePost,
|
||||||
|
ModStickyPost,
|
||||||
|
Post,
|
||||||
|
PostReport,
|
||||||
|
PrivateMessage,
|
||||||
|
Site,
|
||||||
|
UserMention,
|
||||||
|
UserSafe,
|
||||||
|
User_,
|
||||||
|
} from './source';
|
||||||
|
|
||||||
|
export interface UserViewSafe {
|
||||||
|
user: UserSafe;
|
||||||
|
counts: UserAggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserViewDangerous {
|
||||||
|
user: User_;
|
||||||
|
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; // Left Join to CommunityUserBan
|
||||||
|
subscribed: boolean; // Left join to CommunityFollower
|
||||||
|
saved: boolean; // Left join to CommentSaved
|
||||||
|
my_vote?: number; // Left join to CommentLi,
|
||||||
|
}
|
||||||
|
|
||||||
|
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; // Left Join to CommunityUserBan
|
||||||
|
counts: PostAggregates;
|
||||||
|
subscribed: boolean; // Left join to CommunityFollower
|
||||||
|
saved: boolean; // Left join to PostSaved
|
||||||
|
read: boolean; // Left join to PostRead
|
||||||
|
my_vote?: number; // Left join to PostLi,
|
||||||
|
}
|
||||||
|
|
||||||
|
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; // Left joins to comment and us,
|
||||||
|
post: Post;
|
||||||
|
community: CommunitySafe;
|
||||||
|
counts: CommentAggregates;
|
||||||
|
creator_banned_from_community: boolean; // Left Join to CommunityUserBan
|
||||||
|
subscribed: boolean; // Left join to CommunityFollower
|
||||||
|
saved: boolean; // Left join to CommentSaved
|
||||||
|
my_vote?: number; // Left join to CommentLi,
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
308
src/websocket.ts
308
src/websocket.ts
|
@ -1,308 +0,0 @@
|
||||||
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,
|
|
||||||
GetSiteConfig,
|
|
||||||
GetSiteForm,
|
|
||||||
SiteConfigForm,
|
|
||||||
MarkAllAsReadForm,
|
|
||||||
PostJoinForm,
|
|
||||||
CommunityJoinForm,
|
|
||||||
} from './interfaces';
|
|
||||||
|
|
||||||
export class LemmyWebsocket {
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
login(form: LoginForm): string {
|
|
||||||
return wrapper(UserOperation.Login, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
userJoin(form: UserJoinForm): string {
|
|
||||||
return wrapper(UserOperation.UserJoin, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
postJoin(form: PostJoinForm): string {
|
|
||||||
return wrapper(UserOperation.PostJoin, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
communityJoin(form: CommunityJoinForm): string {
|
|
||||||
return wrapper(UserOperation.CommunityJoin, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
register(registerForm: RegisterForm) {
|
|
||||||
return wrapper(UserOperation.Register, registerForm);
|
|
||||||
}
|
|
||||||
|
|
||||||
getCaptcha() {
|
|
||||||
return wrapper(UserOperation.GetCaptcha, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
createCommunity(form: CommunityForm) {
|
|
||||||
return wrapper(UserOperation.CreateCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
editCommunity(form: CommunityForm) {
|
|
||||||
return wrapper(UserOperation.EditCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteCommunity(form: DeleteCommunityForm) {
|
|
||||||
return wrapper(UserOperation.DeleteCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeCommunity(form: RemoveCommunityForm) {
|
|
||||||
return wrapper(UserOperation.RemoveCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
followCommunity(form: FollowCommunityForm) {
|
|
||||||
return wrapper(UserOperation.FollowCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
listCommunities(form: ListCommunitiesForm) {
|
|
||||||
return wrapper(UserOperation.ListCommunities, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getFollowedCommunities(form: GetFollowedCommunitiesForm) {
|
|
||||||
return wrapper(UserOperation.GetFollowedCommunities, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
listCategories() {
|
|
||||||
return wrapper(UserOperation.ListCategories, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
createPost(form: PostForm) {
|
|
||||||
return wrapper(UserOperation.CreatePost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPost(form: GetPostForm) {
|
|
||||||
return wrapper(UserOperation.GetPost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getCommunity(form: GetCommunityForm) {
|
|
||||||
return wrapper(UserOperation.GetCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
createComment(form: CommentForm) {
|
|
||||||
return wrapper(UserOperation.CreateComment, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
editComment(form: CommentForm) {
|
|
||||||
return wrapper(UserOperation.EditComment, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteComment(form: DeleteCommentForm) {
|
|
||||||
return wrapper(UserOperation.DeleteComment, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeComment(form: RemoveCommentForm) {
|
|
||||||
return wrapper(UserOperation.RemoveComment, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
markCommentAsRead(form: MarkCommentAsReadForm) {
|
|
||||||
return wrapper(UserOperation.MarkCommentAsRead, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
likeComment(form: CommentLikeForm) {
|
|
||||||
return wrapper(UserOperation.CreateCommentLike, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveComment(form: SaveCommentForm) {
|
|
||||||
return wrapper(UserOperation.SaveComment, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPosts(form: GetPostsForm) {
|
|
||||||
return wrapper(UserOperation.GetPosts, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getComments(form: GetCommentsForm) {
|
|
||||||
return wrapper(UserOperation.GetComments, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
likePost(form: CreatePostLikeForm) {
|
|
||||||
return wrapper(UserOperation.CreatePostLike, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
editPost(form: PostForm) {
|
|
||||||
return wrapper(UserOperation.EditPost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
deletePost(form: DeletePostForm) {
|
|
||||||
return wrapper(UserOperation.DeletePost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
removePost(form: RemovePostForm) {
|
|
||||||
return wrapper(UserOperation.RemovePost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
lockPost(form: LockPostForm) {
|
|
||||||
return wrapper(UserOperation.LockPost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
stickyPost(form: StickyPostForm) {
|
|
||||||
return wrapper(UserOperation.StickyPost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
savePost(form: SavePostForm) {
|
|
||||||
return wrapper(UserOperation.SavePost, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
banFromCommunity(form: BanFromCommunityForm) {
|
|
||||||
return wrapper(UserOperation.BanFromCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
addModToCommunity(form: AddModToCommunityForm) {
|
|
||||||
return wrapper(UserOperation.AddModToCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
transferCommunity(form: TransferCommunityForm) {
|
|
||||||
return wrapper(UserOperation.TransferCommunity, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
transferSite(form: TransferSiteForm) {
|
|
||||||
return wrapper(UserOperation.TransferSite, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
banUser(form: BanUserForm) {
|
|
||||||
return wrapper(UserOperation.BanUser, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
addAdmin(form: AddAdminForm) {
|
|
||||||
return wrapper(UserOperation.AddAdmin, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserDetails(form: GetUserDetailsForm) {
|
|
||||||
return wrapper(UserOperation.GetUserDetails, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getReplies(form: GetRepliesForm) {
|
|
||||||
return wrapper(UserOperation.GetReplies, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserMentions(form: GetUserMentionsForm) {
|
|
||||||
return wrapper(UserOperation.GetUserMentions, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
markUserMentionAsRead(form: MarkUserMentionAsReadForm) {
|
|
||||||
return wrapper(UserOperation.MarkUserMentionAsRead, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getModlog(form: GetModlogForm) {
|
|
||||||
return wrapper(UserOperation.GetModlog, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
createSite(form: SiteForm) {
|
|
||||||
return wrapper(UserOperation.CreateSite, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
editSite(form: SiteForm) {
|
|
||||||
return wrapper(UserOperation.EditSite, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSite(form: GetSiteForm = {}) {
|
|
||||||
return wrapper(UserOperation.GetSite, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSiteConfig(form: GetSiteConfig) {
|
|
||||||
return wrapper(UserOperation.GetSiteConfig, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
search(form: SearchForm) {
|
|
||||||
return wrapper(UserOperation.Search, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
markAllAsRead(form: MarkAllAsReadForm) {
|
|
||||||
return wrapper(UserOperation.MarkAllAsRead, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveUserSettings(form: UserSettingsForm) {
|
|
||||||
return wrapper(UserOperation.SaveUserSettings, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteAccount(form: DeleteAccountForm) {
|
|
||||||
return wrapper(UserOperation.DeleteAccount, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
passwordReset(form: PasswordResetForm) {
|
|
||||||
return wrapper(UserOperation.PasswordReset, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
passwordChange(form: PasswordChangeForm) {
|
|
||||||
return wrapper(UserOperation.PasswordChange, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
createPrivateMessage(form: PrivateMessageForm) {
|
|
||||||
return wrapper(UserOperation.CreatePrivateMessage, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
editPrivateMessage(form: EditPrivateMessageForm) {
|
|
||||||
return wrapper(UserOperation.EditPrivateMessage, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
deletePrivateMessage(form: DeletePrivateMessageForm) {
|
|
||||||
return wrapper(UserOperation.DeletePrivateMessage, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
markPrivateMessageAsRead(form: MarkPrivateMessageAsReadForm) {
|
|
||||||
return wrapper(UserOperation.MarkPrivateMessageAsRead, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPrivateMessages(form: GetPrivateMessagesForm) {
|
|
||||||
return wrapper(UserOperation.GetPrivateMessages, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveSiteConfig(form: SiteConfigForm) {
|
|
||||||
return wrapper(UserOperation.SaveSiteConfig, form);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function wrapper(op: UserOperation, data: MessageType) {
|
|
||||||
let send = { op: UserOperation[op], data: data };
|
|
||||||
console.log(send);
|
|
||||||
return JSON.stringify(send);
|
|
||||||
}
|
|
Loading…
Reference in a new issue