beta release conversation context

This commit is contained in:
2025-08-03 23:31:56 +00:00
parent 0bfff52fd0
commit 0f178fcfa9
5 changed files with 101 additions and 12 deletions

View File

@ -1,5 +1,5 @@
import { envConfig, prisma } from "./main.js";
import { PleromaEmoji, Notification } from "../types.js";
import { PleromaEmoji, Notification, ContextResponse } from "../types.js";
const getNotifications = async () => {
const { bearerToken, pleromaInstanceUrl } = envConfig;
@ -22,6 +22,32 @@ const getNotifications = async () => {
}
};
const getStatusContext = async (statusId: string) => {
const { bearerToken, pleromaInstanceUrl } = envConfig;
try {
const response = await fetch(
`${pleromaInstanceUrl}/api/v1/statuses/${statusId}/context`,
{
method: "GET",
headers: {
Authorization: `Bearer ${bearerToken}`,
},
}
);
if (!response.ok) {
throw new Error(
`Could not get conversation context: ${response.status} - ${response.statusText}`
);
}
const data: ContextResponse = await response.json();
return data;
} catch (error: unknown) {
if (error instanceof Error) {
throw new Error(error.message);
}
}
};
const getInstanceEmojis = async () => {
const { bearerToken, pleromaInstanceUrl } = envConfig;
try {
@ -72,4 +98,9 @@ const deleteNotification = async (notification: Notification) => {
}
};
export { deleteNotification, getInstanceEmojis, getNotifications };
export {
deleteNotification,
getInstanceEmojis,
getNotifications,
getStatusContext,
};