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

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-08-16 20:24:45 +02:00
import { ConnectionManager } from 'jellyfin-apiclient';
import globalize from '../../scripts/globalize';
2018-10-23 01:05:09 +03:00
function showErrorMessage() {
2020-08-16 20:24:45 +02:00
return import('../../components/alert').then(({default: alert}) => {
return alert(globalize.translate('MessagePlayAccessRestricted'));
});
}
2018-10-23 01:05:09 +03:00
class PlayAccessValidation {
constructor() {
this.name = 'Playback validation';
this.type = 'preplayintercept';
this.id = 'playaccessvalidation';
this.order = -2;
2018-10-23 01:05:09 +03:00
}
intercept(options) {
const item = options.item;
if (!item) {
return Promise.resolve();
}
const serverId = item.ServerId;
if (!serverId) {
return Promise.resolve();
}
2020-08-16 20:24:45 +02:00
return ConnectionManager.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;