mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-28 01:10:54 +01:00
refactor: add request handlers for centralized cached requests (#1504)
* feat: add object base64 hash method * chore: add script to add package * feat: add request-handler package * wip: add request handlers for all jobs and widget api procedures * wip: remove errors shown in logs, add missing decryption for secrets in cached-request-job-handler * wip: highly improve request handler, add request handlers for calendar, media-server, indexer-manager and more, add support for multiple inputs from job handler creator * refactor: move media-server requests to request-handler, add invalidation logic for dns-hole and media requests * refactor: remove unused integration item middleware * feat: add invalidation to switch entity action of smart-home * fix: lint issues * chore: use integration-kind-by-category instead of union for request-handlers * fix: build not working for tasks and websocket * refactor: add more logs * refactor: readd timestamp logic for diconnect status * fix: lint and typecheck issue * chore: address pull request feedback
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
export const radarrReleaseTypes = ["inCinemas", "digitalRelease", "physicalRelease"] as const;
|
||||
type ReleaseType = (typeof radarrReleaseTypes)[number];
|
||||
export type RadarrReleaseType = (typeof radarrReleaseTypes)[number];
|
||||
|
||||
export interface CalendarEvent {
|
||||
name: string;
|
||||
subName: string;
|
||||
date: Date;
|
||||
dates?: { type: ReleaseType; date: Date }[];
|
||||
dates?: { type: RadarrReleaseType; date: Date }[];
|
||||
description?: string;
|
||||
thumbnail?: string;
|
||||
mediaInformation?: {
|
||||
|
||||
@@ -45,7 +45,7 @@ export const downloadClientItemSchema = z.object({
|
||||
export type DownloadClientItem = z.infer<typeof downloadClientItemSchema>;
|
||||
|
||||
export type ExtendedDownloadClientItem = {
|
||||
integration: Integration;
|
||||
integration: Pick<Integration, "id" | "name" | "kind">;
|
||||
received: number;
|
||||
ratio?: number;
|
||||
actions?: {
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface DownloadClientStatus {
|
||||
type: "usenet" | "torrent";
|
||||
}
|
||||
export interface ExtendedClientStatus {
|
||||
integration: Integration;
|
||||
integration: Pick<Integration, "id" | "name" | "kind"> & { updatedAt: Date };
|
||||
interact: boolean;
|
||||
status?: {
|
||||
/** To derive from current items */
|
||||
|
||||
@@ -39,10 +39,6 @@ export interface RequestUser {
|
||||
}
|
||||
|
||||
export interface MediaRequestStats {
|
||||
integration: {
|
||||
kind: string;
|
||||
name: string;
|
||||
};
|
||||
stats: RequestStats;
|
||||
users: RequestUser[];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { logger } from "@homarr/log";
|
||||
import { z } from "@homarr/validation";
|
||||
|
||||
import { Integration } from "../base/integration";
|
||||
@@ -125,20 +126,38 @@ export class OverseerrIntegration extends Integration implements ISearchableInte
|
||||
}
|
||||
|
||||
public async approveRequestAsync(requestId: number): Promise<void> {
|
||||
logger.info(`Approving media request id='${requestId}' integration='${this.integration.name}'`);
|
||||
await fetch(`${this.integration.url}/api/v1/request/${requestId}/approve`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Api-Key": this.getSecretValue("apiKey"),
|
||||
},
|
||||
}).then((response) => {
|
||||
if (!response.ok) {
|
||||
logger.error(
|
||||
`Failed to approve media request id='${requestId}' integration='${this.integration.name}' reason='${response.status} ${response.statusText}' url='${response.url}'`,
|
||||
);
|
||||
}
|
||||
|
||||
logger.info(`Successfully approved media request id='${requestId}' integration='${this.integration.name}'`);
|
||||
});
|
||||
}
|
||||
|
||||
public async declineRequestAsync(requestId: number): Promise<void> {
|
||||
logger.info(`Declining media request id='${requestId}' integration='${this.integration.name}'`);
|
||||
await fetch(`${this.integration.url}/api/v1/request/${requestId}/decline`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Api-Key": this.getSecretValue("apiKey"),
|
||||
},
|
||||
}).then((response) => {
|
||||
if (!response.ok) {
|
||||
logger.error(
|
||||
`Failed to decline media request id='${requestId}' integration='${this.integration.name}' reason='${response.status} ${response.statusText}' url='${response.url}'`,
|
||||
);
|
||||
}
|
||||
|
||||
logger.info(`Successfully declined media request id='${requestId}' integration='${this.integration.name}'`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,3 +5,4 @@ export * from "./interfaces/indexer-manager/indexer";
|
||||
export * from "./interfaces/media-requests/media-request";
|
||||
export * from "./pi-hole/pi-hole-types";
|
||||
export * from "./base/searchable-integration";
|
||||
export * from "./homeassistant/homeassistant-types";
|
||||
|
||||
Reference in New Issue
Block a user