2022-06-21 21:42:09 +00:00
|
|
|
import { ClassConstructor, deserialize, serialize } from "class-transformer";
|
2020-12-20 17:38:55 +00:00
|
|
|
import {
|
|
|
|
CreateComment,
|
|
|
|
CreateCommentLike,
|
2021-09-28 10:38:49 +00:00
|
|
|
CreateCommentReport,
|
2020-12-20 17:38:55 +00:00
|
|
|
DeleteComment,
|
|
|
|
EditComment,
|
|
|
|
GetComments,
|
2021-09-28 10:38:49 +00:00
|
|
|
ListCommentReports,
|
2020-12-20 17:38:55 +00:00
|
|
|
MarkCommentAsRead,
|
|
|
|
RemoveComment,
|
2021-09-28 10:38:49 +00:00
|
|
|
ResolveCommentReport,
|
2020-12-20 17:38:55 +00:00
|
|
|
SaveComment,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/comment";
|
2020-12-20 17:38:55 +00:00
|
|
|
import {
|
|
|
|
AddModToCommunity,
|
|
|
|
BanFromCommunity,
|
2021-08-20 00:49:15 +00:00
|
|
|
BlockCommunity,
|
2020-12-20 17:38:55 +00:00
|
|
|
CreateCommunity,
|
|
|
|
DeleteCommunity,
|
|
|
|
EditCommunity,
|
|
|
|
FollowCommunity,
|
|
|
|
GetCommunity,
|
|
|
|
ListCommunities,
|
|
|
|
RemoveCommunity,
|
|
|
|
TransferCommunity,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/community";
|
|
|
|
import {
|
|
|
|
AddAdmin,
|
|
|
|
BanPerson,
|
|
|
|
BlockPerson,
|
|
|
|
ChangePassword,
|
|
|
|
CreatePrivateMessage,
|
|
|
|
DeleteAccount,
|
|
|
|
DeletePrivateMessage,
|
|
|
|
EditPrivateMessage,
|
2022-01-06 16:19:36 +00:00
|
|
|
GetBannedPersons,
|
2021-12-06 19:44:10 +00:00
|
|
|
GetPersonDetails,
|
|
|
|
GetPersonMentions,
|
|
|
|
GetPrivateMessages,
|
|
|
|
GetReplies,
|
|
|
|
GetReportCount,
|
|
|
|
GetUnreadCount,
|
|
|
|
Login,
|
|
|
|
MarkAllAsRead,
|
|
|
|
MarkPersonMentionAsRead,
|
|
|
|
MarkPrivateMessageAsRead,
|
|
|
|
PasswordChange,
|
|
|
|
PasswordReset,
|
|
|
|
Register,
|
|
|
|
SaveUserSettings,
|
2021-12-30 15:27:05 +00:00
|
|
|
VerifyEmail,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/person";
|
2020-12-20 17:38:55 +00:00
|
|
|
import {
|
|
|
|
CreatePost,
|
|
|
|
CreatePostLike,
|
2021-09-28 10:38:49 +00:00
|
|
|
CreatePostReport,
|
2020-12-20 17:38:55 +00:00
|
|
|
DeletePost,
|
|
|
|
EditPost,
|
|
|
|
GetPost,
|
|
|
|
GetPosts,
|
2021-08-19 15:14:39 +00:00
|
|
|
GetSiteMetadata,
|
2021-09-28 10:38:49 +00:00
|
|
|
ListPostReports,
|
2020-12-20 17:38:55 +00:00
|
|
|
LockPost,
|
2022-05-22 19:46:20 +00:00
|
|
|
MarkPostAsRead,
|
2020-12-20 17:38:55 +00:00
|
|
|
RemovePost,
|
2021-09-28 10:38:49 +00:00
|
|
|
ResolvePostReport,
|
2020-12-20 17:38:55 +00:00
|
|
|
SavePost,
|
|
|
|
StickyPost,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/post";
|
2020-12-20 17:38:55 +00:00
|
|
|
import {
|
2021-12-30 15:27:05 +00:00
|
|
|
ApproveRegistrationApplication,
|
2020-12-20 17:38:55 +00:00
|
|
|
CreateSite,
|
|
|
|
EditSite,
|
|
|
|
GetModlog,
|
|
|
|
GetSite,
|
2021-12-30 15:27:05 +00:00
|
|
|
GetUnreadRegistrationApplicationCount,
|
2022-03-01 16:54:51 +00:00
|
|
|
LeaveAdmin,
|
2021-12-30 15:27:05 +00:00
|
|
|
ListRegistrationApplications,
|
2021-08-23 20:15:24 +00:00
|
|
|
ResolveObject,
|
2020-12-20 17:38:55 +00:00
|
|
|
Search,
|
2021-12-06 19:44:10 +00:00
|
|
|
} from "./interfaces/api/site";
|
|
|
|
import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
|
|
|
|
import { UserOperation } from "./interfaces/others";
|
2020-12-20 17:38:55 +00:00
|
|
|
|
2021-01-24 17:37:04 +00:00
|
|
|
/**
|
2021-08-23 01:01:40 +00:00
|
|
|
* Helps build lemmy websocket message requests, that you can use in your Websocket sends.
|
|
|
|
*
|
2021-08-23 15:18:08 +00:00
|
|
|
* You'll receive back a [[WebSocketResponse]].
|
2021-08-23 01:01:40 +00:00
|
|
|
*
|
|
|
|
* The return types for these are given in [[LemmyHttp]]
|
2021-01-24 17:37:04 +00:00
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
export class LemmyWebsocket {
|
|
|
|
constructor() {}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Log into lemmy.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
login(form: Login): string {
|
|
|
|
return wrapper(UserOperation.Login, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A websocket join for your user.
|
|
|
|
*
|
|
|
|
* Allows your user to receive private messages and notifications.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
userJoin(form: UserJoin): string {
|
|
|
|
return wrapper(UserOperation.UserJoin, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A websocket join for the current post room.
|
|
|
|
*
|
|
|
|
* Allows your user to receive new comments and updates for that post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
postJoin(form: PostJoin): string {
|
|
|
|
return wrapper(UserOperation.PostJoin, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A websocket join for a given community.
|
|
|
|
*
|
|
|
|
* Allows your user to receive community updates.
|
|
|
|
*
|
|
|
|
* Note: community_id: 0, is your front page.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
communityJoin(form: CommunityJoin): string {
|
|
|
|
return wrapper(UserOperation.CommunityJoin, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Register a new user.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
register(register: Register) {
|
|
|
|
return wrapper(UserOperation.Register, register);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Fetch a Captcha.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getCaptcha() {
|
|
|
|
return wrapper(UserOperation.GetCaptcha, {});
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a new community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
createCommunity(form: CreateCommunity) {
|
|
|
|
return wrapper(UserOperation.CreateCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
editCommunity(form: EditCommunity) {
|
|
|
|
return wrapper(UserOperation.EditCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
deleteCommunity(form: DeleteCommunity) {
|
|
|
|
return wrapper(UserOperation.DeleteCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator remove for a community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
removeCommunity(form: RemoveCommunity) {
|
|
|
|
return wrapper(UserOperation.RemoveCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Follow / subscribe to a community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
followCommunity(form: FollowCommunity) {
|
|
|
|
return wrapper(UserOperation.FollowCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* List communities, with various filters.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
listCommunities(form: ListCommunities) {
|
|
|
|
return wrapper(UserOperation.ListCommunities, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
createPost(form: CreatePost) {
|
|
|
|
return wrapper(UserOperation.CreatePost, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getPost(form: GetPost) {
|
|
|
|
return wrapper(UserOperation.GetPost, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch a community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getCommunity(form: GetCommunity) {
|
|
|
|
return wrapper(UserOperation.GetCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a comment.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
createComment(form: CreateComment) {
|
|
|
|
return wrapper(UserOperation.CreateComment, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a comment.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
editComment(form: EditComment) {
|
|
|
|
return wrapper(UserOperation.EditComment, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a comment.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
deleteComment(form: DeleteComment) {
|
|
|
|
return wrapper(UserOperation.DeleteComment, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator remove for a comment.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
removeComment(form: RemoveComment) {
|
|
|
|
return wrapper(UserOperation.RemoveComment, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark a comment as read.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
markCommentAsRead(form: MarkCommentAsRead) {
|
|
|
|
return wrapper(UserOperation.MarkCommentAsRead, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Like / vote on a comment.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
likeComment(form: CreateCommentLike) {
|
|
|
|
return wrapper(UserOperation.CreateCommentLike, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Save a comment.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
saveComment(form: SaveComment) {
|
|
|
|
return wrapper(UserOperation.SaveComment, form);
|
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:49 +00:00
|
|
|
/**
|
|
|
|
* Report a comment.
|
|
|
|
*/
|
|
|
|
createCommentReport(form: CreateCommentReport) {
|
|
|
|
return wrapper(UserOperation.CreateCommentReport, form);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve a comment report. Only a mod can do this.
|
|
|
|
*/
|
|
|
|
resolveCommentReport(form: ResolveCommentReport) {
|
|
|
|
return wrapper(UserOperation.ResolveCommentReport, form);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List comment reports.
|
|
|
|
*/
|
|
|
|
listCommentReports(form: ListCommentReports) {
|
|
|
|
return wrapper(UserOperation.ListCommentReports, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch posts, with various filters.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getPosts(form: GetPosts) {
|
|
|
|
return wrapper(UserOperation.GetPosts, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch comments.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getComments(form: GetComments) {
|
|
|
|
return wrapper(UserOperation.GetComments, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Like / vote on a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
likePost(form: CreatePostLike) {
|
|
|
|
return wrapper(UserOperation.CreatePostLike, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
editPost(form: EditPost) {
|
|
|
|
return wrapper(UserOperation.EditPost, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
deletePost(form: DeletePost) {
|
|
|
|
return wrapper(UserOperation.DeletePost, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator remove for a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
removePost(form: RemovePost) {
|
|
|
|
return wrapper(UserOperation.RemovePost, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator can lock a post ( IE disable new comments ).
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
lockPost(form: LockPost) {
|
|
|
|
return wrapper(UserOperation.LockPost, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* A moderator can sticky a post ( IE stick it to the top of a community ).
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
stickyPost(form: StickyPost) {
|
|
|
|
return wrapper(UserOperation.StickyPost, form);
|
|
|
|
}
|
|
|
|
|
2022-05-22 19:46:20 +00:00
|
|
|
/**
|
|
|
|
* Mark a post as read.
|
|
|
|
*/
|
|
|
|
markPostAsRead(form: MarkPostAsRead) {
|
|
|
|
return wrapper(UserOperation.MarkPostAsRead, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Save a post.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
savePost(form: SavePost) {
|
|
|
|
return wrapper(UserOperation.SavePost, form);
|
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:49 +00:00
|
|
|
/**
|
|
|
|
* Report a post.
|
|
|
|
*/
|
|
|
|
createPostReport(form: CreatePostReport) {
|
|
|
|
return wrapper(UserOperation.CreatePostReport, form);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve a post report. Only a mod can do this.
|
|
|
|
*/
|
|
|
|
resolvePostReport(form: ResolvePostReport) {
|
|
|
|
return wrapper(UserOperation.ResolvePostReport, form);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List post reports.
|
|
|
|
*/
|
|
|
|
listPostReports(form: ListPostReports) {
|
|
|
|
return wrapper(UserOperation.ListPostReports, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Fetch metadata for any given site.
|
|
|
|
*/
|
2021-08-19 15:14:39 +00:00
|
|
|
getSiteMetadata(form: GetSiteMetadata) {
|
|
|
|
return wrapper(UserOperation.GetSiteMetadata, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Ban a user from a community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
banFromCommunity(form: BanFromCommunity) {
|
|
|
|
return wrapper(UserOperation.BanFromCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Add a moderator to your community.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
addModToCommunity(form: AddModToCommunity) {
|
|
|
|
return wrapper(UserOperation.AddModToCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Transfer your community to an existing moderator.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
transferCommunity(form: TransferCommunity) {
|
|
|
|
return wrapper(UserOperation.TransferCommunity, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
2022-03-01 16:54:51 +00:00
|
|
|
* Leave the Site admins.
|
2021-08-23 01:01:40 +00:00
|
|
|
*/
|
2022-03-01 16:54:51 +00:00
|
|
|
leaveAdmin(form: LeaveAdmin) {
|
|
|
|
return wrapper(UserOperation.LeaveAdmin, form);
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Ban a person from your site.
|
|
|
|
*/
|
2021-03-12 18:22:16 +00:00
|
|
|
banPerson(form: BanPerson) {
|
|
|
|
return wrapper(UserOperation.BanPerson, form);
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 16:19:36 +00:00
|
|
|
/**
|
|
|
|
* Get a list of banned users
|
|
|
|
*/
|
|
|
|
getBannedPersons(form: GetBannedPersons) {
|
|
|
|
return wrapper(UserOperation.GetBannedPersons, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Add an admin to your site.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
addAdmin(form: AddAdmin) {
|
|
|
|
return wrapper(UserOperation.AddAdmin, form);
|
|
|
|
}
|
|
|
|
|
2021-12-30 15:27:05 +00:00
|
|
|
/**
|
|
|
|
* Get the unread registration applications count.
|
|
|
|
*/
|
|
|
|
getUnreadRegistrationApplicationCount(
|
|
|
|
form: GetUnreadRegistrationApplicationCount
|
|
|
|
) {
|
|
|
|
return wrapper(UserOperation.GetUnreadRegistrationApplicationCount, form);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List the unread registration applications.
|
|
|
|
*/
|
|
|
|
listRegistrationApplications(form: ListRegistrationApplications) {
|
|
|
|
return wrapper(UserOperation.ListRegistrationApplications, form);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Approve a registration application
|
|
|
|
*/
|
|
|
|
approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
|
|
|
return wrapper(UserOperation.ApproveRegistrationApplication, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get the details for a person.
|
|
|
|
*/
|
2021-03-12 18:22:16 +00:00
|
|
|
getPersonDetails(form: GetPersonDetails) {
|
|
|
|
return wrapper(UserOperation.GetPersonDetails, form);
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get comment replies.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getReplies(form: GetReplies) {
|
|
|
|
return wrapper(UserOperation.GetReplies, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get mentions for your user.
|
|
|
|
*/
|
2021-03-12 18:22:16 +00:00
|
|
|
getPersonMentions(form: GetPersonMentions) {
|
|
|
|
return wrapper(UserOperation.GetPersonMentions, form);
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark a person mention as read.
|
|
|
|
*/
|
2021-03-12 18:22:16 +00:00
|
|
|
markPersonMentionAsRead(form: MarkPersonMentionAsRead) {
|
|
|
|
return wrapper(UserOperation.MarkPersonMentionAsRead, form);
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get the modlog.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getModlog(form: GetModlog) {
|
|
|
|
return wrapper(UserOperation.GetModlog, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create your site.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
createSite(form: CreateSite) {
|
|
|
|
return wrapper(UserOperation.CreateSite, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit your site.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
editSite(form: EditSite) {
|
|
|
|
return wrapper(UserOperation.EditSite, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Gets the site, and your user data.
|
|
|
|
*/
|
2022-06-21 21:42:09 +00:00
|
|
|
getSite(form: GetSite) {
|
2020-12-20 17:38:55 +00:00
|
|
|
return wrapper(UserOperation.GetSite, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Search lemmy.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
search(form: Search) {
|
|
|
|
return wrapper(UserOperation.Search, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 20:15:24 +00:00
|
|
|
/**
|
|
|
|
* Fetch a non-local / federated object.
|
|
|
|
*/
|
|
|
|
resolveObject(form: ResolveObject) {
|
|
|
|
return wrapper(UserOperation.ResolveObject, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark all replies as read.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
markAllAsRead(form: MarkAllAsRead) {
|
|
|
|
return wrapper(UserOperation.MarkAllAsRead, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Save your user settings.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
saveUserSettings(form: SaveUserSettings) {
|
|
|
|
return wrapper(UserOperation.SaveUserSettings, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Change your user password.
|
|
|
|
*/
|
2021-04-01 21:35:37 +00:00
|
|
|
changePassword(form: ChangePassword) {
|
|
|
|
return wrapper(UserOperation.ChangePassword, form);
|
|
|
|
}
|
|
|
|
|
2021-09-28 10:38:49 +00:00
|
|
|
/**
|
|
|
|
* Get counts for your reports
|
|
|
|
*/
|
|
|
|
getReportCount(form: GetReportCount) {
|
|
|
|
return wrapper(UserOperation.GetReportCount, form);
|
|
|
|
}
|
|
|
|
|
2021-10-17 17:42:40 +00:00
|
|
|
/**
|
|
|
|
* Get your unread counts
|
|
|
|
*/
|
|
|
|
getUnreadCount(form: GetUnreadCount) {
|
|
|
|
return wrapper(UserOperation.GetUnreadCount, form);
|
|
|
|
}
|
2021-12-30 15:27:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify your email
|
|
|
|
*/
|
|
|
|
verifyEmail(form: VerifyEmail) {
|
|
|
|
return wrapper(UserOperation.VerifyEmail, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete your account.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
deleteAccount(form: DeleteAccount) {
|
|
|
|
return wrapper(UserOperation.DeleteAccount, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Reset your password.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
passwordReset(form: PasswordReset) {
|
|
|
|
return wrapper(UserOperation.PasswordReset, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Change your password from an email / token based reset.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
passwordChange(form: PasswordChange) {
|
|
|
|
return wrapper(UserOperation.PasswordChange, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Create a private message.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
createPrivateMessage(form: CreatePrivateMessage) {
|
|
|
|
return wrapper(UserOperation.CreatePrivateMessage, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Edit a private message.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
editPrivateMessage(form: EditPrivateMessage) {
|
|
|
|
return wrapper(UserOperation.EditPrivateMessage, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Delete a private message.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
deletePrivateMessage(form: DeletePrivateMessage) {
|
|
|
|
return wrapper(UserOperation.DeletePrivateMessage, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Mark a private message as read.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
markPrivateMessageAsRead(form: MarkPrivateMessageAsRead) {
|
|
|
|
return wrapper(UserOperation.MarkPrivateMessageAsRead, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Get / fetch private messages.
|
|
|
|
*/
|
2020-12-20 17:38:55 +00:00
|
|
|
getPrivateMessages(form: GetPrivateMessages) {
|
|
|
|
return wrapper(UserOperation.GetPrivateMessages, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Block a person.
|
|
|
|
*/
|
2021-08-20 00:49:15 +00:00
|
|
|
blockPerson(form: BlockPerson) {
|
|
|
|
return wrapper(UserOperation.BlockPerson, form);
|
|
|
|
}
|
|
|
|
|
2021-08-23 01:01:40 +00:00
|
|
|
/**
|
|
|
|
* Block a community.
|
|
|
|
*/
|
2021-08-20 00:49:15 +00:00
|
|
|
blockCommunity(form: BlockCommunity) {
|
|
|
|
return wrapper(UserOperation.BlockCommunity, form);
|
|
|
|
}
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 19:21:26 +00:00
|
|
|
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
2022-06-21 21:42:09 +00:00
|
|
|
let send = serialize({ op: UserOperation[op], data });
|
|
|
|
return send;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function wsUserOp(msg: any): UserOperation {
|
|
|
|
let opStr: string = msg.op;
|
|
|
|
return UserOperation[opStr as keyof typeof UserOperation];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a websocket string response to a usable result
|
|
|
|
*/
|
|
|
|
export function wsJsonToRes<ResponseType>(
|
|
|
|
msg: any,
|
|
|
|
responseClass: ClassConstructor<ResponseType>
|
|
|
|
): ResponseType {
|
|
|
|
// Have to deserialize the response again into the correct class
|
|
|
|
return deserialize(responseClass, serialize(msg.data));
|
2020-12-20 17:38:55 +00:00
|
|
|
}
|