Compare commits

..

9 Commits

Author SHA1 Message Date
gronod d4ee3b8ef7 merge branch 'develop' into 'main' - Release v1.7.9
Create Release / release (push) Successful in 19s
Build and Push Docker Image / build (push) Successful in 1m51s
CI / Security audit (push) Successful in 2m12s
CI / Swagger Validation & Coverage (push) Successful in 2m41s
CI / Tests & coverage (push) Successful in 3m20s
2026-05-23 20:58:20 +01:00
gronod 64c872423f chore: bump version to 1.7.9 and update CHANGELOG
Build and Push Docker Image / build (push) Successful in 2m12s
Docs Check / Markdown lint (push) Successful in 2m34s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 3m14s
CI / Security audit (push) Successful in 3m29s
Docs Check / Mermaid diagram parse check (push) Successful in 3m47s
CI / Swagger Validation & Coverage (push) Successful in 4m12s
CI / Tests & coverage (push) Successful in 4m57s
2026-05-23 20:58:09 +01:00
gronod 86c67bcf29 fix: support PascalCase properties in Ombi webhooks (#42) 2026-05-23 20:57:55 +01:00
gronod 9548eb41f5 merge branch 'develop' into 'main' - Release v1.7.8
Create Release / release (push) Successful in 30s
CI / Security audit (push) Successful in 2m9s
Build and Push Docker Image / build (push) Successful in 2m18s
CI / Swagger Validation & Coverage (push) Successful in 2m36s
CI / Tests & coverage (push) Successful in 3m15s
2026-05-23 20:52:46 +01:00
gronod d1db3118f0 chore: bump version to 1.7.8 and update CHANGELOG
Build and Push Docker Image / build (push) Successful in 2m9s
CI / Security audit (push) Successful in 2m32s
Docs Check / Markdown lint (push) Successful in 2m34s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 3m4s
CI / Swagger Validation & Coverage (push) Successful in 3m55s
Docs Check / Mermaid diagram parse check (push) Successful in 4m18s
CI / Tests & coverage (push) Successful in 4m34s
2026-05-23 20:52:27 +01:00
gronod f8aa90011e merge branch 'develop' into 'main' - Release v1.7.7
Create Release / release (push) Successful in 22s
Build and Push Docker Image / build (push) Successful in 2m3s
CI / Security audit (push) Successful in 1m56s
CI / Tests & coverage (push) Successful in 2m28s
CI / Swagger Validation & Coverage (push) Successful in 2m21s
2026-05-23 20:38:14 +01:00
gronod 82b3824658 chore: bump version to 1.7.7 and update CHANGELOG
Build and Push Docker Image / build (push) Successful in 2m17s
Docs Check / Markdown lint (push) Successful in 2m27s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 2m44s
CI / Security audit (push) Successful in 3m10s
Docs Check / Mermaid diagram parse check (push) Successful in 3m54s
CI / Tests & coverage (push) Successful in 4m6s
CI / Swagger Validation & Coverage (push) Successful in 4m23s
2026-05-23 20:38:05 +01:00
gronod 49e3261b59 ci: use RELEASE_TOKEN for Gitea Container Registry authentication
CI / Security audit (push) Successful in 2m21s
CI / Swagger Validation & Coverage (push) Successful in 2m36s
CI / Tests & coverage (push) Successful in 3m0s
Build and Push Docker Image / build (push) Successful in 2m30s
2026-05-23 19:43:28 +01:00
gronod 2934becf32 ci: publish Docker container image to Gitea Package Registry in parallel
CI / Security audit (push) Successful in 1m58s
CI / Swagger Validation & Coverage (push) Successful in 2m25s
CI / Tests & coverage (push) Successful in 3m0s
Build and Push Docker Image / build (push) Failing after 1m38s
2026-05-23 19:01:38 +01:00
7 changed files with 225 additions and 19 deletions
+20 -3
View File
@@ -23,17 +23,34 @@ jobs:
if [[ "$BRANCH" == develop* ]]; then
# Sanitise branch name for tag: replace slashes with dashes
SAFE_BRANCH=$(echo "$BRANCH" | tr '/' '-')
echo "tags=reg.i3omb.com/sofarr:${SAFE_BRANCH}" >> $GITHUB_OUTPUT
echo "Building develop image ${SAFE_BRANCH} (version ${VERSION})"
TAGS="reg.i3omb.com/sofarr:${SAFE_BRANCH}"
TAGS="${TAGS},git.i3omb.com/gandalf/sofarr:${SAFE_BRANCH}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "Building develop image tags: ${TAGS}"
else
RELEASE_NAME=${BRANCH#release/}
# Primary registry tags
TAGS="reg.i3omb.com/sofarr:${VERSION}"
TAGS="${TAGS},reg.i3omb.com/sofarr:${RELEASE_NAME}"
TAGS="${TAGS},reg.i3omb.com/sofarr:latest"
# Gitea package registry tags
TAGS="${TAGS},git.i3omb.com/gandalf/sofarr:${VERSION}"
TAGS="${TAGS},git.i3omb.com/gandalf/sofarr:${RELEASE_NAME}"
TAGS="${TAGS},git.i3omb.com/gandalf/sofarr:latest"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "Building release image ${VERSION} from branch ${BRANCH}"
echo "Building release image tags: ${TAGS}"
fi
- name: Log into Gitea Container Registry
uses: docker/login-action@v3
with:
registry: git.i3omb.com
username: ${{ github.actor }}
password: ${{ secrets.RELEASE_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
+25
View File
@@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file.
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.7.9] - 2026-05-23
### Fixed
- **Ombi webhook PascalCase payload parsing (Re-release)** — Correctly packaged and released the Ombi webhook parsing logic to handle PascalCase property names (e.g., `NotificationType`, `RequestId`) sent by C#/.NET applications. This ensures standard Ombi webhook integrations function correctly. Resolves Gitea Issue [#42](https://git.i3omb.com/Gandalf/sofarr/issues/42).
---
## [1.7.8] - 2026-05-23
### Fixed
- **Ombi webhook PascalCase payload parsing** — Updated the Ombi webhook parsing logic to correctly handle payloads formatted with PascalCase property names (e.g. `NotificationType`, `RequestId`), which are often sent by C#/.NET applications. This ensures that new requests generated via Ombi's standard webhook integrations are correctly processed and displayed in the frontend dashboard. Resolves Gitea Issue [#42](https://git.i3omb.com/Gandalf/sofarr/issues/42).
---
## [1.7.7] - 2026-05-23
### Fixed
- **Ombi webhook NewRequest parsing support** — Added `'NewRequest'` to `VALID_EVENT_TYPES` and `OMBI_EVENTS` sets in `server/routes/webhook.js`. When a user submits a new media request in Ombi, the backend now successfully parses the webhook payload, bypasses the request cache, fetches the latest request list, and broadcasts it to all connected dashboard screens via SSE in real time. Previously, these webhook payloads were rejected with a `400 Bad Request` error. Resolves Gitea Issue [#42](https://git.i3omb.com/Gandalf/sofarr/issues/42).
- **Ombi webhook integration tests** — Implemented a robust integration test suite in `tests/integration/webhook.test.js` validating `POST /api/webhook/ombi` payloads, secret keys, duplicate/replay protection, input checks, and cache refresh triggers.
---
## [1.7.6] - 2026-05-23
### Fixed
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "sofarr",
"version": "1.7.6",
"version": "1.7.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sofarr",
"version": "1.7.6",
"version": "1.7.9",
"license": "MIT",
"dependencies": {
"axios": "^1.6.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sofarr",
"version": "1.7.6",
"version": "1.7.9",
"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": {
+9 -5
View File
@@ -87,7 +87,7 @@ const VALID_EVENT_TYPES = new Set([
'Rename', 'SeriesAdd', 'SeriesDelete', 'MovieAdd', 'MovieDelete',
'MovieFileDelete', 'Health', 'ApplicationUpdate', 'HealthRestored',
// Ombi notification types
'RequestAvailable', 'RequestApproved', 'RequestDeclined', 'RequestPending', 'RequestProcessing'
'NewRequest', 'RequestAvailable', 'RequestApproved', 'RequestDeclined', 'RequestPending', 'RequestProcessing'
]);
// Replay protection — cache recently-seen (eventType+instanceName+timestamp) keys.
@@ -135,6 +135,7 @@ const HISTORY_EVENTS = new Set([
// Ombi event types — all Ombi events refresh the requests cache
const OMBI_EVENTS = new Set([
'NewRequest',
'RequestAvailable',
'RequestApproved',
'RequestDeclined',
@@ -716,9 +717,12 @@ router.post('/ombi', webhookLimiter, (req, res) => {
return res.status(401).json({ error: 'Unauthorized' });
}
// Ombi uses notificationType instead of eventType
const { notificationType, requestId, requestedUser, applicationUrl } = req.body;
const eventType = notificationType || req.body.eventType;
// Ombi uses notificationType instead of eventType. Support PascalCase for .NET apps
const notificationType = req.body.notificationType || req.body.NotificationType;
const requestId = req.body.requestId || req.body.RequestId;
const applicationUrl = req.body.applicationUrl || req.body.ApplicationUrl;
const eventType = notificationType || req.body.eventType || req.body.EventType;
// Extract username from requestedUser (handles both object and string formats)
const username = extractRequestedUser(req.body);
@@ -731,7 +735,7 @@ router.post('/ombi', webhookLimiter, (req, res) => {
// Use applicationUrl as instance identifier for replay protection
const instanceName = applicationUrl || 'ombi';
// Use requestId + eventType + current time as replay key
const eventDate = req.body.requestedDate || new Date().toISOString();
const eventDate = req.body.requestedDate || req.body.RequestedDate || new Date().toISOString();
if (isReplay(eventType, instanceName, `${requestId}-${eventDate}`)) {
logToFile(`[Webhook] Ombi duplicate event ignored: ${eventType} requestId=${requestId}`);
+9 -7
View File
@@ -15,17 +15,19 @@
function extractRequestedUser(request) {
if (!request) return '';
const requestedUser = request.requestedUser || request.RequestedUser;
// Handle object format: OmbiStore.Entities.OmbiUser
if (request.requestedUser && typeof request.requestedUser === 'object') {
if (requestedUser && typeof requestedUser === 'object') {
// Priority: alias > userAlias > userName > normalizedUserName > requestedByAlias
return request.requestedUser.alias ||
request.requestedUser.userAlias ||
request.requestedUser.userName ||
request.requestedUser.normalizedUserName ||
request.requestedByAlias || '';
return requestedUser.alias || requestedUser.Alias ||
requestedUser.userAlias || requestedUser.UserAlias ||
requestedUser.userName || requestedUser.UserName ||
requestedUser.normalizedUserName || requestedUser.NormalizedUserName ||
request.requestedByAlias || request.RequestedByAlias || '';
}
// Handle string format (fallback for compatibility)
return request.requestedUser || request.requestedByAlias || '';
return requestedUser || request.requestedByAlias || request.RequestedByAlias || '';
}
function filterRequestsByUser(requests, username, showAll) {
+159 -1
View File
@@ -97,6 +97,9 @@ function makeApp() {
process.env.RADARR_INSTANCES = JSON.stringify([
{ id: 'radarr-1', name: 'Main Radarr', url: 'https://radarr.test', apiKey: 'rk' }
]);
process.env.OMBI_INSTANCES = JSON.stringify([
{ id: 'ombi-1', name: 'Main Ombi', url: 'https://ombi.test', apiKey: 'ok' }
]);
return createApp({ skipRateLimits: true });
}
@@ -113,9 +116,10 @@ function postRadarr(app, payload, secret = VALID_SECRET) {
}
beforeEach(() => {
// Block outbound *arr calls made by processWebhookEvent (fire-and-forget)
// Block outbound *arr and Ombi calls made by processWebhookEvent (fire-and-forget)
nock('https://sonarr.test').persist().get(/.*/).reply(200, { records: [] });
nock('https://radarr.test').persist().get(/.*/).reply(200, { records: [] });
nock('https://ombi.test').persist().get(/.*/).reply(200, []);
});
afterEach(() => {
@@ -125,6 +129,7 @@ afterEach(() => {
delete process.env.SOFARR_BASE_URL;
delete process.env.SONARR_INSTANCES;
delete process.env.RADARR_INSTANCES;
delete process.env.OMBI_INSTANCES;
});
// ---------------------------------------------------------------------------
@@ -518,3 +523,156 @@ describe('GET /api/webhook/config', () => {
expect(res.body.missing).toHaveLength(2);
});
});
// ---------------------------------------------------------------------------
// Ombi webhook receiver
// ---------------------------------------------------------------------------
describe('POST /api/webhook/ombi', () => {
function postOmbi(app, payload, secret = VALID_SECRET) {
const req = request(app).post('/api/webhook/ombi').send(payload);
if (secret !== null) req.set('X-Sofarr-Webhook-Secret', secret);
return req;
}
it('returns 401 when X-Sofarr-Webhook-Secret header is missing', async () => {
const app = makeApp();
const res = await postOmbi(app, { notificationType: 'NewRequest', requestId: 1 }, null);
expect(res.status).toBe(401);
expect(res.body.error).toBe('Unauthorized');
});
it('returns 401 when X-Sofarr-Webhook-Secret header is wrong', async () => {
const app = makeApp();
const res = await postOmbi(app, { notificationType: 'NewRequest', requestId: 1 }, 'wrong-secret');
expect(res.status).toBe(401);
expect(res.body.error).toBe('Unauthorized');
});
it('returns 400 when notificationType is missing or invalid', async () => {
const app = makeApp();
const res = await postOmbi(app, { requestId: 1 });
expect(res.status).toBe(400);
expect(res.body.error).toBe('Invalid or missing notificationType');
});
it('returns 400 when notificationType is unknown', async () => {
const app = makeApp();
const res = await postOmbi(app, { notificationType: 'UnknownNotification', requestId: 1 });
expect(res.status).toBe(400);
expect(res.body.error).toBe('Invalid or missing notificationType');
});
it('returns 200 { received: true } for a valid NewRequest event', async () => {
const app = makeApp();
// Nock requests endpoint since processWebhookEvent will fetch requests
nock('https://ombi.test')
.get('/api/v1/Request/movie')
.reply(200, []);
nock('https://ombi.test')
.get('/api/v1/Request/tv')
.reply(200, []);
const payload = {
notificationType: 'NewRequest',
requestId: 123,
requestedUser: 'gordon',
title: 'New Movie',
type: 'Movie',
requestStatus: 'Pending',
applicationUrl: 'https://ombi.test',
requestedDate: '2026-05-23T20:30:00.000Z'
};
const res = await postOmbi(app, payload);
expect(res.status).toBe(200);
expect(res.body.received).toBe(true);
expect(res.body.duplicate).toBeUndefined();
});
it('returns 200 { received: true } for a valid RequestAvailable event', async () => {
const app = makeApp();
nock('https://ombi.test')
.get('/api/v1/Request/movie')
.reply(200, []);
nock('https://ombi.test')
.get('/api/v1/Request/tv')
.reply(200, []);
const payload = {
notificationType: 'RequestAvailable',
requestId: 124,
requestedUser: 'gordon',
title: 'Available Movie',
type: 'Movie',
requestStatus: 'Available',
applicationUrl: 'https://ombi.test',
requestedDate: '2026-05-23T20:31:00.000Z'
};
const res = await postOmbi(app, payload);
expect(res.status).toBe(200);
expect(res.body.received).toBe(true);
});
it('returns duplicate: true for a replay of the same event', async () => {
const app = makeApp();
nock('https://ombi.test').persist()
.get('/api/v1/Request/movie')
.reply(200, []);
nock('https://ombi.test').persist()
.get('/api/v1/Request/tv')
.reply(200, []);
const payload = {
notificationType: 'NewRequest',
requestId: 125,
requestedUser: 'gordon',
title: 'New Movie',
type: 'Movie',
requestStatus: 'Pending',
applicationUrl: 'https://ombi.test',
requestedDate: '2026-05-23T20:32:00.000Z'
};
// First request
const res1 = await postOmbi(app, payload);
expect(res1.status).toBe(200);
expect(res1.body.duplicate).toBeUndefined();
// Replay
const res2 = await postOmbi(app, payload);
expect(res2.status).toBe(200);
expect(res2.body.duplicate).toBe(true);
});
it('returns 200 { received: true } for a valid NewRequest event with PascalCase payload', async () => {
const app = makeApp();
nock('https://ombi.test')
.get('/api/v1/Request/movie')
.reply(200, []);
nock('https://ombi.test')
.get('/api/v1/Request/tv')
.reply(200, []);
const payload = {
NotificationType: 'NewRequest',
RequestId: 126,
RequestedUser: { UserName: 'gordon_pascal' },
Title: 'Pascal Movie',
Type: 'Movie',
RequestStatus: 'Pending',
ApplicationUrl: 'https://ombi.test',
RequestedDate: '2026-05-23T20:33:00.000Z'
};
const res = await postOmbi(app, payload);
expect(res.status).toBe(200);
expect(res.body.received).toBe(true);
expect(res.body.duplicate).toBeUndefined();
});
});