Adding block person and block community actions
This commit is contained in:
parent
3fc2a6c5e1
commit
c875ef9328
6 changed files with 99 additions and 0 deletions
27
src/http.ts
27
src/http.ts
|
@ -16,11 +16,14 @@ import {
|
||||||
AddModToCommunityResponse,
|
AddModToCommunityResponse,
|
||||||
BanFromCommunity,
|
BanFromCommunity,
|
||||||
BanFromCommunityResponse,
|
BanFromCommunityResponse,
|
||||||
|
BlockCommunity,
|
||||||
CommunityResponse,
|
CommunityResponse,
|
||||||
CreateCommunity,
|
CreateCommunity,
|
||||||
DeleteCommunity,
|
DeleteCommunity,
|
||||||
EditCommunity,
|
EditCommunity,
|
||||||
FollowCommunity,
|
FollowCommunity,
|
||||||
|
GetBlockedCommunities,
|
||||||
|
GetBlockedCommunitiesResponse,
|
||||||
GetCommunity,
|
GetCommunity,
|
||||||
GetCommunityResponse,
|
GetCommunityResponse,
|
||||||
GetFollowedCommunities,
|
GetFollowedCommunities,
|
||||||
|
@ -91,6 +94,10 @@ import {
|
||||||
SaveUserSettings,
|
SaveUserSettings,
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
PersonMentionResponse,
|
PersonMentionResponse,
|
||||||
|
GetBlockedPersonsResponse,
|
||||||
|
GetBlockedPersons,
|
||||||
|
BlockPerson,
|
||||||
|
BlockPersonResponse,
|
||||||
} from './interfaces/api/person';
|
} from './interfaces/api/person';
|
||||||
|
|
||||||
import { VERSION } from './interfaces/others';
|
import { VERSION } from './interfaces/others';
|
||||||
|
@ -172,6 +179,10 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Post, '/community/follow', form);
|
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> {
|
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/community/delete', form);
|
return this.wrapper(HttpType.Post, '/community/delete', form);
|
||||||
}
|
}
|
||||||
|
@ -320,6 +331,12 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Get, '/user/mention', form);
|
return this.wrapper(HttpType.Get, '/user/mention', form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getBlockedPersons(
|
||||||
|
form: GetBlockedPersons
|
||||||
|
): Promise<GetBlockedPersonsResponse> {
|
||||||
|
return this.wrapper(HttpType.Get, '/user/block', form);
|
||||||
|
}
|
||||||
|
|
||||||
async markPersonMentionAsRead(
|
async markPersonMentionAsRead(
|
||||||
form: MarkPersonMentionAsRead
|
form: MarkPersonMentionAsRead
|
||||||
): Promise<PersonMentionResponse> {
|
): Promise<PersonMentionResponse> {
|
||||||
|
@ -336,10 +353,20 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Get, '/user/followed_communities', form);
|
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> {
|
async banPerson(form: BanPerson): Promise<BanPersonResponse> {
|
||||||
return this.wrapper(HttpType.Post, '/user/ban', form);
|
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> {
|
async getCaptcha(): Promise<GetCaptchaResponse> {
|
||||||
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {
|
import {
|
||||||
CommunityFollowerView,
|
CommunityFollowerView,
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
|
CommunityBlockView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
PersonViewSafe,
|
PersonViewSafe,
|
||||||
} from '../views';
|
} from '../views';
|
||||||
|
@ -118,3 +119,17 @@ export interface TransferCommunity {
|
||||||
person_id: number;
|
person_id: number;
|
||||||
auth: string;
|
auth: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BlockCommunity {
|
||||||
|
community_id: number;
|
||||||
|
block: boolean;
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetBlockedCommunities {
|
||||||
|
auth: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetBlockedCommunitiesResponse {
|
||||||
|
communities: CommunityBlockView[];
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import {
|
||||||
PrivateMessageView,
|
PrivateMessageView,
|
||||||
PersonMentionView,
|
PersonMentionView,
|
||||||
PersonViewSafe,
|
PersonViewSafe,
|
||||||
|
CommunityBlockView,
|
||||||
|
PersonBlockView,
|
||||||
} from '../views';
|
} from '../views';
|
||||||
|
|
||||||
export interface Login {
|
export interface Login {
|
||||||
|
@ -90,6 +92,8 @@ export interface GetPersonDetails {
|
||||||
export interface GetPersonDetailsResponse {
|
export interface GetPersonDetailsResponse {
|
||||||
person_view: PersonViewSafe;
|
person_view: PersonViewSafe;
|
||||||
follows: CommunityFollowerView[];
|
follows: CommunityFollowerView[];
|
||||||
|
community_blocks: CommunityBlockView[];
|
||||||
|
person_blocks: PersonBlockView[];
|
||||||
moderates: CommunityModeratorView[];
|
moderates: CommunityModeratorView[];
|
||||||
comments: CommentView[];
|
comments: CommentView[];
|
||||||
posts: PostView[];
|
posts: PostView[];
|
||||||
|
@ -229,3 +233,22 @@ export interface GetReportCountResponse {
|
||||||
comment_reports: number;
|
comment_reports: number;
|
||||||
post_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[];
|
||||||
|
}
|
||||||
|
|
|
@ -64,6 +64,10 @@ export enum UserOperation {
|
||||||
PostJoin,
|
PostJoin,
|
||||||
CommunityJoin,
|
CommunityJoin,
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
|
BlockCommunity,
|
||||||
|
BlockPerson,
|
||||||
|
GetBlockedCommunities,
|
||||||
|
GetBlockedPersons,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SortType {
|
export enum SortType {
|
||||||
|
|
|
@ -175,6 +175,11 @@ export interface CommunityFollowerView {
|
||||||
follower: PersonSafe;
|
follower: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CommunityBlockView {
|
||||||
|
person: PersonSafe;
|
||||||
|
community: CommunitySafe;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CommunityModeratorView {
|
export interface CommunityModeratorView {
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@ -185,6 +190,11 @@ export interface CommunityPersonBanView {
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersonBlockView {
|
||||||
|
person: PersonSafe;
|
||||||
|
recipient: PersonSafe;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CommunityView {
|
export interface CommunityView {
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
|
|
|
@ -11,10 +11,12 @@ import {
|
||||||
import {
|
import {
|
||||||
AddModToCommunity,
|
AddModToCommunity,
|
||||||
BanFromCommunity,
|
BanFromCommunity,
|
||||||
|
BlockCommunity,
|
||||||
CreateCommunity,
|
CreateCommunity,
|
||||||
DeleteCommunity,
|
DeleteCommunity,
|
||||||
EditCommunity,
|
EditCommunity,
|
||||||
FollowCommunity,
|
FollowCommunity,
|
||||||
|
GetBlockedCommunities,
|
||||||
GetCommunity,
|
GetCommunity,
|
||||||
GetFollowedCommunities,
|
GetFollowedCommunities,
|
||||||
ListCommunities,
|
ListCommunities,
|
||||||
|
@ -63,6 +65,8 @@ import {
|
||||||
Register,
|
Register,
|
||||||
SaveUserSettings,
|
SaveUserSettings,
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
|
BlockPerson,
|
||||||
|
GetBlockedPersons,
|
||||||
} from './interfaces/api/person';
|
} from './interfaces/api/person';
|
||||||
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
||||||
import { UserOperation } from './interfaces/others';
|
import { UserOperation } from './interfaces/others';
|
||||||
|
@ -312,6 +316,22 @@ export class LemmyWebsocket {
|
||||||
saveSiteConfig(form: SaveSiteConfig) {
|
saveSiteConfig(form: SaveSiteConfig) {
|
||||||
return wrapper(UserOperation.SaveSiteConfig, form);
|
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) {
|
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||||
|
|
Loading…
Reference in a new issue