1
0
Fork 1
mirror of https://example.com synced 2024-11-27 16:26:46 +09:00

Merge branch 'mastodon-api-convert-conversation-ids' into 'develop'

Mastodon API: convert IDs in conversations

Closes #10675

See merge request firefish/firefish!10568
This commit is contained in:
Kainoa Kanter 2023-08-14 19:34:33 +00:00
commit a1284d0591
2 changed files with 19 additions and 2 deletions

View file

@ -74,3 +74,13 @@ export function convertStatus(status: Entity.Status) {
return status;
}
export function convertConversation(conversation: Entity.Conversation) {
conversation.id = convertId(conversation.id, IdType.MastodonId);
conversation.accounts = conversation.accounts.map(convertAccount);
if (conversation.last_status) {
conversation.last_status = convertStatus(conversation.last_status);
}
return conversation;
}

View file

@ -1,7 +1,12 @@
import Router from "@koa/router";
import { getClient } from "../ApiMastodonCompatibleService.js";
import { ParsedUrlQuery } from "querystring";
import { convertAccount, convertList, convertStatus } from "../converters.js";
import {
convertAccount,
convertConversation,
convertList,
convertStatus,
} from "../converters.js";
import { convertId, IdType } from "../../index.js";
export function limitToInt(q: ParsedUrlQuery) {
@ -136,7 +141,9 @@ export function apiTimelineMastodon(router: Router): void {
const data = await client.getConversationTimeline(
convertTimelinesArgsId(limitToInt(ctx.query)),
);
ctx.body = data.data;
ctx.body = data.data.map((conversation) =>
convertConversation(conversation),
);
} catch (e: any) {
console.error(e);
console.error(e.response.data);