From a9ee9031c38065ff39a4825a323d580024cc1bfd Mon Sep 17 00:00:00 2001 From: Paul Nettleton Date: Thu, 22 Dec 2022 16:04:42 -0600 Subject: [PATCH 1/3] Add rss feed minified --- server/objects/Feed.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/objects/Feed.js b/server/objects/Feed.js index 9e00d57c..bbc342b6 100644 --- a/server/objects/Feed.js +++ b/server/objects/Feed.js @@ -61,6 +61,15 @@ class Feed { } } + toJSONMinified() { + return { + id: this.id, + entityType: this.entityType, + entityId: this.entityId, + feedUrl: this.feedUrl + } + } + getEpisodePath(id) { var episode = this.episodes.find(ep => ep.id === id) if (!episode) return null From 2cba83f1dd18d53c785be8f73341c5dd2a86d4db Mon Sep 17 00:00:00 2001 From: Paul Nettleton Date: Thu, 22 Dec 2022 16:26:11 -0600 Subject: [PATCH 2/3] Server socket event fixes --- server/controllers/SeriesController.js | 2 +- server/controllers/UserController.js | 2 +- server/managers/NotificationManager.js | 2 +- server/managers/RssFeedManager.js | 4 ++-- server/routers/ApiRouter.js | 4 ++-- server/scanner/Scanner.js | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/controllers/SeriesController.js b/server/controllers/SeriesController.js index c5b56edf..b469b2a3 100644 --- a/server/controllers/SeriesController.js +++ b/server/controllers/SeriesController.js @@ -41,7 +41,7 @@ class SeriesController { const hasUpdated = req.series.update(req.body) if (hasUpdated) { await this.db.updateEntity('series', req.series) - SocketAuthority.emitter('series_updated', req.series) + SocketAuthority.emitter('series_updated', req.series.toJSON()) } res.json(req.series) } diff --git a/server/controllers/UserController.js b/server/controllers/UserController.js index 78ced4e9..af0ce0e1 100644 --- a/server/controllers/UserController.js +++ b/server/controllers/UserController.js @@ -48,7 +48,7 @@ class UserController { var newUser = new User(account) var success = await this.db.insertEntity('user', newUser) if (success) { - SocketAuthority.adminEmitter('user_added', newUser) + SocketAuthority.adminEmitter('user_added', newUser.toJSONForBrowser()) res.json({ user: newUser.toJSONForBrowser() }) diff --git a/server/managers/NotificationManager.js b/server/managers/NotificationManager.js index 33d13ab5..e13e99f9 100644 --- a/server/managers/NotificationManager.js +++ b/server/managers/NotificationManager.js @@ -58,7 +58,7 @@ class NotificationManager { } await this.db.updateEntity('settings', this.db.notificationSettings) - SocketAuthority.emitter('notifications_updated', this.db.notificationSettings) + SocketAuthority.emitter('notifications_updated', this.db.notificationSettings.toJSON()) this.notificationFinished() } diff --git a/server/managers/RssFeedManager.js b/server/managers/RssFeedManager.js index bd90b96c..42892c90 100644 --- a/server/managers/RssFeedManager.js +++ b/server/managers/RssFeedManager.js @@ -106,7 +106,7 @@ class RssFeedManager { Logger.debug(`[RssFeedManager] Opened RSS feed ${feed.feedUrl}`) await this.db.insertEntity('feed', feed) - SocketAuthority.emitter('rss_feed_open', { id: feed.id, entityType: feed.entityType, entityId: feed.entityId, feedUrl: feed.feedUrl }) + SocketAuthority.emitter('rss_feed_open', feed.toJSONMinified()) return feed } @@ -120,7 +120,7 @@ class RssFeedManager { if (!this.feeds[id]) return var feed = this.feeds[id] await this.db.removeEntity('feed', id) - SocketAuthority.emitter('rss_feed_closed', { id: feed.id, entityType: feed.entityType, entityId: feed.entityId, feedUrl: feed.feedUrl }) + SocketAuthority.emitter('rss_feed_closed', feed.toJSONMinified()) delete this.feeds[id] Logger.info(`[RssFeedManager] Closed RSS feed "${feed.feedUrl}"`) } diff --git a/server/routers/ApiRouter.js b/server/routers/ApiRouter.js index 30e00fa7..a4baa06b 100644 --- a/server/routers/ApiRouter.js +++ b/server/routers/ApiRouter.js @@ -476,7 +476,7 @@ class ApiRouter { } if (newAuthors.length) { await this.db.insertEntities('author', newAuthors) - SocketAuthority.emitter('authors_added', newAuthors) + SocketAuthority.emitter('authors_added', newAuthors.map(au => au.toJSON())) } } @@ -500,7 +500,7 @@ class ApiRouter { } if (newSeries.length) { await this.db.insertEntities('series', newSeries) - SocketAuthority.emitter('authors_added', newSeries) + SocketAuthority.emitter('multiple_series_added', newSeries.map(se => se.toJSON())) } } } diff --git a/server/scanner/Scanner.js b/server/scanner/Scanner.js index 542449f8..e9d3b549 100644 --- a/server/scanner/Scanner.js +++ b/server/scanner/Scanner.js @@ -477,7 +477,7 @@ class Scanner { }) if (newSeries.length) { await this.db.insertEntities('series', newSeries) - SocketAuthority.emitter('series_added', newSeries.map(se => se.toJSON())) + SocketAuthority.emitter('multiple_series_added', newSeries.map(se => se.toJSON())) } } } @@ -844,7 +844,7 @@ class Scanner { author = new Author() author.setData({ name: authorName }) await this.db.insertEntity('author', author) - SocketAuthority.emitter('author_added', author) + SocketAuthority.emitter('author_added', author.toJSON()) } authorPayload.push(author.toJSONMinimal()) } @@ -862,7 +862,7 @@ class Scanner { seriesItem = new Series() seriesItem.setData({ name: seriesMatchItem.series }) await this.db.insertEntity('series', seriesItem) - SocketAuthority.emitter('series_added', seriesItem) + SocketAuthority.emitter('series_added', seriesItem.toJSON()) } seriesPayload.push(seriesItem.toJSONMinimal(seriesMatchItem.sequence)) } @@ -984,7 +984,7 @@ class Scanner { Logger.info(`[Scanner] matchLibraryItems: Library match scan canceled for "${libraryScan.libraryName}"`) delete this.cancelLibraryScan[libraryScan.libraryId] var scanData = libraryScan.getScanEmitData - scanData.results = false + scanData.results = null SocketAuthority.emitter('scan_complete', scanData) this.librariesScanning = this.librariesScanning.filter(ls => ls.id !== library.id) return From e4c20d677c2318cde88fcfd160933f5638a78e04 Mon Sep 17 00:00:00 2001 From: advplyr <67830747+advplyr@users.noreply.github.com> Date: Fri, 23 Dec 2022 07:33:33 -0600 Subject: [PATCH 3/3] Update server/controllers/SeriesController.js Co-authored-by: Paul Nettleton --- server/controllers/SeriesController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/controllers/SeriesController.js b/server/controllers/SeriesController.js index b469b2a3..cc70495b 100644 --- a/server/controllers/SeriesController.js +++ b/server/controllers/SeriesController.js @@ -43,7 +43,7 @@ class SeriesController { await this.db.updateEntity('series', req.series) SocketAuthority.emitter('series_updated', req.series.toJSON()) } - res.json(req.series) + res.json(req.series.toJSON()) } middleware(req, res, next) {