beta release conversation context
This commit is contained in:
35
src/api.ts
35
src/api.ts
@ -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,
|
||||
};
|
||||
|
Reference in New Issue
Block a user