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 globalize from '../../scripts/globalize';
import ServerConnections from '../../components/ServerConnections';
import alert from '../../components/alert';
2023-03-08 11:03:48 -05:00
import { PluginType } from '../../types/plugin.ts';
2018-10-23 01:05:09 +03:00
function showErrorMessage() {
return alert(globalize.translate('MessagePlayAccessRestricted'));
}
2018-10-23 01:05:09 +03:00
class PlayAccessValidation {
constructor() {
this.name = 'Playback validation';
2023-03-08 11:03:48 -05:00
this.type = PluginType.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();
}
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();
}
2021-02-03 09:49:08 +01:00
return showErrorMessage().finally(Promise.reject);
});
}
}
export default PlayAccessValidation;