Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
1.4 kB · 40 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041import { childLogger, type Logger } from "@foxxmd/logging";import type {AppriseConfig, GotifyConfig, NtfyConfig, WebhookPayload} from "../common/infrastructure/config/health/webhooks.ts";
export abstract class AbstractWebhookNotifier {
config: GotifyConfig | NtfyConfig | AppriseConfig logger: Logger;
initialized: boolean = false; requiresAuth: boolean = false; authed: boolean = false;
protected constructor(type: string, defaultName: string, config: GotifyConfig | NtfyConfig | AppriseConfig, logger: Logger) { this.config = config; const label = `${type} - ${config.name ?? defaultName}` this.logger = childLogger(logger, label); }
initialize = async () => { this.initialized = true; this.logger.verbose('Initialized'); }
testAuth = async () => { return; }
notify = async (payload: WebhookPayload) => { if(!this.initialized) { this.logger.debug('Will not use notifier because it is not initialized.'); return; } if(this.requiresAuth && !this.authed) { this.logger.debug('Will not use notifier because it is not correctly authenticated.'); return; } return await this.doNotify(payload); } abstract doNotify: (payload: WebhookPayload) => Promise<any>;}