mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
* Add OAuth authentication support for MCP servers * Improve mobile text sizing with responsive text classes * refactor: improve virtualized text viewer with React Query infinite scroll and simplified buffering * Add push notifications with VAPID and PWA support * feat: add VAPID environment variables for push notifications * Replace SquareFill with MicOff icon for stop recording buttons * Send push notifications when app is not focused * Fix stop generation button icons to use X instead of MicOff * feat: enhance push notification logging and debugging - Add structured logging throughout push notification flow - Improve error handling with detailed diagnostics - Add /api/notifications/debug endpoint for troubleshooting - Enhanced test notification response with per-subscription results - Add service worker logging and better install/activate handling * Improve VAPID push notification configuration with validation and better defaults - Add validation warnings for VAPID_SUBJECT format (requires mailto: prefix for iOS/Safari) - Expose VAPID details via notifications API endpoint - Update default VAPID_SUBJECT from mailto:admin@opencode.local to empty string - Enhance VAPID logging with key lengths and subject info - Improve documentation in .env.example with setup instructions * Fix notification URL to use repo ID instead of filesystem path * Clean up push notification logging and debug endpoints * Add push notifications documentation
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import type { PushSubscriptionRecord } from "@opencode-manager/shared/types";
|
|
import { API_BASE_URL } from "@/config";
|
|
import { fetchWrapper } from "./fetchWrapper";
|
|
|
|
export const notificationsApi = {
|
|
getVapidPublicKey: async (): Promise<{ publicKey: string }> => {
|
|
return fetchWrapper(`${API_BASE_URL}/api/notifications/vapid-public-key`);
|
|
},
|
|
|
|
subscribe: async (
|
|
subscription: PushSubscriptionJSON,
|
|
deviceName?: string,
|
|
userId = 'default'
|
|
): Promise<{ subscription: PushSubscriptionRecord }> => {
|
|
return fetchWrapper(`${API_BASE_URL}/api/notifications/subscribe`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
endpoint: subscription.endpoint,
|
|
keys: subscription.keys,
|
|
deviceName,
|
|
}),
|
|
params: { userId },
|
|
});
|
|
},
|
|
|
|
unsubscribe: async (endpoint: string, userId = 'default'): Promise<{ success: boolean }> => {
|
|
return fetchWrapper(`${API_BASE_URL}/api/notifications/subscribe`, {
|
|
method: "DELETE",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ endpoint }),
|
|
params: { userId },
|
|
});
|
|
},
|
|
|
|
getSubscriptions: async (userId = 'default'): Promise<{
|
|
subscriptions: PushSubscriptionRecord[];
|
|
}> => {
|
|
return fetchWrapper(`${API_BASE_URL}/api/notifications/subscriptions`, {
|
|
params: { userId },
|
|
});
|
|
},
|
|
|
|
removeSubscription: async (
|
|
id: number,
|
|
userId = 'default'
|
|
): Promise<{ success: boolean }> => {
|
|
return fetchWrapper(
|
|
`${API_BASE_URL}/api/notifications/subscriptions/${id}`,
|
|
{ method: "DELETE", params: { userId } }
|
|
);
|
|
},
|
|
|
|
sendTest: async (userId = 'default'): Promise<{
|
|
success: boolean;
|
|
devicesNotified: number;
|
|
}> => {
|
|
return fetchWrapper(`${API_BASE_URL}/api/notifications/test`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
params: { userId },
|
|
});
|
|
},
|
|
};
|