Skip to content

Commit 884b83d

Browse files
authored
fix: Add missing public domain block API (#1214)
1 parent d99a37a commit 884b83d

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Represents a domain that is blocked by the instance.
3+
*/
4+
export interface DomainBlock {
5+
/** The domain which is blocked. This may be obfuscated or partially censored. */
6+
domain: string;
7+
/** The SHA256 hash digest of the domain string. */
8+
digest: string;
9+
/** The level to which the domain is blocked. */
10+
severity: DomainBlockSeverity;
11+
/** An optional reason for the domain block. */
12+
comment?: string | null;
13+
}
14+
15+
export type DomainBlockSeverity = "silence" | "suspend";

src/mastodon/entities/v1/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from "./context";
77
export * from "./conversation";
88
export * from "./custom-emoji";
99
export * from "./extended-description";
10+
export * from "./domain-block";
1011
export * from "./familiar-followers";
1112
export * from "./featured-tags";
1213
export * from "./filter";

src/mastodon/rest/v1/instance-repository.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type HttpMetaParams } from "../../../interfaces";
22
import {
33
type Activity,
4+
type DomainBlock,
45
type ExtendedDescription,
56
type Instance,
67
} from "../../entities/v1";
@@ -48,4 +49,12 @@ export interface InstanceRepository {
4849
/** https://github.com/mastodon/mastodon/pull/24037 */
4950
list(meta?: HttpMetaParams): Promise<Record<string, string[]>>;
5051
};
52+
53+
domainBlocks: {
54+
/**
55+
* Obtain a list of domains that have been blocked.
56+
* @see https://docs.joinmastodon.org/methods/instance/#domain_blocks
57+
*/
58+
fetch(meta?: HttpMetaParams): Promise<DomainBlock[]>;
59+
};
5160
}

tests/rest/v1/instance.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ it("fetches extended description", async () => {
3232
updatedAt: null,
3333
});
3434
});
35+
36+
test.todo("lists domain blocks");
37+
// FIXME: domain blocks publicity setting can only be edited via the admin panel
38+
// it("lists domain blocks", async () => {
39+
// await using client = await sessions.acquire();
40+
// const blocks = await client.rest.v1.instance.domainBlocks.fetch();
41+
// expect(blocks).toEqual([]);
42+
// });

0 commit comments

Comments
 (0)