Skip to content

Commit

Permalink
feat: Mastodon 4.2.0 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
neet committed Aug 10, 2023
1 parent c985d31 commit 88703ac
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/mastodon/entities/v1/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export interface Account {
followingCount: number;
/** Roles that have been granted to this account. */
roles: Pick<Role, "id" | "name" | "color">[]; // TODO: Create an entity when documentation is updated
/** https://github.com/mastodon/mastodon/pull/23591 */
memorial?: boolean | null;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/mastodon/entities/v1/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export interface List {
* `none` = Show replies to no one
*/
repliesPolicy: ListRepliesPolicy;
/** https://github.com/mastodon/mastodon/pull/22048/files */
isExclusive: boolean;
}
2 changes: 1 addition & 1 deletion src/mastodon/entities/v1/report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Account } from "./account";

export type ReportCategory = "spam" | "violation" | "other";
export type ReportCategory = "spam" | "violation" | "legal" | "other";

/**
* Reports filed against users and/or statuses, to be taken action on by moderators.
Expand Down
2 changes: 2 additions & 0 deletions src/mastodon/rest/v1/account-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface CreateAccountParams {
readonly locale: string;
/** Text that will be reviewed by moderators if registrations require manual approval. */
readonly reason?: string;
/** https://github.com/mastodon/mastodon/pull/25342 */
readonly timeZone?: string;
}

export interface UpdateCredentialsParams {
Expand Down
27 changes: 27 additions & 0 deletions src/mastodon/rest/v1/admin/trend-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ export interface TrendRepository {
* @see https://docs.joinmastodon.org/methods/admin/trends/#links
*/
list(meta?: HttpMetaParams): Paginator<TrendLink[]>;

/** https://github.com/mastodon/mastodon/pull/24257 */
$select(id: string): {
approve(meta?: HttpMetaParams): Promise<TrendLink>;
reject(meta?: HttpMetaParams): Promise<TrendLink>;
};

/** https://github.com/mastodon/mastodon/pull/24257 */
publishers: {
list(meta?: HttpMetaParams): Paginator<TrendLink[]>;
$select(id: string): {
approve(meta?: HttpMetaParams): Promise<TrendLink>;
reject(meta?: HttpMetaParams): Promise<TrendLink>;
};
};
};

statuses: {
Expand All @@ -17,6 +32,12 @@ export interface TrendRepository {
* @see https://docs.joinmastodon.org/methods/admin/trends/#statuses
*/
list(meta?: HttpMetaParams): Paginator<Status[]>;

/** https://github.com/mastodon/mastodon/pull/24257 */
$select(id: string): {
approve(meta?: HttpMetaParams): Promise<Status>;
reject(meta?: HttpMetaParams): Promise<Status>;
};
};

tags: {
Expand All @@ -25,5 +46,11 @@ export interface TrendRepository {
* @see https://docs.joinmastodon.org/methods/admin/trends/#tags
*/
list(meta?: HttpMetaParams): Paginator<Admin.Tag[]>;

/** https://github.com/mastodon/mastodon/pull/24257 */
$select(id: string): {
approve(meta?: HttpMetaParams): Promise<Admin.Tag>;
reject(meta?: HttpMetaParams): Promise<Admin.Tag>;
};
};
}
3 changes: 3 additions & 0 deletions src/mastodon/rest/v1/conversation-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ export interface ConversationRepository {
* @see https://docs.joinmastodon.org/methods/timelines/conversations/#post
*/
read(meta?: HttpMetaParams): Promise<Conversation>;

/** https://github.com/mastodon/mastodon/pull/25509 */
unread(meta?: HttpMetaParams): Promise<Conversation>;
};
}
10 changes: 10 additions & 0 deletions src/mastodon/rest/v1/instance-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ export interface InstanceRepository {
*/
list(meta?: HttpMetaParams): Paginator<Activity[]>;
};

languages: {
/** https://github.com/mastodon/mastodon/pull/24443 */
list(meta?: HttpMetaParams): Promise<string[]>;
};

translationLanguages: {
/** https://github.com/mastodon/mastodon/pull/24037 */
list(meta?: HttpMetaParams): Promise<Record<string, string[]>>;
};
}
2 changes: 2 additions & 0 deletions src/mastodon/rest/v1/report-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface ReportAccountParams {
readonly category?: ReportCategory | null;
/** must reference rules returned in GET /api/v1/instance */
readonly ruleIds?: readonly string[] | null;
/** https://github.com/mastodon/mastodon/pull/25866 */
readonly forwardToDomains?: readonly string[] | null;
}

export interface ReportRepository {
Expand Down
12 changes: 11 additions & 1 deletion tests/rest/v1/conversations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ describe("conversations", () => {
});

assert(conversation != undefined);
await alice.rest.v1.conversations.$select(conversation.id).read();

conversation = await alice.rest.v1.conversations
.$select(conversation.id)
.read();
expect(conversation.unread).toBe(false);

conversation = await alice.rest.v1.conversations
.$select(conversation.id)
.unread();
expect(conversation.unread).toBe(true);

await alice.rest.v1.conversations.$select(conversation.id).remove();
});
});
Expand Down
14 changes: 14 additions & 0 deletions tests/rest/v1/instance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@ it("lists peers", () => {
expect(peers).toEqual(expect.any(Array));
});
});

it("lists languages", () => {
return sessions.use(async (client) => {
const languages = await client.rest.v1.instance.languages.list();
expect(languages).toEqual(expect.any(Array));
});
});

it("lists translatable languages", () => {
return sessions.use(async (client) => {
const languages = await client.rest.v1.instance.translationLanguages.list();
expect(languages).toMatchInlineSnapshot();
});
});

0 comments on commit 88703ac

Please sign in to comment.