This commit is contained in:
parent
049335be9d
commit
b1b8c196b7
|
@ -71,3 +71,12 @@ export function getLocalPreload(file) {
|
|||
}
|
||||
return path.resolve(__dirname, `../../dist/${file}`);
|
||||
}
|
||||
|
||||
export function composeUserAgent() {
|
||||
const baseUserAgent = app.userAgentFallback.split(' ');
|
||||
|
||||
// filter out the Mattermost tag that gets added earlier on
|
||||
const filteredUserAgent = baseUserAgent.filter((ua) => !ua.startsWith('Mattermost'));
|
||||
|
||||
return `${filteredUserAgent.join(' ')} Mattermost/${app.getVersion()}`;
|
||||
}
|
||||
|
|
|
@ -22,15 +22,12 @@ import {
|
|||
} from 'common/communication';
|
||||
|
||||
import ContextMenu from '../contextMenu';
|
||||
import {getWindowBoundaries, getLocalPreload} from '../utils';
|
||||
import {getWindowBoundaries, getLocalPreload, composeUserAgent} from '../utils';
|
||||
import * as WindowManager from '../windows/windowManager';
|
||||
import * as appState from '../appState';
|
||||
|
||||
import {removeWebContentsListeners} from './webContentEvents';
|
||||
|
||||
// copying what webview sends
|
||||
// TODO: review
|
||||
const userAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.146 Electron/6.1.7 Safari/537.36 Mattermost/${app.getVersion()}`;
|
||||
const READY = 1;
|
||||
const WAITING_MM = 2;
|
||||
const LOADING = 0;
|
||||
|
@ -104,7 +101,7 @@ export class MattermostView extends EventEmitter {
|
|||
load = (someURL) => {
|
||||
const loadURL = (typeof someURL === 'undefined') ? `${this.server.url.toString()}` : urlUtils.parseURL(someURL).toString();
|
||||
log.info(`[${Util.shorten(this.server.name)}] Loading ${loadURL}`);
|
||||
const loading = this.view.webContents.loadURL(loadURL, {userAgent});
|
||||
const loading = this.view.webContents.loadURL(loadURL, {userAgent: composeUserAgent()});
|
||||
loading.then(this.loadSuccess(loadURL)).catch((err) => {
|
||||
this.loadRetry(loadURL, err);
|
||||
});
|
||||
|
@ -116,7 +113,7 @@ export class MattermostView extends EventEmitter {
|
|||
if (!this.view) {
|
||||
return;
|
||||
}
|
||||
const loading = this.view.webContents.loadURL(loadURL, {userAgent});
|
||||
const loading = this.view.webContents.loadURL(loadURL, {userAgent: composeUserAgent()});
|
||||
loading.then(this.loadSuccess(loadURL)).catch((err) => {
|
||||
if (this.maxRetries-- > 0) {
|
||||
this.loadRetry(loadURL, err);
|
||||
|
|
|
@ -13,6 +13,7 @@ import * as WindowManager from '../windows/windowManager';
|
|||
import {protocols} from '../../../electron-builder.json';
|
||||
|
||||
import allowProtocolDialog from '../allowProtocolDialog';
|
||||
import {composeUserAgent} from '../utils';
|
||||
|
||||
const customLogins = {};
|
||||
const listeners = {};
|
||||
|
@ -28,18 +29,6 @@ function isTrustedPopupWindow(webContents) {
|
|||
return Utils.browserWindowFromWebContents(webContents) === popupWindow;
|
||||
}
|
||||
|
||||
const nixUA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome Safari/537.36';
|
||||
|
||||
const popupUserAgent = {
|
||||
darwin: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome Safari/537.36',
|
||||
win32: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome Safari/537.36',
|
||||
aix: nixUA,
|
||||
freebsd: nixUA,
|
||||
linux: nixUA,
|
||||
openbsd: nixUA,
|
||||
sunos: nixUA,
|
||||
};
|
||||
|
||||
const scheme = protocols && protocols[0] && protocols[0].schemes && protocols[0].schemes[0];
|
||||
|
||||
const generateWillNavigate = (getServersFunction) => {
|
||||
|
@ -191,7 +180,7 @@ const generateNewWindowListener = (getServersFunction, spellcheck) => {
|
|||
// currently changing the userAgent for popup windows to allow plugins to go through google's oAuth
|
||||
// should be removed once a proper oAuth2 implementation is setup.
|
||||
popupWindow.loadURL(url, {
|
||||
userAgent: popupUserAgent[process.platform],
|
||||
userAgent: composeUserAgent(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue