mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-04-07 13:38:33 +03:00
* feat: add notification system with Ntfy.sh and Apprise providers (#231) Add push notification support for mirror job events with two providers: - Ntfy.sh: direct HTTP POST to ntfy topics with priority/tag support - Apprise API: aggregator gateway supporting 100+ notification services Includes database migration (0010), settings UI tab, test endpoint, auto-save integration, token encryption, and comprehensive tests. Notifications are fire-and-forget and never block the mirror flow. * fix: address review findings for notification system - Fix silent catch in GET handler that returned ciphertext to UI, causing double-encryption on next save. Now clears token to "" on decryption failure instead. - Add Zod schema validation to test notification endpoint, following project API route pattern guidelines. - Mark notifyOnNewRepo toggle as "coming soon" with disabled state, since the backend doesn't yet emit new_repo events. The schema and type support is in place for when it's implemented. * fix notification gating and config validation * trim sync notification details
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { POST } from "./index";
|
|
|
|
describe("POST /api/config notification validation", () => {
|
|
test("returns 400 for invalid notificationConfig payload", async () => {
|
|
const request = new Request("http://localhost/api/config", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({
|
|
githubConfig: { username: "octo", token: "ghp_x" },
|
|
giteaConfig: { url: "https://gitea.example.com", token: "gt_x", username: "octo" },
|
|
scheduleConfig: { enabled: true, interval: 3600 },
|
|
cleanupConfig: { enabled: false, retentionDays: 604800 },
|
|
mirrorOptions: {
|
|
mirrorReleases: false,
|
|
releaseLimit: 10,
|
|
mirrorLFS: false,
|
|
mirrorMetadata: false,
|
|
metadataComponents: {
|
|
issues: false,
|
|
pullRequests: false,
|
|
labels: false,
|
|
milestones: false,
|
|
wiki: false,
|
|
},
|
|
},
|
|
advancedOptions: {
|
|
skipForks: false,
|
|
starredCodeOnly: false,
|
|
autoMirrorStarred: false,
|
|
},
|
|
notificationConfig: {
|
|
enabled: true,
|
|
provider: "invalid-provider",
|
|
},
|
|
}),
|
|
});
|
|
|
|
const response = await POST({
|
|
request,
|
|
locals: {
|
|
session: { userId: "user-1" },
|
|
},
|
|
} as any);
|
|
const data = await response.json();
|
|
|
|
expect(response.status).toBe(400);
|
|
expect(data.success).toBe(false);
|
|
expect(data.message).toContain("Invalid notificationConfig");
|
|
});
|
|
});
|