Merge pull request #1310 from k9withabone/socket-fixes

Socket fixes
This commit is contained in:
advplyr 2022-12-23 07:47:32 -06:00 committed by GitHub
commit 43d9e129a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 12 deletions

View File

@ -41,9 +41,9 @@ 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)
res.json(req.series.toJSON())
}
middleware(req, res, next) {

View File

@ -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()
})

View File

@ -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()
}

View File

@ -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}"`)
}

View File

@ -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

View File

@ -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()))
}
}
}

View File

@ -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