Adding block person and block community actions

This commit is contained in:
Dessalines 2021-05-09 22:33:18 -04:00
parent 3fc2a6c5e1
commit c875ef9328
6 changed files with 99 additions and 0 deletions

View file

@ -16,11 +16,14 @@ import {
AddModToCommunityResponse,
BanFromCommunity,
BanFromCommunityResponse,
BlockCommunity,
CommunityResponse,
CreateCommunity,
DeleteCommunity,
EditCommunity,
FollowCommunity,
GetBlockedCommunities,
GetBlockedCommunitiesResponse,
GetCommunity,
GetCommunityResponse,
GetFollowedCommunities,
@ -91,6 +94,10 @@ import {
SaveUserSettings,
ChangePassword,
PersonMentionResponse,
GetBlockedPersonsResponse,
GetBlockedPersons,
BlockPerson,
BlockPersonResponse,
} from './interfaces/api/person';
import { VERSION } from './interfaces/others';
@ -172,6 +179,10 @@ export class LemmyHttp {
return this.wrapper(HttpType.Post, '/community/follow', form);
}
async blockCommunity(form: BlockCommunity): Promise<CommunityResponse> {
return this.wrapper(HttpType.Post, '/community/block', form);
}
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> {
return this.wrapper(HttpType.Post, '/community/delete', form);
}
@ -320,6 +331,12 @@ export class LemmyHttp {
return this.wrapper(HttpType.Get, '/user/mention', form);
}
async getBlockedPersons(
form: GetBlockedPersons
): Promise<GetBlockedPersonsResponse> {
return this.wrapper(HttpType.Get, '/user/block', form);
}
async markPersonMentionAsRead(
form: MarkPersonMentionAsRead
): Promise<PersonMentionResponse> {
@ -336,10 +353,20 @@ export class LemmyHttp {
return this.wrapper(HttpType.Get, '/user/followed_communities', form);
}
async getBlockedCommunities(
form: GetBlockedCommunities
): Promise<GetBlockedCommunitiesResponse> {
return this.wrapper(HttpType.Get, '/user/blocked_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', {});
}

View file

@ -1,6 +1,7 @@
import {
CommunityFollowerView,
CommunityModeratorView,
CommunityBlockView,
CommunityView,
PersonViewSafe,
} from '../views';
@ -118,3 +119,17 @@ export interface TransferCommunity {
person_id: number;
auth: string;
}
export interface BlockCommunity {
community_id: number;
block: boolean;
auth: string;
}
export interface GetBlockedCommunities {
auth: string;
}
export interface GetBlockedCommunitiesResponse {
communities: CommunityBlockView[];
}

View file

@ -6,6 +6,8 @@ import {
PrivateMessageView,
PersonMentionView,
PersonViewSafe,
CommunityBlockView,
PersonBlockView,
} from '../views';
export interface Login {
@ -90,6 +92,8 @@ export interface GetPersonDetails {
export interface GetPersonDetailsResponse {
person_view: PersonViewSafe;
follows: CommunityFollowerView[];
community_blocks: CommunityBlockView[];
person_blocks: PersonBlockView[];
moderates: CommunityModeratorView[];
comments: CommentView[];
posts: PostView[];
@ -229,3 +233,22 @@ 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;
}
export interface GetBlockedPersons {
auth: string;
}
export interface GetBlockedPersonsResponse {
persons: PersonBlockView[];
}

View file

@ -64,6 +64,10 @@ export enum UserOperation {
PostJoin,
CommunityJoin,
ChangePassword,
BlockCommunity,
BlockPerson,
GetBlockedCommunities,
GetBlockedPersons,
}
export enum SortType {

View file

@ -175,6 +175,11 @@ export interface CommunityFollowerView {
follower: PersonSafe;
}
export interface CommunityBlockView {
person: PersonSafe;
community: CommunitySafe;
}
export interface CommunityModeratorView {
community: CommunitySafe;
moderator: PersonSafe;
@ -185,6 +190,11 @@ export interface CommunityPersonBanView {
person: PersonSafe;
}
export interface PersonBlockView {
person: PersonSafe;
recipient: PersonSafe;
}
export interface CommunityView {
community: CommunitySafe;
subscribed: boolean;

View file

@ -11,10 +11,12 @@ import {
import {
AddModToCommunity,
BanFromCommunity,
BlockCommunity,
CreateCommunity,
DeleteCommunity,
EditCommunity,
FollowCommunity,
GetBlockedCommunities,
GetCommunity,
GetFollowedCommunities,
ListCommunities,
@ -63,6 +65,8 @@ import {
Register,
SaveUserSettings,
ChangePassword,
BlockPerson,
GetBlockedPersons,
} from './interfaces/api/person';
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
import { UserOperation } from './interfaces/others';
@ -312,6 +316,22 @@ export class LemmyWebsocket {
saveSiteConfig(form: SaveSiteConfig) {
return wrapper(UserOperation.SaveSiteConfig, form);
}
blockPerson(form: BlockPerson) {
return wrapper(UserOperation.BlockPerson, form);
}
getBlockedPersons(form: GetBlockedPersons) {
return wrapper(UserOperation.GetBlockedPersons, form);
}
blockCommunity(form: BlockCommunity) {
return wrapper(UserOperation.BlockCommunity, form);
}
getBlockedCommunities(form: GetBlockedCommunities) {
return wrapper(UserOperation.GetBlockedCommunities, form);
}
}
function wrapper<MessageType>(op: UserOperation, data: MessageType) {