mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-25 05:29:07 +01:00
Mastodon API: convert IDs in conversations
This commit is contained in:
parent
8363ac9d84
commit
e759864442
@ -74,3 +74,13 @@ export function convertStatus(status: Entity.Status) {
|
|||||||
|
|
||||||
return 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;
|
||||||
|
}
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import Router from "@koa/router";
|
import Router from "@koa/router";
|
||||||
import { getClient } from "../ApiMastodonCompatibleService.js";
|
import { getClient } from "../ApiMastodonCompatibleService.js";
|
||||||
import { ParsedUrlQuery } from "querystring";
|
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";
|
import { convertId, IdType } from "../../index.js";
|
||||||
|
|
||||||
export function limitToInt(q: ParsedUrlQuery) {
|
export function limitToInt(q: ParsedUrlQuery) {
|
||||||
@ -136,7 +141,9 @@ export function apiTimelineMastodon(router: Router): void {
|
|||||||
const data = await client.getConversationTimeline(
|
const data = await client.getConversationTimeline(
|
||||||
convertTimelinesArgsId(limitToInt(ctx.query)),
|
convertTimelinesArgsId(limitToInt(ctx.query)),
|
||||||
);
|
);
|
||||||
ctx.body = data.data;
|
ctx.body = data.data.map((conversation) =>
|
||||||
|
convertConversation(conversation),
|
||||||
|
);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
console.error(e.response.data);
|
console.error(e.response.data);
|
||||||
|
Loading…
Reference in New Issue
Block a user