1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/plugins/playAccessValidation/plugin.js
vitorsemeano 5071aedcea extracted connectionManager from site.js
new module ServerConnections for ConnectionManager
all code adapted to this new module
removed Events and ConnectionManager from eslintrc
2020-11-05 23:12:23 +00:00

43 lines
1.2 KiB
JavaScript

import globalize from '../../scripts/globalize';
import ServerConnections from '../../components/ServerConnections';
function showErrorMessage() {
return import('../../components/alert').then(({default: alert}) => {
return alert(globalize.translate('MessagePlayAccessRestricted'));
});
}
class PlayAccessValidation {
constructor() {
this.name = 'Playback validation';
this.type = 'preplayintercept';
this.id = 'playaccessvalidation';
this.order = -2;
}
intercept(options) {
const item = options.item;
if (!item) {
return Promise.resolve();
}
const serverId = item.ServerId;
if (!serverId) {
return Promise.resolve();
}
return ServerConnections.getApiClient(serverId).getCurrentUser().then(function (user) {
if (user.Policy.EnableMediaPlayback) {
return Promise.resolve();
}
// reject but don't show an error message
if (!options.fullscreen) {
return Promise.reject();
}
return showErrorMessage();
});
}
}
export default PlayAccessValidation;