mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-10-31 17:49:55 +00:00
Adding block person and block community actions (#22)
* Adding block person and block community actions * Forgot creator_blocked from views * Adding creator_blocked to PersonMentionView * Moving blocked and follows to MyUserInfo * Change to local_user_view * Add moderates to MyUserInfo * Adding blockcommunityresponse * rename recipient to target
This commit is contained in:
parent
1ce122e4be
commit
a0b3f7606b
7 changed files with 79 additions and 27 deletions
20
src/http.ts
20
src/http.ts
|
@ -16,6 +16,8 @@ import {
|
|||
AddModToCommunityResponse,
|
||||
BanFromCommunity,
|
||||
BanFromCommunityResponse,
|
||||
BlockCommunity,
|
||||
BlockCommunityResponse,
|
||||
CommunityResponse,
|
||||
CreateCommunity,
|
||||
DeleteCommunity,
|
||||
|
@ -23,8 +25,6 @@ import {
|
|||
FollowCommunity,
|
||||
GetCommunity,
|
||||
GetCommunityResponse,
|
||||
GetFollowedCommunities,
|
||||
GetFollowedCommunitiesResponse,
|
||||
ListCommunities,
|
||||
ListCommunitiesResponse,
|
||||
RemoveCommunity,
|
||||
|
@ -93,6 +93,8 @@ import {
|
|||
SaveUserSettings,
|
||||
ChangePassword,
|
||||
PersonMentionResponse,
|
||||
BlockPerson,
|
||||
BlockPersonResponse,
|
||||
} from './interfaces/api/person';
|
||||
|
||||
import { VERSION } from './interfaces/others';
|
||||
|
@ -174,6 +176,10 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Post, '/community/follow', form);
|
||||
}
|
||||
|
||||
async blockCommunity(form: BlockCommunity): Promise<BlockCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/block', form);
|
||||
}
|
||||
|
||||
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/delete', form);
|
||||
}
|
||||
|
@ -338,16 +344,14 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Get, '/user/replies', form);
|
||||
}
|
||||
|
||||
async getFollowedCommunities(
|
||||
form: GetFollowedCommunities
|
||||
): Promise<GetFollowedCommunitiesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/followed_communities', form);
|
||||
}
|
||||
|
||||
async banPerson(form: BanPerson): Promise<BanPersonResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/ban', form);
|
||||
}
|
||||
|
||||
async blockPerson(form: BlockPerson): Promise<BlockPersonResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/block', form);
|
||||
}
|
||||
|
||||
async getCaptcha(): Promise<GetCaptchaResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import {
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
PersonViewSafe,
|
||||
|
@ -105,16 +104,19 @@ export interface FollowCommunity {
|
|||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetFollowedCommunities {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetFollowedCommunitiesResponse {
|
||||
communities: CommunityFollowerView[];
|
||||
}
|
||||
|
||||
export interface TransferCommunity {
|
||||
community_id: number;
|
||||
person_id: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface BlockCommunity {
|
||||
community_id: number;
|
||||
block: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface BlockCommunityResponse {
|
||||
community_view: CommunityView;
|
||||
blocked: boolean;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import {
|
|||
PrivateMessageView,
|
||||
PersonMentionView,
|
||||
PersonViewSafe,
|
||||
CommunityBlockView,
|
||||
PersonBlockView,
|
||||
} from '../views';
|
||||
|
||||
export interface Login {
|
||||
|
@ -90,10 +92,9 @@ export interface GetPersonDetails {
|
|||
|
||||
export interface GetPersonDetailsResponse {
|
||||
person_view: PersonViewSafe;
|
||||
follows: CommunityFollowerView[];
|
||||
moderates: CommunityModeratorView[];
|
||||
comments: CommentView[];
|
||||
posts: PostView[];
|
||||
moderates: CommunityModeratorView[];
|
||||
}
|
||||
|
||||
export interface GetRepliesResponse {
|
||||
|
@ -230,3 +231,14 @@ export interface GetReportCountResponse {
|
|||
comment_reports: number;
|
||||
post_reports: number;
|
||||
}
|
||||
|
||||
export interface BlockPerson {
|
||||
person_id: number;
|
||||
block: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface BlockPersonResponse {
|
||||
person_view: PersonViewSafe;
|
||||
blocked: boolean;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import { LocalUserSettingsView } from '../views';
|
||||
import {
|
||||
CommunityBlockView,
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
LocalUserSettingsView,
|
||||
PersonBlockView,
|
||||
} from '../views';
|
||||
import {
|
||||
CommentView,
|
||||
CommunityView,
|
||||
|
@ -101,10 +107,18 @@ export interface GetSiteResponse {
|
|||
banned: PersonViewSafe[];
|
||||
online: number;
|
||||
version: string;
|
||||
my_user?: LocalUserSettingsView; // Gives back your local user and settings if logged in
|
||||
my_user?: MyUserInfo; // Gives back your local user, settings, follows, and blocks if logged in
|
||||
federated_instances?: FederatedInstances;
|
||||
}
|
||||
|
||||
export interface MyUserInfo {
|
||||
local_user_view: LocalUserSettingsView;
|
||||
follows: CommunityFollowerView[];
|
||||
moderates: CommunityModeratorView[];
|
||||
community_blocks: CommunityBlockView[];
|
||||
person_blocks: PersonBlockView[];
|
||||
}
|
||||
|
||||
export interface TransferSite {
|
||||
person_id: number;
|
||||
auth: string;
|
||||
|
|
|
@ -31,7 +31,6 @@ export enum UserOperation {
|
|||
DeleteCommunity,
|
||||
RemoveCommunity,
|
||||
FollowCommunity,
|
||||
GetFollowedCommunities,
|
||||
GetPersonDetails,
|
||||
GetReplies,
|
||||
GetPersonMentions,
|
||||
|
@ -65,6 +64,8 @@ export enum UserOperation {
|
|||
CommunityJoin,
|
||||
ChangePassword,
|
||||
GetSiteMetadata,
|
||||
BlockCommunity,
|
||||
BlockPerson,
|
||||
}
|
||||
|
||||
export enum SortType {
|
||||
|
|
|
@ -44,6 +44,7 @@ export interface PersonMentionView {
|
|||
creator_banned_from_community: boolean;
|
||||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
creator_blocked: boolean;
|
||||
my_vote?: number;
|
||||
}
|
||||
|
||||
|
@ -74,6 +75,7 @@ export interface PostView {
|
|||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
read: boolean;
|
||||
creator_blocked: boolean;
|
||||
my_vote?: number;
|
||||
}
|
||||
|
||||
|
@ -96,6 +98,7 @@ export interface CommentView {
|
|||
creator_banned_from_community: boolean;
|
||||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
creator_blocked: boolean;
|
||||
my_vote?: number;
|
||||
}
|
||||
|
||||
|
@ -183,6 +186,11 @@ export interface CommunityFollowerView {
|
|||
follower: PersonSafe;
|
||||
}
|
||||
|
||||
export interface CommunityBlockView {
|
||||
person: PersonSafe;
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface CommunityModeratorView {
|
||||
community: CommunitySafe;
|
||||
moderator: PersonSafe;
|
||||
|
@ -193,8 +201,14 @@ export interface CommunityPersonBanView {
|
|||
person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface PersonBlockView {
|
||||
person: PersonSafe;
|
||||
target: PersonSafe;
|
||||
}
|
||||
|
||||
export interface CommunityView {
|
||||
community: CommunitySafe;
|
||||
subscribed: boolean;
|
||||
blocked: boolean;
|
||||
counts: CommunityAggregates;
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ import {
|
|||
import {
|
||||
AddModToCommunity,
|
||||
BanFromCommunity,
|
||||
BlockCommunity,
|
||||
CreateCommunity,
|
||||
DeleteCommunity,
|
||||
EditCommunity,
|
||||
FollowCommunity,
|
||||
GetCommunity,
|
||||
GetFollowedCommunities,
|
||||
ListCommunities,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
|
@ -64,6 +64,7 @@ import {
|
|||
Register,
|
||||
SaveUserSettings,
|
||||
ChangePassword,
|
||||
BlockPerson,
|
||||
} from './interfaces/api/person';
|
||||
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
||||
import { UserOperation } from './interfaces/others';
|
||||
|
@ -122,10 +123,6 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.ListCommunities, form);
|
||||
}
|
||||
|
||||
getFollowedCommunities(form: GetFollowedCommunities) {
|
||||
return wrapper(UserOperation.GetFollowedCommunities, form);
|
||||
}
|
||||
|
||||
createPost(form: CreatePost) {
|
||||
return wrapper(UserOperation.CreatePost, form);
|
||||
}
|
||||
|
@ -317,6 +314,14 @@ export class LemmyWebsocket {
|
|||
saveSiteConfig(form: SaveSiteConfig) {
|
||||
return wrapper(UserOperation.SaveSiteConfig, form);
|
||||
}
|
||||
|
||||
blockPerson(form: BlockPerson) {
|
||||
return wrapper(UserOperation.BlockPerson, form);
|
||||
}
|
||||
|
||||
blockCommunity(form: BlockCommunity) {
|
||||
return wrapper(UserOperation.BlockCommunity, form);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||
|
|
Loading…
Reference in a new issue