Implementation
final Map<String, WsEvent Function(Map<String, dynamic>)> wsDeserializer = {
'CreateComment': (json) => WsEventCreateComment(
const CreateComment(content: '', postId: 0, auth: '')
.responseFactory(json),
),
'EditComment': (json) => WsEventEditComment(
const EditComment(content: '', commentId: 0, auth: '')
.responseFactory(json),
),
'DeleteComment': (json) => WsEventDeleteComment(
const DeleteComment(commentId: 0, deleted: true, auth: '')
.responseFactory(json),
),
'RemoveComment': (json) => WsEventRemoveComment(
const RemoveComment(commentId: 0, removed: true, auth: '')
.responseFactory(json),
),
'MarkCommentAsRead': (json) => WsEventMarkCommentAsRead(
const MarkCommentAsRead(commentId: 0, read: true, auth: '')
.responseFactory(json),
),
'SaveComment': (json) => WsEventSaveComment(
const SaveComment(commentId: 0, save: true, auth: '')
.responseFactory(json),
),
'CreateCommentLike': (json) => WsEventCreateCommentLike(
const CreateCommentLike(commentId: 0, score: VoteType.none, auth: '')
.responseFactory(json),
),
'GetComments': (json) => WsEventGetComments(
const GetComments(
type: CommentListingType.all,
sort: SortType.hot,
savedOnly: false,
).responseFactory(json),
),
'CreateCommentReport': (json) => WsEventCreateCommentReport(
const CreateCommentReport(commentId: 0, reason: '', auth: '')
.responseFactory(json),
),
'ResolveCommentReport': (json) => WsEventResolveCommentReport(
const ResolveCommentReport(reportId: 0, resolved: true, auth: '')
.responseFactory(json),
),
'ListCommentReports': (json) => WsEventListCommentReports(
const ListCommentReports(auth: '').responseFactory(json),
),
'GetCommunity': (json) => WsEventGetCommunity(
const GetCommunity().responseFactory(json),
),
'CreateCommunity': (json) => WsEventCreateCommunity(
const CreateCommunity(name: '', title: '', nsfw: true, auth: '')
.responseFactory(json),
),
'ListCommunities': (json) => WsEventListCommunities(
const ListCommunities(type: PostListingType.all, sort: SortType.hot)
.responseFactory(json),
),
'BanFromCommunity': (json) => WsEventBanFromCommunity(
const BanFromCommunity(
communityId: 0,
personId: 0,
ban: true,
removeData: true,
auth: '',
).responseFactory(json),
),
'AddModToCommunity': (json) => WsEventAddModToCommunity(
const AddModToCommunity(
communityId: 0,
personId: 0,
added: true,
auth: '',
).responseFactory(json),
),
'EditCommunity': (json) => WsEventEditCommunity(
const EditCommunity(communityId: 0, title: '', nsfw: true, auth: '')
.responseFactory(json),
),
'DeleteCommunity': (json) => WsEventDeleteCommunity(
const DeleteCommunity(communityId: 0, deleted: true, auth: '')
.responseFactory(json),
),
'RemoveCommunity': (json) => WsEventRemoveCommunity(
const RemoveCommunity(communityId: 0, removed: true, auth: '')
.responseFactory(json),
),
'FollowCommunity': (json) => WsEventFollowCommunity(
const FollowCommunity(communityId: 0, follow: true, auth: '')
.responseFactory(json),
),
'TransferCommunity': (json) => WsEventTransferCommunity(
const TransferCommunity(communityId: 0, personId: 0, auth: '')
.responseFactory(json),
),
'LeaveAdmin': (json) => WsEventLeaveAdmin(
const LeaveAdmin(auth: '').responseFactory(json),
),
'GetPost': (json) => WsEventGetPost(
const GetPost(id: 0).responseFactory(json),
),
'CreatePost': (json) => WsEventCreatePost(
const CreatePost(name: '', nsfw: true, communityId: 0, auth: '')
.responseFactory(json),
),
'GetPosts': (json) => WsEventGetPosts(
const GetPosts(
type: PostListingType.all,
sort: SortType.hot,
savedOnly: false,
).responseFactory(json),
),
'CreatePostLike': (json) => WsEventCreatePostLike(
const CreatePostLike(postId: 0, score: VoteType.none, auth: '')
.responseFactory(json),
),
'EditPost': (json) => WsEventEditPost(
const EditPost(postId: 0, name: '', nsfw: true, auth: '')
.responseFactory(json),
),
'DeletePost': (json) => WsEventDeletePost(
const DeletePost(postId: 0, deleted: true, auth: '')
.responseFactory(json),
),
'RemovePost': (json) => WsEventRemovePost(
const RemovePost(postId: 0, removed: true, auth: '')
.responseFactory(json),
),
'LockPost': (json) => WsEventLockPost(
const LockPost(postId: 0, locked: true, auth: '').responseFactory(json),
),
'StickyPost': (json) => WsEventStickyPost(
const StickyPost(postId: 0, stickied: true, auth: '')
.responseFactory(json),
),
'SavePost': (json) => WsEventSavePost(
const SavePost(postId: 0, save: true, auth: '').responseFactory(json),
),
'CreatePostReport': (json) => WsEventCreatePostReport(
const CreatePostReport(postId: 0, reason: '', auth: '')
.responseFactory(json),
),
'ResolvePostReport': (json) => WsEventResolvePostReport(
const ResolvePostReport(reportId: 0, resolved: true, auth: '')
.responseFactory(json),
),
'ListPostReports': (json) => WsEventListPostReports(
const ListPostReports(auth: '').responseFactory(json),
),
'Search': (json) => WsEventSearch(
const Search(
q: '',
type: SearchType.all,
listingType: PostListingType.all,
sort: SortType.hot,
).responseFactory(json),
),
'GetModlog': (json) => WsEventGetModlog(
const GetModlog().responseFactory(json),
),
'CreateSite': (json) => WsEventCreateSite(
const CreateSite(
name: '',
enableDownvotes: true,
openRegistration: true,
enableNsfw: true,
auth: '',
).responseFactory(json),
),
'EditSite': (json) => WsEventEditSite(
const EditSite(
name: '',
enableDownvotes: true,
openRegistration: true,
enableNsfw: true,
auth: '',
).responseFactory(json),
),
'GetSite': (json) => WsEventGetSite(
const GetSite().responseFactory(json),
),
'GetSiteConfig': (json) => WsEventGetSiteConfig(
const GetSiteConfig(auth: '').responseFactory(json),
),
'SaveSiteConfig': (json) => WsEventSaveSiteConfig(
const SaveSiteConfig(configHjson: '', auth: '').responseFactory(json),
),
'Login': (json) => WsEventLogin(
const Login(usernameOrEmail: '', password: '').responseFactory(json),
),
'Register': (json) => WsEventRegister(
const Register(
username: '',
password: '',
passwordVerify: '',
showNsfw: true,
).responseFactory(json),
),
'GetCaptcha': (json) => WsEventGetCaptcha(
const GetCaptcha().responseFactory(json),
),
'SaveUserSettings': (json) => WsEventSaveUserSettings(
const SaveUserSettings(
showNsfw: true,
theme: '',
defaultSortType: SortType.hot,
defaultListingType: PostListingType.all,
lang: '',
showAvatars: true,
sendNotificationsToEmail: true,
auth: '',
).responseFactory(json),
),
'ChangePassword': (json) => WsEventChangePassword(
const ChangePassword(
newPassword: '',
newPasswordVerify: '',
oldPassword: '',
auth: '',
).responseFactory(json),
),
'GetPersonDetails': (json) => WsEventGetPersonDetails(
const GetPersonDetails(sort: SortType.hot, savedOnly: true)
.responseFactory(json),
),
'MarkAllAsRead': (json) => WsEventMarkAllAsRead(
const MarkAllAsRead(auth: '').responseFactory(json),
),
'AddAdmin': (json) => WsEventAddAdmin(
const AddAdmin(personId: 0, added: true, auth: '')
.responseFactory(json),
),
'BanPerson': (json) => WsEventBanPerson(
const BanPerson(personId: 0, ban: true, removeData: true, auth: '')
.responseFactory(json),
),
'GetReplies': (json) => WsEventGetReplies(
const GetReplies(sort: SortType.hot, unreadOnly: true, auth: '')
.responseFactory(json),
),
'GetPersonMentions': (json) => WsEventGetPersonMentions(
const GetPersonMentions(sort: SortType.hot, unreadOnly: true, auth: '')
.responseFactory(json),
),
'MarkPersonMentionAsRead': (json) => WsEventMarkPersonMentionAsRead(
const MarkPersonMentionAsRead(personMentionId: 0, read: true, auth: '')
.responseFactory(json),
),
'DeleteAccount': (json) => WsEventDeleteAccount(
const DeleteAccount(password: '', auth: '').responseFactory(json),
),
'PasswordReset': (json) => WsEventPasswordReset(
const PasswordReset(email: '').responseFactory(json),
),
'PasswordChange': (json) => WsEventPasswordChange(
const PasswordChange(token: '', password: '', passwordVerify: '')
.responseFactory(json),
),
'CreatePrivateMessage': (json) => WsEventCreatePrivateMessage(
const CreatePrivateMessage(content: '', recipientId: 0, auth: '')
.responseFactory(json),
),
'EditPrivateMessage': (json) => WsEventEditPrivateMessage(
const EditPrivateMessage(privateMessageId: 0, content: '', auth: '')
.responseFactory(json),
),
'DeletePrivateMessage': (json) => WsEventDeletePrivateMessage(
const DeletePrivateMessage(privateMessageId: 0, deleted: true, auth: '')
.responseFactory(json),
),
'MarkPrivateMessageAsRead': (json) => WsEventMarkPrivateMessageAsRead(
const MarkPrivateMessageAsRead(
privateMessageId: 0,
read: true,
auth: '',
).responseFactory(json),
),
'GetPrivateMessages': (json) => WsEventGetPrivateMessages(
const GetPrivateMessages(unreadOnly: true, auth: '')
.responseFactory(json),
),
'GetReportCount': (json) => WsEventGetReportCount(
const GetReportCount(auth: '').responseFactory(json),
),
'ResolveObject': (json) => WsEventResolveObject(
const ResolveObject(q: '').responseFactory(json),
),
'GetSiteMetadata': (json) => WsEventGetSiteMetadata(
const GetSiteMetadata(url: '').responseFactory(json),
),
'BlockPerson': (json) => WsEventBlockPerson(
const BlockPerson(personId: 0, block: true, auth: '')
.responseFactory(json),
),
'BlockCommunity': (json) => WsEventBlockCommunity(
const BlockCommunity(communityId: 0, block: true, auth: '')
.responseFactory(json),
),
'GetUnreadCount': (json) => WsEventGetUnreadCount(
const GetUnreadCount(auth: '').responseFactory(json),
),
'GetBannedPersons': (json) => WsEventGetBannedPersons(
const GetBannedPersons(auth: '').responseFactory(json),
),
'VerifyEmail': (json) => WsEventVerifyEmail(
const VerifyEmail(token: '').responseFactory(json),
),
'GetUnreadRegistrationApplicationCount': (json) =>
WsEventGetUnreadRegistrationApplicationCount(
const GetUnreadRegistrationApplicationCount(auth: '')
.responseFactory(json),
),
'ListRegistrationApplications': (json) => WsEventListRegistrationApplications(
const ListRegistrationApplications(auth: '').responseFactory(json),
),
'ApproveRegistrationApplication': (json) =>
WsEventApproveRegistrationApplication(
const ApproveRegistrationApplication(approve: true, id: 0, auth: '')
.responseFactory(json),
),
};