diff --git a/src/http.ts b/src/http.ts index be1abf9..3a542ee 100644 --- a/src/http.ts +++ b/src/http.ts @@ -16,8 +16,6 @@ import { AddModToCommunityResponse, BanFromCommunity, BanFromCommunityResponse, - CommunityJoin, - CommunityJoinResponse, CommunityResponse, CreateCommunity, DeleteCommunity, @@ -42,8 +40,6 @@ import { GetPosts, GetPostsResponse, LockPost, - PostJoin, - PostJoinResponse, PostResponse, RemovePost, SavePost, @@ -94,8 +90,6 @@ import { PrivateMessagesResponse, Register, SaveUserSettings, - UserJoin, - UserJoinResponse, UserMentionResponse, } from './interfaces/api/user'; @@ -337,18 +331,6 @@ export class LemmyHttp { return this.wrapper(HttpType.Get, '/user/followed_communities', form); } - async userJoin(form: UserJoin): Promise { - return this.wrapper(HttpType.Post, '/user/join', form); - } - - async postJoin(form: PostJoin): Promise { - return this.wrapper(HttpType.Post, '/post/join', form); - } - - async communityJoin(form: CommunityJoin): Promise { - return this.wrapper(HttpType.Post, '/community/join', form); - } - async banUser(form: BanUser): Promise { return this.wrapper(HttpType.Post, '/user/ban', form); } diff --git a/src/interfaces/api/comment.ts b/src/interfaces/api/comment.ts index e1769a8..cc21ce0 100644 --- a/src/interfaces/api/comment.ts +++ b/src/interfaces/api/comment.ts @@ -10,7 +10,7 @@ export interface CreateComment { export interface EditComment { content: string; - edit_id: number; + comment_id: number; form_id?: string; auth: string; } @@ -19,7 +19,7 @@ export interface EditComment { * Only the creator can delete the comment. */ export interface DeleteComment { - edit_id: number; + comment_id: number; deleted: boolean; auth: string; } @@ -28,7 +28,7 @@ export interface DeleteComment { * Only a mod or admin can remove the comment. */ export interface RemoveComment { - edit_id: number; + comment_id: number; removed: boolean; reason?: string; auth: string; diff --git a/src/interfaces/api/community.ts b/src/interfaces/api/community.ts index 78dc3ee..f7844fe 100644 --- a/src/interfaces/api/community.ts +++ b/src/interfaces/api/community.ts @@ -73,7 +73,7 @@ export interface AddModToCommunityResponse { * Only mods can edit a community. */ export interface EditCommunity { - edit_id: number; + community_id: number; title: string; description?: string; icon?: string; @@ -84,7 +84,7 @@ export interface EditCommunity { } export interface DeleteCommunity { - edit_id: number; + community_id: number; deleted: boolean; auth: string; } @@ -93,7 +93,7 @@ export interface DeleteCommunity { * Only admins can remove a community. */ export interface RemoveCommunity { - edit_id: number; + community_id: number; removed: boolean; reason?: string; expires?: number; @@ -119,22 +119,3 @@ export interface TransferCommunity { user_id: number; auth: string; } - -/** - * The main / frontpage community is `community_id: 0`. - */ -export interface CommunityJoin { - community_id: number; -} - -export interface CommunityJoinResponse { - joined: boolean; -} - -export interface ModJoin { - community_id: number; -} - -export interface ModJoinResponse { - joined: boolean; -} diff --git a/src/interfaces/api/index.ts b/src/interfaces/api/index.ts index e7b34ae..673bc8d 100644 --- a/src/interfaces/api/index.ts +++ b/src/interfaces/api/index.ts @@ -3,3 +3,4 @@ export * from './community'; export * from './post'; export * from './site'; export * from './user'; +export * from './websocket'; diff --git a/src/interfaces/api/post.ts b/src/interfaces/api/post.ts index 1863f49..11b4b85 100644 --- a/src/interfaces/api/post.ts +++ b/src/interfaces/api/post.ts @@ -61,7 +61,7 @@ export interface CreatePostLike { } export interface EditPost { - edit_id: number; + post_id: number; name: string; url?: string; body?: string; @@ -70,7 +70,7 @@ export interface EditPost { } export interface DeletePost { - edit_id: number; + post_id: number; deleted: boolean; auth: string; } @@ -79,7 +79,7 @@ export interface DeletePost { * Only admins and mods can remove a post. */ export interface RemovePost { - edit_id: number; + post_id: number; removed: boolean; reason?: string; auth: string; @@ -89,7 +89,7 @@ export interface RemovePost { * Only admins and mods can lock a post. */ export interface LockPost { - edit_id: number; + post_id: number; locked: boolean; auth: string; } @@ -98,7 +98,7 @@ export interface LockPost { * Only admins and mods can sticky a post. */ export interface StickyPost { - edit_id: number; + post_id: number; stickied: boolean; auth: string; } @@ -109,14 +109,6 @@ export interface SavePost { auth: string; } -export interface PostJoin { - post_id: number; -} - -export interface PostJoinResponse { - joined: boolean; -} - export interface CreatePostReport { post_id: number; reason: string; diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index 11db1ef..26428c8 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -1,4 +1,4 @@ -import { Category, User_ } from '../source'; +import { Category, UserSafeSettings } from '../source'; import { CommentView, CommunityView, @@ -99,7 +99,7 @@ export interface GetSiteResponse { banned: UserViewSafe[]; online: number; version: string; - my_user?: User_; // Gives back your user and settings if logged in + my_user?: UserSafeSettings; // Gives back your user and settings if logged in federated_instances: string[]; } diff --git a/src/interfaces/api/user.ts b/src/interfaces/api/user.ts index 1607e25..2f7c8d0 100644 --- a/src/interfaces/api/user.ts +++ b/src/interfaces/api/user.ts @@ -5,7 +5,6 @@ import { PostView, PrivateMessageView, UserMentionView, - UserViewDangerous, UserViewSafe, } from '../views'; @@ -22,7 +21,6 @@ export interface Register { email?: string; password: string; password_verify: string; - admin: boolean; show_nsfw: boolean; captcha_uuid?: string; // Only checked if these are enabled in the server captcha_answer?: string; @@ -82,8 +80,7 @@ export interface GetUserDetails { } export interface GetUserDetailsResponse { - user_view?: UserViewSafe; - user_view_dangerous?: UserViewDangerous; + user_view: UserViewSafe; follows: CommunityFollowerView[]; moderates: CommunityModeratorView[]; comments: CommentView[]; @@ -179,19 +176,19 @@ export interface CreatePrivateMessage { } export interface EditPrivateMessage { - edit_id: number; + private_message_id: number; content: string; auth: string; } export interface DeletePrivateMessage { - edit_id: number; + private_message_id: number; deleted: boolean; auth: string; } export interface MarkPrivateMessageAsRead { - edit_id: number; + private_message_id: number; read: boolean; auth: string; } @@ -211,14 +208,6 @@ export interface PrivateMessageResponse { private_message_view: PrivateMessageView; } -export interface UserJoin { - auth: string; -} - -export interface UserJoinResponse { - joined: boolean; -} - /** * If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates. */ diff --git a/src/interfaces/api/websocket.ts b/src/interfaces/api/websocket.ts new file mode 100644 index 0000000..72c88d3 --- /dev/null +++ b/src/interfaces/api/websocket.ts @@ -0,0 +1,34 @@ +export interface UserJoin { + auth: string; +} + +export interface UserJoinResponse { + joined: boolean; +} + +/** + * The main / frontpage community is `community_id: 0`. + */ +export interface CommunityJoin { + community_id: number; +} + +export interface CommunityJoinResponse { + joined: boolean; +} + +export interface ModJoin { + community_id: number; +} + +export interface ModJoinResponse { + joined: boolean; +} + +export interface PostJoin { + post_id: number; +} + +export interface PostJoinResponse { + joined: boolean; +} diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 9b37c58..67acb15 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -17,11 +17,10 @@ export interface UserSafe { deleted: boolean; } -export interface User_ { +export interface UserSafeSettings { id: number; name: string; preferred_username?: string; - password_encrypted: string; email?: string; avatar?: string; admin: boolean; @@ -39,8 +38,6 @@ export interface User_ { actor_id: string; bio?: string; local: boolean; - private_key?: string; - public_key?: string; last_refreshed_at: string; banner?: string; deleted: boolean; diff --git a/src/interfaces/views.ts b/src/interfaces/views.ts index 814ab89..4dd81dc 100644 --- a/src/interfaces/views.ts +++ b/src/interfaces/views.ts @@ -25,7 +25,6 @@ import { Site, UserMention, UserSafe, - User_, } from './source'; export interface UserViewSafe { @@ -33,11 +32,6 @@ export interface UserViewSafe { counts: UserAggregates; } -export interface UserViewDangerous { - user: User_; - counts: UserAggregates; -} - export interface UserMentionView { user_mention: UserMention; comment: Comment; diff --git a/src/websocket.ts b/src/websocket.ts index 4b74895..c792c72 100644 --- a/src/websocket.ts +++ b/src/websocket.ts @@ -11,7 +11,6 @@ import { import { AddModToCommunity, BanFromCommunity, - CommunityJoin, CreateCommunity, DeleteCommunity, EditCommunity, @@ -30,7 +29,6 @@ import { GetPost, GetPosts, LockPost, - PostJoin, RemovePost, SavePost, StickyPost, @@ -64,8 +62,8 @@ import { PasswordReset, Register, SaveUserSettings, - UserJoin, } from './interfaces/api/user'; +import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket'; import { UserOperation } from './interfaces/others'; export class LemmyWebsocket {