mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 12:05:53 +00:00
feat: blocking api interfaces
This commit is contained in:
@@ -24,6 +24,8 @@ import { LabrinthAttributionInternalModule } from './labrinth/attribution/intern
|
||||
import { LabrinthAuthInternalModule } from './labrinth/auth/internal'
|
||||
import { LabrinthAuthV2Module } from './labrinth/auth/v2'
|
||||
import { LabrinthBillingInternalModule } from './labrinth/billing/internal'
|
||||
import { LabrinthBlockedUsersInternalModule } from './labrinth/blocked-users/internal'
|
||||
import { LabrinthBlockedUsersV3Module } from './labrinth/blocked-users/v3'
|
||||
import { LabrinthCampaignInternalModule } from './labrinth/campaign/internal'
|
||||
import { LabrinthCollectionsModule } from './labrinth/collections'
|
||||
import { LabrinthContentV3Module } from './labrinth/content/v3'
|
||||
@@ -100,6 +102,8 @@ export const MODULE_REGISTRY = {
|
||||
labrinth_auth_v2: LabrinthAuthV2Module,
|
||||
labrinth_attribution_internal: LabrinthAttributionInternalModule,
|
||||
labrinth_billing_internal: LabrinthBillingInternalModule,
|
||||
labrinth_blocked_users_internal: LabrinthBlockedUsersInternalModule,
|
||||
labrinth_blocked_users_v3: LabrinthBlockedUsersV3Module,
|
||||
labrinth_campaign_internal: LabrinthCampaignInternalModule,
|
||||
labrinth_collections: LabrinthCollectionsModule,
|
||||
labrinth_content_v3: LabrinthContentV3Module,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { AbstractModule } from '../../../core/abstract-module'
|
||||
import type { Labrinth } from '../types'
|
||||
|
||||
export class LabrinthBlockedUsersInternalModule extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
return 'labrinth_blocked_users_internal'
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether one user has blocked another.
|
||||
*/
|
||||
public async getStatus(
|
||||
userId: string,
|
||||
targetId: string,
|
||||
): Promise<Labrinth.BlockedUsers.Internal.BlockStatus> {
|
||||
return this.client.request<Labrinth.BlockedUsers.Internal.BlockStatus>(
|
||||
`/block/${encodeURIComponent(userId)}/${encodeURIComponent(targetId)}`,
|
||||
{
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
method: 'GET',
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { AbstractModule } from '../../../core/abstract-module'
|
||||
import type { Labrinth } from '../types'
|
||||
|
||||
export class LabrinthBlockedUsersV3Module extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
return 'labrinth_blocked_users_v3'
|
||||
}
|
||||
|
||||
/**
|
||||
* List the users blocked by the authenticated user.
|
||||
*/
|
||||
public async list(): Promise<Labrinth.BlockedUsers.v3.BlockedUserId[]> {
|
||||
return this.client.request<Labrinth.BlockedUsers.v3.BlockedUserId[]>('/blocks', {
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a user.
|
||||
*
|
||||
* @param idOrUsername - The target user's ID or username
|
||||
*/
|
||||
public async block(idOrUsername: string): Promise<void> {
|
||||
return this.client.request(`/block/${encodeURIComponent(idOrUsername)}`, {
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblock a user.
|
||||
*
|
||||
* @param idOrUsername - The target user's ID or username
|
||||
*/
|
||||
public async unblock(idOrUsername: string): Promise<void> {
|
||||
return this.client.request(`/block/${encodeURIComponent(idOrUsername)}`, {
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1691,6 +1691,18 @@ export namespace Labrinth {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace BlockedUsers {
|
||||
export namespace Internal {
|
||||
export type BlockStatus = {
|
||||
blocked: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export namespace v3 {
|
||||
export type BlockedUserId = string
|
||||
}
|
||||
}
|
||||
|
||||
export namespace ServerPing {
|
||||
export namespace Internal {
|
||||
export type MinecraftJavaPingRequest = {
|
||||
|
||||
Reference in New Issue
Block a user