mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 06:15:39 -04:00
Add Plex and Jellyfin webhook integration for automatic watch tracking
When a user finishes watching on their media server, a webhook fires and Sofa logs it as watched, triggering all existing auto-transitions. Each user configures their connection in settings and gets a unique webhook URL. - Add webhookConnections and webhookEventLog schema tables - Add TMDB findByExternalId for resolving IMDB/TVDB IDs - Add source parameter to tracking functions (plex/jellyfin) - Add webhook processing service with payload parsers, title resolution, and deduplication - Add public webhook receiver route (token-based auth) - Add authenticated settings API routes for managing connections - Add Media Servers section to settings UI with Plex/Jellyfin cards Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE `webhookConnections` (
|
||||
`id` text PRIMARY KEY,
|
||||
`userId` text NOT NULL,
|
||||
`provider` text NOT NULL,
|
||||
`token` text NOT NULL,
|
||||
`mediaServerUsername` text NOT NULL,
|
||||
`enabled` integer DEFAULT true NOT NULL,
|
||||
`createdAt` integer NOT NULL,
|
||||
`lastEventAt` integer,
|
||||
CONSTRAINT `fk_webhookConnections_userId_user_id_fk` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE CASCADE
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `webhookEventLog` (
|
||||
`id` text PRIMARY KEY,
|
||||
`connectionId` text NOT NULL,
|
||||
`eventType` text,
|
||||
`mediaType` text,
|
||||
`mediaTitle` text,
|
||||
`status` text NOT NULL,
|
||||
`errorMessage` text,
|
||||
`receivedAt` integer NOT NULL,
|
||||
CONSTRAINT `fk_webhookEventLog_connectionId_webhookConnections_id_fk` FOREIGN KEY (`connectionId`) REFERENCES `webhookConnections`(`id`) ON DELETE CASCADE
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `webhookConnections_userId_provider` ON `webhookConnections` (`userId`,`provider`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `webhookConnections_token` ON `webhookConnections` (`token`);--> statement-breakpoint
|
||||
CREATE INDEX `webhookEventLog_connectionId_receivedAt` ON `webhookEventLog` (`connectionId`,`receivedAt`);
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user