From de71580756dfc5bb88b78c7d0cf05f297a1ce441 Mon Sep 17 00:00:00 2001 From: Gronod Date: Sat, 23 May 2026 10:12:07 +0100 Subject: [PATCH 1/2] fix(ombi): retrieve and include settings ID in webhook enable payload (resolves #41) --- server/routes/ombi.js | 18 +++++++++++++++++ tests/integration/ombi.test.js | 37 +++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/server/routes/ombi.js b/server/routes/ombi.js index 80fc07b..2772d9d 100644 --- a/server/routes/ombi.js +++ b/server/routes/ombi.js @@ -225,9 +225,27 @@ router.post('/webhook/enable', requireAuth, async (req, res) => { // Call Ombi API to register webhook const axios = require('axios'); + + // Get existing settings to retrieve the database ID + const currentRes = await axios.get( + `${ombiInst.url}/api/v1/Settings/notifications/webhook`, + { + headers: { + 'ApiKey': ombiInst.apiKey + } + } + ).catch(err => { + logToFile(`[Ombi] Warning fetching existing webhook settings: ${err.message}`); + return { data: {} }; + }); + + const currentConfig = currentRes.data || {}; + const settingsId = currentConfig.id || 0; + const response = await axios.post( `${ombiInst.url}/api/v1/Settings/notifications/webhook`, { + id: settingsId, enabled: true, webhookUrl: webhookUrl, applicationToken: ombiInst.apiKey diff --git a/tests/integration/ombi.test.js b/tests/integration/ombi.test.js index ef1584d..bb9dcb8 100644 --- a/tests/integration/ombi.test.js +++ b/tests/integration/ombi.test.js @@ -850,7 +850,15 @@ describe('POST /api/ombi/webhook/enable', () => { it('enables webhook successfully', async () => { nock(OMBI_BASE) - .post('/api/v1/Settings/notifications/webhook') + .get('/api/v1/Settings/notifications/webhook') + .reply(200, { id: 42, enabled: false, webhookUrl: null, applicationToken: null }); + nock(OMBI_BASE) + .post('/api/v1/Settings/notifications/webhook', { + id: 42, + enabled: true, + webhookUrl: `${SOFARR_BASE}/api/webhook/ombi`, + applicationToken: 'test-ombi-key' + }) .reply(200, { success: true }); const { cookies, csrfToken } = await authenticateUser(app, 'TestUser', false); @@ -866,7 +874,34 @@ describe('POST /api/ombi/webhook/enable', () => { expect(res.body.applicationToken).toBe('test-ombi-key'); }); + it('enables webhook successfully even if GET settings fails', async () => { + nock(OMBI_BASE) + .get('/api/v1/Settings/notifications/webhook') + .reply(500, { error: 'Failed to fetch settings' }); + nock(OMBI_BASE) + .post('/api/v1/Settings/notifications/webhook', { + id: 0, + enabled: true, + webhookUrl: `${SOFARR_BASE}/api/webhook/ombi`, + applicationToken: 'test-ombi-key' + }) + .reply(200, { success: true }); + + const { cookies, csrfToken } = await authenticateUser(app, 'TestUser', false); + + const res = await request(app) + .post('/api/ombi/webhook/enable') + .set('Cookie', cookies) + .set('X-CSRF-Token', csrfToken) + .expect(200); + + expect(res.body.success).toBe(true); + }); + it('handles Ombi API errors gracefully', async () => { + nock(OMBI_BASE) + .get('/api/v1/Settings/notifications/webhook') + .reply(200, { id: 42 }); nock(OMBI_BASE) .post('/api/v1/Settings/notifications/webhook') .reply(500, { error: 'Internal server error' }); From f8c7e35f316da4c9bc4f3edd4dac4d4908a1fd40 Mon Sep 17 00:00:00 2001 From: Gronod Date: Sat, 23 May 2026 10:13:25 +0100 Subject: [PATCH 2/2] chore: bump version to 1.7.5 and update CHANGELOG --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 769e0cf..7b40ff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm --- +## [1.7.5] - 2026-05-23 + +### Fixed + +- **Ombi webhook settings persistence** — Fixed a bug where enabling the Ombi webhook from the frontend was successfully processed by the server but not stored on the Ombi side. The payload submitted to Ombi now retrieves the database `id` of the settings row first and merges it back into the `POST` payload. This ensures Entity Framework Core on the Ombi backend performs an update on the correct database row, enabling the webhook and letting its status persist successfully. Resolves Gitea Issue [#41](https://git.i3omb.com/Gandalf/sofarr/issues/41). + +--- + ## [1.7.4] - 2026-05-23 ### Fixed diff --git a/package-lock.json b/package-lock.json index 44a3927..df42842 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sofarr", - "version": "1.7.4", + "version": "1.7.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sofarr", - "version": "1.7.4", + "version": "1.7.5", "license": "MIT", "dependencies": { "axios": "^1.6.0", diff --git a/package.json b/package.json index 390bdcb..bf4136b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sofarr", - "version": "1.7.4", + "version": "1.7.5", "description": "A personal media download dashboard that shows your downloads 'so far' while you relax on the sofa waiting for your *arr services to finish", "main": "server/index.js", "scripts": {