Skip to content

Commit 74681b3

Browse files
authored
fix: Add missing v1.instance.extendedDescription API (#1212)
1 parent a8e25be commit 74681b3

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Represents an extended description for the instance, to be shown on its about page.
3+
*/
4+
export interface ExtendedDescription {
5+
/** The rendered HTML content of the extended description. */
6+
content: string;
7+
/** A timestamp of when the extended description was last updated. */
8+
updatedAt?: string | null;
9+
}

src/mastodon/entities/v1/index.ts

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

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { type HttpMetaParams } from "../../../interfaces";
2-
import { type Activity, type Instance } from "../../entities/v1";
2+
import {
3+
type Activity,
4+
type ExtendedDescription,
5+
type Instance,
6+
} from "../../entities/v1";
37
import { type Paginator } from "../../paginator";
48

59
export interface InstanceRepository {
@@ -33,6 +37,13 @@ export interface InstanceRepository {
3337
list(meta?: HttpMetaParams): Promise<string[]>;
3438
};
3539

40+
extendedDescription: {
41+
/**
42+
* Obtain an extended description of this server
43+
*/
44+
fetch(meta?: HttpMetaParams): Promise<ExtendedDescription>;
45+
};
46+
3647
translationLanguages: {
3748
/** https://github.com/mastodon/mastodon/pull/24037 */
3849
list(meta?: HttpMetaParams): Promise<Record<string, string[]>>;

tests/rest/v1/instance.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ it("lists translatable languages", async () => {
2121
const languages = await client.rest.v1.instance.translationLanguages.list();
2222
expect(languages).toEqual(expect.any(Object));
2323
});
24+
25+
it("fetches extended description", async () => {
26+
await using client = await sessions.acquire();
27+
const description = await client.rest.v1.instance.extendedDescription.fetch();
28+
29+
expect(description).toEqual({
30+
content: "",
31+
// eslint-disable-next-line unicorn/no-null
32+
updatedAt: null,
33+
});
34+
});

0 commit comments

Comments
 (0)