From 2cba83f1dd18d53c785be8f73341c5dd2a86d4db Mon Sep 17 00:00:00 2001 From: Paul Nettleton Date: Thu, 22 Dec 2022 16:26:11 -0600 Subject: [PATCH] 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