mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-04 21:30:11 +00:00
Add extensible notification providers + UI/API
Introduce a provider-based notification system and wire it through the API and admin UI. Added INotificationProvider + notification service implementation and providers (apprise, discord, ntfy, pushover), plus a GET /api/admin/notifications/providers endpoint to expose provider metadata. Refactored code to use provider type strings (removed enum coupling), updated masking/encryption calls, and simplified the test notification endpoint to accept backendId or type+config and call sendToBackend directly. UI: NotificationsTab now fetches provider metadata and renders provider cards and dynamic config forms (fields driven by provider metadata). Added config field rendering, improved backend cards, and edit/delete actions. APIs: New providers route, updated admin notification CRUD routes to validate provider types dynamically, updated test route schema. Added download-client categories POST API to fetch categories from clients and wired postImportCategory handling in download-client routes. Other notable changes: BookDate now fetches Claude models dynamically from Anthropic's Models API; added paginated model fetch helper. Added ALLOW_WEAK_PASSWORD flag exposure to auth providers and password change logic. Doc updates and various tests added/updated. File-organization doc clarifies EPERM fix using stream-based copy.
This commit is contained in:
@@ -406,6 +406,16 @@ export class NZBGetService implements IDownloadClient {
|
||||
}
|
||||
}
|
||||
|
||||
/** Not applicable for usenet clients */
|
||||
async getCategories(): Promise<string[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
/** Not applicable for usenet clients */
|
||||
async setCategory(_id: string, _category: string): Promise<void> {
|
||||
// No-op: post-import category is scoped to torrent clients
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Category Management
|
||||
// =========================================================================
|
||||
|
||||
@@ -208,6 +208,55 @@ export class ProwlarrService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search with multiple query variations to increase coverage
|
||||
* Fires 2 queries per call: "title author" and "title", then deduplicates by guid
|
||||
*/
|
||||
async searchWithVariations(
|
||||
title: string,
|
||||
author: string,
|
||||
filters?: SearchFilters
|
||||
): Promise<TorrentResult[]> {
|
||||
const queries = [
|
||||
`${title} ${author}`,
|
||||
title,
|
||||
];
|
||||
|
||||
logger.info(`Searching with ${queries.length} query variations`, { queries });
|
||||
|
||||
const allResults: TorrentResult[] = [];
|
||||
|
||||
for (const query of queries) {
|
||||
try {
|
||||
const results = await this.search(query, filters);
|
||||
logger.info(`Query "${query}" returned ${results.length} results`);
|
||||
allResults.push(...results);
|
||||
} catch (error) {
|
||||
logger.error(`Query "${query}" failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||
// Continue with other queries even if one fails
|
||||
}
|
||||
}
|
||||
|
||||
const deduplicated = this.deduplicateResults(allResults);
|
||||
logger.info(`Multi-query search: ${allResults.length} total → ${deduplicated.length} after dedup (${allResults.length - deduplicated.length} duplicates removed)`);
|
||||
|
||||
return deduplicated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deduplicate results by guid, preserving order (first occurrence wins)
|
||||
*/
|
||||
private deduplicateResults(results: TorrentResult[]): TorrentResult[] {
|
||||
const seen = new Set<string>();
|
||||
return results.filter(result => {
|
||||
if (seen.has(result.guid)) {
|
||||
return false;
|
||||
}
|
||||
seen.add(result.guid);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of configured indexers
|
||||
*/
|
||||
|
||||
@@ -729,6 +729,26 @@ export class QBittorrentService implements IDownloadClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all configured categories from qBittorrent
|
||||
*/
|
||||
async getCategories(): Promise<string[]> {
|
||||
if (!this.cookie) {
|
||||
await this.login();
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await this.client.get('/torrents/categories', {
|
||||
headers: { Cookie: this.cookie },
|
||||
});
|
||||
|
||||
return Object.keys(response.data || {});
|
||||
} catch (error) {
|
||||
logger.error('Failed to get categories', { error: error instanceof Error ? error.message : String(error) });
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set category for torrent
|
||||
*/
|
||||
|
||||
@@ -825,6 +825,16 @@ export class SABnzbdService implements IDownloadClient {
|
||||
await this.archiveCompletedNZB(id);
|
||||
}
|
||||
|
||||
/** Not applicable for usenet clients */
|
||||
async getCategories(): Promise<string[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
/** Not applicable for usenet clients */
|
||||
async setCategory(_id: string, _category: string): Promise<void> {
|
||||
// No-op: post-import category is scoped to torrent clients
|
||||
}
|
||||
|
||||
/**
|
||||
* Map NZBInfo to the unified DownloadInfo format.
|
||||
*/
|
||||
|
||||
@@ -441,6 +441,29 @@ export class TransmissionService implements IDownloadClient {
|
||||
// No-op: torrents are managed by the seeding cleanup scheduler
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available categories/labels.
|
||||
* Transmission uses free-form labels — no predefined list to fetch.
|
||||
*/
|
||||
async getCategories(): Promise<string[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the label for a torrent.
|
||||
* Uses the torrent-set RPC method to replace the labels array.
|
||||
*/
|
||||
async setCategory(id: string, category: string): Promise<void> {
|
||||
try {
|
||||
const torrent = await this.getTorrentByHash(id);
|
||||
await this.rpc('torrent-set', { ids: [torrent.hashString], labels: [category] });
|
||||
logger.info(`Set label for torrent ${id}: ${category}`);
|
||||
} catch (error) {
|
||||
logger.error('Failed to set label', { error: error instanceof Error ? error.message : String(error) });
|
||||
throw new Error('Failed to set torrent label');
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// Internal Helpers
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user