mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 12:21:12 +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,
|
AddModToCommunityResponse,
|
||||||
BanFromCommunity,
|
BanFromCommunity,
|
||||||
BanFromCommunityResponse,
|
BanFromCommunityResponse,
|
||||||
|
BlockCommunity,
|
||||||
|
BlockCommunityResponse,
|
||||||
CommunityResponse,
|
CommunityResponse,
|
||||||
CreateCommunity,
|
CreateCommunity,
|
||||||
DeleteCommunity,
|
DeleteCommunity,
|
||||||
|
@ -23,8 +25,6 @@ import {
|
||||||
FollowCommunity,
|
FollowCommunity,
|
||||||
GetCommunity,
|
GetCommunity,
|
||||||
GetCommunityResponse,
|
GetCommunityResponse,
|
||||||
GetFollowedCommunities,
|
|
||||||
GetFollowedCommunitiesResponse,
|
|
||||||
ListCommunities,
|
ListCommunities,
|
||||||
ListCommunitiesResponse,
|
ListCommunitiesResponse,
|
||||||
RemoveCommunity,
|
RemoveCommunity,
|
||||||
|
@ -93,6 +93,8 @@ import {
|
||||||
SaveUserSettings,
|
SaveUserSettings,
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
PersonMentionResponse,
|
PersonMentionResponse,
|
||||||
|
BlockPerson,
|
||||||
|
BlockPersonResponse,
|
||||||
} from './interfaces/api/person';
|
} from './interfaces/api/person';
|
||||||
|
|
||||||
import { VERSION } from './interfaces/others';
|
import { VERSION } from './interfaces/others';
|
||||||
|
@ -174,6 +176,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<BlockCommunityResponse> {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
@ -338,16 +344,14 @@ export class LemmyHttp {
|
||||||
return this.wrapper(HttpType.Get, '/user/replies', form);
|
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> {
|
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,5 +1,4 @@
|
||||||
import {
|
import {
|
||||||
CommunityFollowerView,
|
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
PersonViewSafe,
|
PersonViewSafe,
|
||||||
|
@ -105,16 +104,19 @@ export interface FollowCommunity {
|
||||||
auth: string;
|
auth: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetFollowedCommunities {
|
|
||||||
auth: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GetFollowedCommunitiesResponse {
|
|
||||||
communities: CommunityFollowerView[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransferCommunity {
|
export interface TransferCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
person_id: number;
|
person_id: number;
|
||||||
auth: string;
|
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,
|
PrivateMessageView,
|
||||||
PersonMentionView,
|
PersonMentionView,
|
||||||
PersonViewSafe,
|
PersonViewSafe,
|
||||||
|
CommunityBlockView,
|
||||||
|
PersonBlockView,
|
||||||
} from '../views';
|
} from '../views';
|
||||||
|
|
||||||
export interface Login {
|
export interface Login {
|
||||||
|
@ -90,10 +92,9 @@ export interface GetPersonDetails {
|
||||||
|
|
||||||
export interface GetPersonDetailsResponse {
|
export interface GetPersonDetailsResponse {
|
||||||
person_view: PersonViewSafe;
|
person_view: PersonViewSafe;
|
||||||
follows: CommunityFollowerView[];
|
|
||||||
moderates: CommunityModeratorView[];
|
|
||||||
comments: CommentView[];
|
comments: CommentView[];
|
||||||
posts: PostView[];
|
posts: PostView[];
|
||||||
|
moderates: CommunityModeratorView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetRepliesResponse {
|
export interface GetRepliesResponse {
|
||||||
|
@ -230,3 +231,14 @@ 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;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
import { LocalUserSettingsView } from '../views';
|
import {
|
||||||
|
CommunityBlockView,
|
||||||
|
CommunityFollowerView,
|
||||||
|
CommunityModeratorView,
|
||||||
|
LocalUserSettingsView,
|
||||||
|
PersonBlockView,
|
||||||
|
} from '../views';
|
||||||
import {
|
import {
|
||||||
CommentView,
|
CommentView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
|
@ -101,10 +107,18 @@ export interface GetSiteResponse {
|
||||||
banned: PersonViewSafe[];
|
banned: PersonViewSafe[];
|
||||||
online: number;
|
online: number;
|
||||||
version: string;
|
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;
|
federated_instances?: FederatedInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MyUserInfo {
|
||||||
|
local_user_view: LocalUserSettingsView;
|
||||||
|
follows: CommunityFollowerView[];
|
||||||
|
moderates: CommunityModeratorView[];
|
||||||
|
community_blocks: CommunityBlockView[];
|
||||||
|
person_blocks: PersonBlockView[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface TransferSite {
|
export interface TransferSite {
|
||||||
person_id: number;
|
person_id: number;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
|
@ -31,7 +31,6 @@ export enum UserOperation {
|
||||||
DeleteCommunity,
|
DeleteCommunity,
|
||||||
RemoveCommunity,
|
RemoveCommunity,
|
||||||
FollowCommunity,
|
FollowCommunity,
|
||||||
GetFollowedCommunities,
|
|
||||||
GetPersonDetails,
|
GetPersonDetails,
|
||||||
GetReplies,
|
GetReplies,
|
||||||
GetPersonMentions,
|
GetPersonMentions,
|
||||||
|
@ -65,6 +64,8 @@ export enum UserOperation {
|
||||||
CommunityJoin,
|
CommunityJoin,
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
GetSiteMetadata,
|
GetSiteMetadata,
|
||||||
|
BlockCommunity,
|
||||||
|
BlockPerson,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SortType {
|
export enum SortType {
|
||||||
|
|
|
@ -44,6 +44,7 @@ export interface PersonMentionView {
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
saved: boolean;
|
saved: boolean;
|
||||||
|
creator_blocked: boolean;
|
||||||
my_vote?: number;
|
my_vote?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ export interface PostView {
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
saved: boolean;
|
saved: boolean;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
|
creator_blocked: boolean;
|
||||||
my_vote?: number;
|
my_vote?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +98,7 @@ export interface CommentView {
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
saved: boolean;
|
saved: boolean;
|
||||||
|
creator_blocked: boolean;
|
||||||
my_vote?: number;
|
my_vote?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +186,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;
|
||||||
|
@ -193,8 +201,14 @@ export interface CommunityPersonBanView {
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PersonBlockView {
|
||||||
|
person: PersonSafe;
|
||||||
|
target: PersonSafe;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CommunityView {
|
export interface CommunityView {
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
|
blocked: boolean;
|
||||||
counts: CommunityAggregates;
|
counts: CommunityAggregates;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ import {
|
||||||
import {
|
import {
|
||||||
AddModToCommunity,
|
AddModToCommunity,
|
||||||
BanFromCommunity,
|
BanFromCommunity,
|
||||||
|
BlockCommunity,
|
||||||
CreateCommunity,
|
CreateCommunity,
|
||||||
DeleteCommunity,
|
DeleteCommunity,
|
||||||
EditCommunity,
|
EditCommunity,
|
||||||
FollowCommunity,
|
FollowCommunity,
|
||||||
GetCommunity,
|
GetCommunity,
|
||||||
GetFollowedCommunities,
|
|
||||||
ListCommunities,
|
ListCommunities,
|
||||||
RemoveCommunity,
|
RemoveCommunity,
|
||||||
TransferCommunity,
|
TransferCommunity,
|
||||||
|
@ -64,6 +64,7 @@ import {
|
||||||
Register,
|
Register,
|
||||||
SaveUserSettings,
|
SaveUserSettings,
|
||||||
ChangePassword,
|
ChangePassword,
|
||||||
|
BlockPerson,
|
||||||
} 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';
|
||||||
|
@ -122,10 +123,6 @@ export class LemmyWebsocket {
|
||||||
return wrapper(UserOperation.ListCommunities, form);
|
return wrapper(UserOperation.ListCommunities, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFollowedCommunities(form: GetFollowedCommunities) {
|
|
||||||
return wrapper(UserOperation.GetFollowedCommunities, form);
|
|
||||||
}
|
|
||||||
|
|
||||||
createPost(form: CreatePost) {
|
createPost(form: CreatePost) {
|
||||||
return wrapper(UserOperation.CreatePost, form);
|
return wrapper(UserOperation.CreatePost, form);
|
||||||
}
|
}
|
||||||
|
@ -317,6 +314,14 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockCommunity(form: BlockCommunity) {
|
||||||
|
return wrapper(UserOperation.BlockCommunity, form);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||||
|
|
Loading…
Reference in a new issue