mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-31 08:14:40 +02:00
Add book item more menu item for Share, restrict share to admin or up, add admin socket events for open/close shares
This commit is contained in:
parent
e05ab14ad2
commit
2f2ec2ec1f
11 changed files with 102 additions and 37 deletions
|
@ -43,7 +43,7 @@ class LibraryItemController {
|
|||
item.rssFeed = feedData?.toJSONMinified() || null
|
||||
}
|
||||
|
||||
if (item.mediaType === 'book' && includeEntities.includes('share')) {
|
||||
if (item.mediaType === 'book' && req.user.isAdminOrUp && includeEntities.includes('share')) {
|
||||
item.mediaItemShare = ShareManager.findByMediaItemId(item.media.id)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const Database = require('../Database')
|
||||
const Logger = require('../Logger')
|
||||
const SocketAuthority = require('../SocketAuthority')
|
||||
|
||||
/**
|
||||
* @typedef OpenMediaItemShareObject
|
||||
|
@ -136,6 +137,7 @@ class ShareManager {
|
|||
} else {
|
||||
this.openMediaItemShares.push({ id: mediaItemShare.id, mediaItemShare: mediaItemShare.toJSON() })
|
||||
}
|
||||
SocketAuthority.adminEmitter('share_open', mediaItemShare.toJSONForClient())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,6 +155,12 @@ class ShareManager {
|
|||
this.openMediaItemShares = this.openMediaItemShares.filter((s) => s.id !== mediaItemShareId)
|
||||
this.openSharePlaybackSessions = this.openSharePlaybackSessions.filter((s) => s.mediaItemShareId !== mediaItemShareId)
|
||||
await this.destroyMediaItemShare(mediaItemShareId)
|
||||
|
||||
const mediaItemShareObjectForClient = { ...mediaItemShare.mediaItemShare }
|
||||
delete mediaItemShareObjectForClient.pash
|
||||
delete mediaItemShareObjectForClient.userId
|
||||
delete mediaItemShareObjectForClient.extraData
|
||||
SocketAuthority.adminEmitter('share_closed', mediaItemShareObjectForClient)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -567,8 +567,8 @@ class LibraryItem extends Model {
|
|||
if (li.numEpisodesIncomplete) {
|
||||
oldLibraryItem.numEpisodesIncomplete = li.numEpisodesIncomplete
|
||||
}
|
||||
if (li.mediaType === 'book' && options.include?.includes?.('share')) {
|
||||
oldLibraryItem.mediaItemShare = ShareManager.findByMediaItemId(li.mediaId)
|
||||
if (li.mediaItemShare) {
|
||||
oldLibraryItem.mediaItemShare = li.mediaItemShare
|
||||
}
|
||||
|
||||
return oldLibraryItem
|
||||
|
|
|
@ -332,9 +332,9 @@ module.exports = {
|
|||
/**
|
||||
* Get library items for book media type using filter and sort
|
||||
* @param {string} libraryId
|
||||
* @param {[oldUser]} user
|
||||
* @param {[string]} filterGroup
|
||||
* @param {[string]} filterValue
|
||||
* @param {import('../../objects/user/User')} user
|
||||
* @param {string|null} filterGroup
|
||||
* @param {string|null} filterValue
|
||||
* @param {string} sortBy
|
||||
* @param {string} sortDesc
|
||||
* @param {boolean} collapseseries
|
||||
|
@ -356,7 +356,7 @@ module.exports = {
|
|||
sortBy = 'media.metadata.title'
|
||||
}
|
||||
const includeRSSFeed = include.includes('rssfeed')
|
||||
const includeMediaItemShare = include.includes('share')
|
||||
const includeMediaItemShare = !!user?.isAdminOrUp && include.includes('share')
|
||||
|
||||
// For sorting by author name an additional attribute must be added
|
||||
// with author names concatenated
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue