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 -18
View File
@@ -354,24 +354,6 @@ export interface PublicSettings {
pool_keys: string[];
}
export const registerCabinePushToken = async (
pushToken: string,
): Promise<void> => {
try {
await apiClient.post(`${API}/push-token`, { push_token: pushToken });
} catch {
/* ignore */
}
};
export const unregisterCabinePushToken = async (): Promise<void> => {
try {
await apiClient.delete(`${API}/push-token`);
} catch {
/* ignore */
}
};
export interface AppNotification {
command_id: number;
type: string;
@@ -454,3 +436,36 @@ export const getAllAddresses = async (): Promise<
correct_address: a.correct_address ?? a.CorrectAddress ?? "",
}));
};
// ============================================
// TELEGRAM — CABINE
// ============================================
const CABINE_API = "https://5.181.0.112.nip.io/api/v1/cabine";
export const getCabineTelegramStatus = async (): Promise<{ linked: boolean; enabled: boolean }> => {
try {
const { data } = await apiClient.get(`${CABINE_API}/telegram/status`);
return data;
} catch {
return { linked: false, enabled: false };
}
};
export const generateCabineLinkToken = async (): Promise<{
link_url?: string;
error?: string;
}> => {
try {
const { data } = await apiClient.post(`${CABINE_API}/telegram/link-token`);
return data;
} catch (e: any) {
return { error: e?.response?.data?.error || "Erreur" };
}
};
export const unlinkCabineTelegram = async (): Promise<void> => {
try {
await apiClient.delete(`${CABINE_API}/telegram/unlink`);
} catch { /* ignore */ }
};