mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-08 23:18:31 +01:00
fix: fixing seerr intergration
added an alert if seerr if configured via settings, but not authed Added an alert if the auth for seerr expires it should fire cleaned up a little Signed-off-by: Lance Chant <13349722+lancechant@users.noreply.github.com>
This commit is contained in:
@@ -70,6 +70,36 @@ export const clearJellyseerrStorageData = () => {
|
||||
storage.remove(JELLYSEERR_COOKIES);
|
||||
};
|
||||
|
||||
export type JellyseerrSessionStatus =
|
||||
| { valid: true }
|
||||
| { valid: false; reason: "no_session" | "expired" };
|
||||
|
||||
export async function validateJellyseerrSession(
|
||||
serverUrl: string,
|
||||
): Promise<JellyseerrSessionStatus> {
|
||||
const user = storage.get<JellyseerrUser>(JELLYSEERR_USER);
|
||||
const cookies = storage.get<string[]>(JELLYSEERR_COOKIES);
|
||||
|
||||
console.log(
|
||||
"Validating Jellyseerr session with server URL:",
|
||||
serverUrl,
|
||||
!user,
|
||||
!cookies,
|
||||
);
|
||||
if (!user || !cookies) {
|
||||
return { valid: false, reason: "no_session" };
|
||||
}
|
||||
|
||||
try {
|
||||
const api = new JellyseerrApi(serverUrl);
|
||||
await api.axios.get(Endpoints.API_V1 + Endpoints.STATUS);
|
||||
return { valid: true };
|
||||
} catch {
|
||||
clearJellyseerrStorageData();
|
||||
return { valid: false, reason: "expired" };
|
||||
}
|
||||
}
|
||||
|
||||
export enum Endpoints {
|
||||
STATUS = "/status",
|
||||
API_V1 = "/api/v1",
|
||||
@@ -450,7 +480,8 @@ export const useJellyseerr = () => {
|
||||
clearJellyseerrStorageData();
|
||||
setJellyseerrUser(undefined);
|
||||
updateSettings({ jellyseerrServerUrl: undefined });
|
||||
}, []);
|
||||
queryClient.removeQueries({ queryKey: ["search", "jellyseerr"] });
|
||||
}, [queryClient]);
|
||||
|
||||
const requestMedia = useCallback(
|
||||
(title: string, request: MediaRequestBody, onSuccess?: () => void) => {
|
||||
|
||||
Reference in New Issue
Block a user