2023-07-06 01:10:33 +02:00
|
|
|
import { Entity } from "megalodon";
|
2023-04-30 21:34:52 +02:00
|
|
|
import { convertId, IdType } from "../index.js";
|
|
|
|
|
|
|
|
function simpleConvert(data: any) {
|
|
|
|
data.id = convertId(data.id, IdType.MastodonId);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2023-05-02 05:32:18 +02:00
|
|
|
export function convertAccount(account: Entity.Account) {
|
|
|
|
return simpleConvert(account);
|
|
|
|
}
|
|
|
|
export function convertAnnouncement(announcement: Entity.Announcement) {
|
|
|
|
return simpleConvert(announcement);
|
|
|
|
}
|
|
|
|
export function convertAttachment(attachment: Entity.Attachment) {
|
|
|
|
return simpleConvert(attachment);
|
|
|
|
}
|
|
|
|
export function convertFilter(filter: Entity.Filter) {
|
|
|
|
return simpleConvert(filter);
|
|
|
|
}
|
|
|
|
export function convertList(list: Entity.List) {
|
|
|
|
return simpleConvert(list);
|
|
|
|
}
|
2023-07-06 01:10:33 +02:00
|
|
|
export function convertFeaturedTag(tag: Entity.FeaturedTag) {
|
|
|
|
return simpleConvert(tag);
|
|
|
|
}
|
2023-04-30 21:34:52 +02:00
|
|
|
|
|
|
|
export function convertNotification(notification: Entity.Notification) {
|
|
|
|
notification.account = convertAccount(notification.account);
|
|
|
|
notification.id = convertId(notification.id, IdType.MastodonId);
|
|
|
|
if (notification.status)
|
|
|
|
notification.status = convertStatus(notification.status);
|
|
|
|
return notification;
|
|
|
|
}
|
|
|
|
|
2023-05-02 05:32:18 +02:00
|
|
|
export function convertPoll(poll: Entity.Poll) {
|
|
|
|
return simpleConvert(poll);
|
|
|
|
}
|
|
|
|
export function convertRelationship(relationship: Entity.Relationship) {
|
|
|
|
return simpleConvert(relationship);
|
|
|
|
}
|
2023-04-30 21:34:52 +02:00
|
|
|
|
|
|
|
export function convertStatus(status: Entity.Status) {
|
|
|
|
status.account = convertAccount(status.account);
|
|
|
|
status.id = convertId(status.id, IdType.MastodonId);
|
|
|
|
if (status.in_reply_to_account_id)
|
2023-05-02 05:32:18 +02:00
|
|
|
status.in_reply_to_account_id = convertId(
|
|
|
|
status.in_reply_to_account_id,
|
|
|
|
IdType.MastodonId,
|
|
|
|
);
|
2023-04-30 21:34:52 +02:00
|
|
|
if (status.in_reply_to_id)
|
|
|
|
status.in_reply_to_id = convertId(status.in_reply_to_id, IdType.MastodonId);
|
2023-05-02 05:32:18 +02:00
|
|
|
status.media_attachments = status.media_attachments.map((attachment) =>
|
|
|
|
convertAttachment(attachment),
|
|
|
|
);
|
|
|
|
status.mentions = status.mentions.map((mention) => ({
|
2023-04-30 21:34:52 +02:00
|
|
|
...mention,
|
|
|
|
id: convertId(mention.id, IdType.MastodonId),
|
|
|
|
}));
|
2023-05-02 05:32:18 +02:00
|
|
|
if (status.poll) status.poll = convertPoll(status.poll);
|
|
|
|
if (status.reblog) status.reblog = convertStatus(status.reblog);
|
2023-04-30 21:34:52 +02:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|