Fix issue with media permissions on Linux (#3355)
This commit is contained in:
@@ -60,13 +60,15 @@ jest.mock('main/windows/mainWindow', () => ({
|
|||||||
|
|
||||||
describe('main/PermissionsManager', () => {
|
describe('main/PermissionsManager', () => {
|
||||||
describe('setForServer', () => {
|
describe('setForServer', () => {
|
||||||
it('should ask for media permission when is not granted but the user explicitly granted it', () => {
|
if (process.platform !== 'linux') {
|
||||||
systemPreferences.getMediaAccessStatus.mockReturnValue('denied');
|
it('should ask for media permission when is not granted but the user explicitly granted it', () => {
|
||||||
const permissionsManager = new PermissionsManager('anyfile.json');
|
systemPreferences.getMediaAccessStatus.mockReturnValue('denied');
|
||||||
permissionsManager.setForServer({url: new URL('http://anyurl.com')}, {media: {allowed: true}});
|
const permissionsManager = new PermissionsManager('anyfile.json');
|
||||||
expect(systemPreferences.askForMediaAccess).toHaveBeenNthCalledWith(1, 'microphone');
|
permissionsManager.setForServer({url: new URL('http://anyurl.com')}, {media: {allowed: true}});
|
||||||
expect(systemPreferences.askForMediaAccess).toHaveBeenNthCalledWith(2, 'camera');
|
expect(systemPreferences.askForMediaAccess).toHaveBeenNthCalledWith(1, 'microphone');
|
||||||
});
|
expect(systemPreferences.askForMediaAccess).toHaveBeenNthCalledWith(2, 'camera');
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handlePermissionRequest', () => {
|
describe('handlePermissionRequest', () => {
|
||||||
|
@@ -95,7 +95,7 @@ export class PermissionsManager extends JsonFileManager<PermissionsByOrigin> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
setForServer = (server: MattermostServer, permissions: Permissions) => {
|
setForServer = (server: MattermostServer, permissions: Permissions) => {
|
||||||
if (permissions.media?.allowed) {
|
if (permissions.media?.allowed && (process.platform === 'win32' || process.platform === 'darwin')) {
|
||||||
this.checkMediaAccess('microphone');
|
this.checkMediaAccess('microphone');
|
||||||
this.checkMediaAccess('camera');
|
this.checkMediaAccess('camera');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user