Fix issue with media permissions on Linux (#3355)

This commit is contained in:
j0794
2025-03-13 21:58:14 +05:00
committed by GitHub
parent eeddb8f897
commit 4ec27f3e7c
2 changed files with 10 additions and 8 deletions

View File

@@ -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', () => {

View File

@@ -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');
} }