chore: add notification telegram

This commit is contained in:
2026-03-24 11:51:22 +01:00
parent a8eeb55e72
commit 79c050d689
15 changed files with 424 additions and 253 deletions
+33 -19
View File
@@ -760,6 +760,8 @@ export interface AppSettings {
nowpayments_api_key: string;
nowpayments_ipn_secret: string;
nowpayments_currencies: string[];
telegram_bot_token: string;
telegram_bot_username: string;
}
export const getSettings = async (): Promise<{
@@ -778,25 +780,6 @@ export const getSettings = async (): Promise<{
}
};
export const registerAdminPushToken = async (
pushToken: string,
): Promise<void> => {
try {
await apiClient.post(`${V2}/admin/protected/push-token`, {
push_token: pushToken,
});
} catch {
/* ignore */
}
};
export const unregisterAdminPushToken = async (): Promise<void> => {
try {
await apiClient.delete(`${V2}/admin/protected/push-token`);
} catch {
/* ignore */
}
};
export interface AppNotification {
command_id: number;
@@ -818,6 +801,37 @@ export const markAdminNotificationsRead = async (): Promise<void> => {
await apiClient.post(`${V2}/admin/protected/notifications/read`);
};
// ============================================
// TELEGRAM — ADMIN
// ============================================
export const getAdminTelegramStatus = async (): Promise<{ linked: boolean; enabled: boolean }> => {
try {
const { data } = await apiClient.get(`${V2}/admin/protected/telegram/status`);
return data;
} catch {
return { linked: false, enabled: false };
}
};
export const generateAdminLinkToken = async (): Promise<{
link_url?: string;
error?: string;
}> => {
try {
const { data } = await apiClient.post(`${V2}/admin/protected/telegram/link-token`);
return data;
} catch (e: any) {
return { error: e?.response?.data?.error || "Erreur" };
}
};
export const unlinkAdminTelegram = async (): Promise<void> => {
try {
await apiClient.delete(`${V2}/admin/protected/telegram/unlink`);
} catch { /* ignore */ }
};
export const updateSettings = async (
settings: AppSettings,
): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => {