mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-25 13:51:12 +00:00
Making a few API v2 changes.
This commit is contained in:
parent
fe1b1b4c1f
commit
e4b54162a4
11 changed files with 54 additions and 86 deletions
18
src/http.ts
18
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<UserJoinResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/join', form);
|
||||
}
|
||||
|
||||
async postJoin(form: PostJoin): Promise<PostJoinResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/join', form);
|
||||
}
|
||||
|
||||
async communityJoin(form: CommunityJoin): Promise<CommunityJoinResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/join', form);
|
||||
}
|
||||
|
||||
async banUser(form: BanUser): Promise<BanUserResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/ban', form);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3,3 +3,4 @@ export * from './community';
|
|||
export * from './post';
|
||||
export * from './site';
|
||||
export * from './user';
|
||||
export * from './websocket';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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[];
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
34
src/interfaces/api/websocket.ts
Normal file
34
src/interfaces/api/websocket.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
export interface UserJoin {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface UserJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main / frontpage community is `community_id: 0`.
|
||||
*/
|
||||
export interface CommunityJoin {
|
||||
community_id: number;
|
||||
}
|
||||
|
||||
export interface CommunityJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
||||
|
||||
export interface ModJoin {
|
||||
community_id: number;
|
||||
}
|
||||
|
||||
export interface ModJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
||||
|
||||
export interface PostJoin {
|
||||
post_id: number;
|
||||
}
|
||||
|
||||
export interface PostJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue