Making a few API v2 changes.

This commit is contained in:
Dessalines 2021-01-18 16:45:43 -05:00
parent fe1b1b4c1f
commit e4b54162a4
11 changed files with 54 additions and 86 deletions

View file

@ -16,8 +16,6 @@ import {
AddModToCommunityResponse, AddModToCommunityResponse,
BanFromCommunity, BanFromCommunity,
BanFromCommunityResponse, BanFromCommunityResponse,
CommunityJoin,
CommunityJoinResponse,
CommunityResponse, CommunityResponse,
CreateCommunity, CreateCommunity,
DeleteCommunity, DeleteCommunity,
@ -42,8 +40,6 @@ import {
GetPosts, GetPosts,
GetPostsResponse, GetPostsResponse,
LockPost, LockPost,
PostJoin,
PostJoinResponse,
PostResponse, PostResponse,
RemovePost, RemovePost,
SavePost, SavePost,
@ -94,8 +90,6 @@ import {
PrivateMessagesResponse, PrivateMessagesResponse,
Register, Register,
SaveUserSettings, SaveUserSettings,
UserJoin,
UserJoinResponse,
UserMentionResponse, UserMentionResponse,
} from './interfaces/api/user'; } from './interfaces/api/user';
@ -337,18 +331,6 @@ export class LemmyHttp {
return this.wrapper(HttpType.Get, '/user/followed_communities', form); 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> { async banUser(form: BanUser): Promise<BanUserResponse> {
return this.wrapper(HttpType.Post, '/user/ban', form); return this.wrapper(HttpType.Post, '/user/ban', form);
} }

View file

@ -10,7 +10,7 @@ export interface CreateComment {
export interface EditComment { export interface EditComment {
content: string; content: string;
edit_id: number; comment_id: number;
form_id?: string; form_id?: string;
auth: string; auth: string;
} }
@ -19,7 +19,7 @@ export interface EditComment {
* Only the creator can delete the comment. * Only the creator can delete the comment.
*/ */
export interface DeleteComment { export interface DeleteComment {
edit_id: number; comment_id: number;
deleted: boolean; deleted: boolean;
auth: string; auth: string;
} }
@ -28,7 +28,7 @@ export interface DeleteComment {
* Only a mod or admin can remove the comment. * Only a mod or admin can remove the comment.
*/ */
export interface RemoveComment { export interface RemoveComment {
edit_id: number; comment_id: number;
removed: boolean; removed: boolean;
reason?: string; reason?: string;
auth: string; auth: string;

View file

@ -73,7 +73,7 @@ export interface AddModToCommunityResponse {
* Only mods can edit a community. * Only mods can edit a community.
*/ */
export interface EditCommunity { export interface EditCommunity {
edit_id: number; community_id: number;
title: string; title: string;
description?: string; description?: string;
icon?: string; icon?: string;
@ -84,7 +84,7 @@ export interface EditCommunity {
} }
export interface DeleteCommunity { export interface DeleteCommunity {
edit_id: number; community_id: number;
deleted: boolean; deleted: boolean;
auth: string; auth: string;
} }
@ -93,7 +93,7 @@ export interface DeleteCommunity {
* Only admins can remove a community. * Only admins can remove a community.
*/ */
export interface RemoveCommunity { export interface RemoveCommunity {
edit_id: number; community_id: number;
removed: boolean; removed: boolean;
reason?: string; reason?: string;
expires?: number; expires?: number;
@ -119,22 +119,3 @@ export interface TransferCommunity {
user_id: number; user_id: number;
auth: string; 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;
}

View file

@ -3,3 +3,4 @@ export * from './community';
export * from './post'; export * from './post';
export * from './site'; export * from './site';
export * from './user'; export * from './user';
export * from './websocket';

View file

@ -61,7 +61,7 @@ export interface CreatePostLike {
} }
export interface EditPost { export interface EditPost {
edit_id: number; post_id: number;
name: string; name: string;
url?: string; url?: string;
body?: string; body?: string;
@ -70,7 +70,7 @@ export interface EditPost {
} }
export interface DeletePost { export interface DeletePost {
edit_id: number; post_id: number;
deleted: boolean; deleted: boolean;
auth: string; auth: string;
} }
@ -79,7 +79,7 @@ export interface DeletePost {
* Only admins and mods can remove a post. * Only admins and mods can remove a post.
*/ */
export interface RemovePost { export interface RemovePost {
edit_id: number; post_id: number;
removed: boolean; removed: boolean;
reason?: string; reason?: string;
auth: string; auth: string;
@ -89,7 +89,7 @@ export interface RemovePost {
* Only admins and mods can lock a post. * Only admins and mods can lock a post.
*/ */
export interface LockPost { export interface LockPost {
edit_id: number; post_id: number;
locked: boolean; locked: boolean;
auth: string; auth: string;
} }
@ -98,7 +98,7 @@ export interface LockPost {
* Only admins and mods can sticky a post. * Only admins and mods can sticky a post.
*/ */
export interface StickyPost { export interface StickyPost {
edit_id: number; post_id: number;
stickied: boolean; stickied: boolean;
auth: string; auth: string;
} }
@ -109,14 +109,6 @@ export interface SavePost {
auth: string; auth: string;
} }
export interface PostJoin {
post_id: number;
}
export interface PostJoinResponse {
joined: boolean;
}
export interface CreatePostReport { export interface CreatePostReport {
post_id: number; post_id: number;
reason: string; reason: string;

View file

@ -1,4 +1,4 @@
import { Category, User_ } from '../source'; import { Category, UserSafeSettings } from '../source';
import { import {
CommentView, CommentView,
CommunityView, CommunityView,
@ -99,7 +99,7 @@ export interface GetSiteResponse {
banned: UserViewSafe[]; banned: UserViewSafe[];
online: number; online: number;
version: string; 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[]; federated_instances: string[];
} }

View file

@ -5,7 +5,6 @@ import {
PostView, PostView,
PrivateMessageView, PrivateMessageView,
UserMentionView, UserMentionView,
UserViewDangerous,
UserViewSafe, UserViewSafe,
} from '../views'; } from '../views';
@ -22,7 +21,6 @@ export interface Register {
email?: string; email?: string;
password: string; password: string;
password_verify: string; password_verify: string;
admin: boolean;
show_nsfw: boolean; show_nsfw: boolean;
captcha_uuid?: string; // Only checked if these are enabled in the server captcha_uuid?: string; // Only checked if these are enabled in the server
captcha_answer?: string; captcha_answer?: string;
@ -82,8 +80,7 @@ export interface GetUserDetails {
} }
export interface GetUserDetailsResponse { export interface GetUserDetailsResponse {
user_view?: UserViewSafe; user_view: UserViewSafe;
user_view_dangerous?: UserViewDangerous;
follows: CommunityFollowerView[]; follows: CommunityFollowerView[];
moderates: CommunityModeratorView[]; moderates: CommunityModeratorView[];
comments: CommentView[]; comments: CommentView[];
@ -179,19 +176,19 @@ export interface CreatePrivateMessage {
} }
export interface EditPrivateMessage { export interface EditPrivateMessage {
edit_id: number; private_message_id: number;
content: string; content: string;
auth: string; auth: string;
} }
export interface DeletePrivateMessage { export interface DeletePrivateMessage {
edit_id: number; private_message_id: number;
deleted: boolean; deleted: boolean;
auth: string; auth: string;
} }
export interface MarkPrivateMessageAsRead { export interface MarkPrivateMessageAsRead {
edit_id: number; private_message_id: number;
read: boolean; read: boolean;
auth: string; auth: string;
} }
@ -211,14 +208,6 @@ export interface PrivateMessageResponse {
private_message_view: PrivateMessageView; 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. * If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
*/ */

View 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;
}

View file

@ -17,11 +17,10 @@ export interface UserSafe {
deleted: boolean; deleted: boolean;
} }
export interface User_ { export interface UserSafeSettings {
id: number; id: number;
name: string; name: string;
preferred_username?: string; preferred_username?: string;
password_encrypted: string;
email?: string; email?: string;
avatar?: string; avatar?: string;
admin: boolean; admin: boolean;
@ -39,8 +38,6 @@ export interface User_ {
actor_id: string; actor_id: string;
bio?: string; bio?: string;
local: boolean; local: boolean;
private_key?: string;
public_key?: string;
last_refreshed_at: string; last_refreshed_at: string;
banner?: string; banner?: string;
deleted: boolean; deleted: boolean;

View file

@ -25,7 +25,6 @@ import {
Site, Site,
UserMention, UserMention,
UserSafe, UserSafe,
User_,
} from './source'; } from './source';
export interface UserViewSafe { export interface UserViewSafe {
@ -33,11 +32,6 @@ export interface UserViewSafe {
counts: UserAggregates; counts: UserAggregates;
} }
export interface UserViewDangerous {
user: User_;
counts: UserAggregates;
}
export interface UserMentionView { export interface UserMentionView {
user_mention: UserMention; user_mention: UserMention;
comment: Comment; comment: Comment;

View file

@ -11,7 +11,6 @@ import {
import { import {
AddModToCommunity, AddModToCommunity,
BanFromCommunity, BanFromCommunity,
CommunityJoin,
CreateCommunity, CreateCommunity,
DeleteCommunity, DeleteCommunity,
EditCommunity, EditCommunity,
@ -30,7 +29,6 @@ import {
GetPost, GetPost,
GetPosts, GetPosts,
LockPost, LockPost,
PostJoin,
RemovePost, RemovePost,
SavePost, SavePost,
StickyPost, StickyPost,
@ -64,8 +62,8 @@ import {
PasswordReset, PasswordReset,
Register, Register,
SaveUserSettings, SaveUserSettings,
UserJoin,
} from './interfaces/api/user'; } from './interfaces/api/user';
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
import { UserOperation } from './interfaces/others'; import { UserOperation } from './interfaces/others';
export class LemmyWebsocket { export class LemmyWebsocket {