Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix external link that are 'outlook protected' are opened internal. #262

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ For other distributions please follow your specific steps.

```json
{
"urlMainWindow": "https://customurl.example/",
"urlsInternal": ["customurl.example"],
"urlsExternal": ["externalurls.example"],
"showWindowFrame": true
"urlMainWindow":"https://customurl.example/",
"deeplinkUrls":["customurl.example"],
"outlookUrls":["outlookurls.example"],
"externalUrls": ["externalurls.example"],
"showWindowFrame":true
}
```

Expand All @@ -88,11 +89,12 @@ Outlook.com account:
```json
{
"urlMainWindow": "https://outlook.live.com/mail",
"urlsInternal": ["outlook.com", "live.com"],
"urlsExternal": ["outlook.com", "live.com"]
"deeplinkUrls": ["outlook.com", "live.com"],
"outlookUrls": ["outlook.com", "live.com"]
}
```


### Architecture components

The main software architecture components and their versions are this:
Expand Down
40 changes: 26 additions & 14 deletions src/controller/mail-window-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ const settings = require("electron-settings");
const getClientFile = require("./client-injector");
const path = require("path");


let outlookUrl;
let deeplinkUrls;
let externalUrls;
let outlookUrls;
let showWindowFrame;
let $this;
Expand Down Expand Up @@ -47,10 +49,14 @@ class MailWindowController {
"outlook.office365.com",
"outlook.office.com",
];
externalUrls = settings.getSync('externalUrls') || [
'outlook.office.com/mail/safelink.html'
]
console.log("Loaded settings", {
outlookUrl: outlookUrl,
deeplinkUrls: deeplinkUrls,
outlookUrls: outlookUrls,
externalUrls: externalUrls,
});
}
init() {
Expand Down Expand Up @@ -195,20 +201,27 @@ class MailWindowController {

openInBrowser(e, url, frameName, disposition, options) {
console.log("Open in browser: " + url); //frameName,disposition,options)
if (new RegExp(deeplinkUrls.join("|")).test(url)) {
// Default action - if the user wants to open mail in a new window - let them.
//e.preventDefault()
console.log("Is deeplink");
options.webPreferences.affinity = "main-window";
} else if (new RegExp(outlookUrls.join("|")).test(url)) {
// Open calendar, contacts and tasks in the same window
e.preventDefault();
this.loadURL(url);
} else {
// Send everything else to the browser
e.preventDefault();
shell.openExternal(url);

if (!new RegExp(externalUrls.join("|")).test(url)) {
if (new RegExp(deeplinkUrls.join("|")).test(url)) {
// Default action - if the user wants to open mail in a new window - let them.
//e.preventDefault()
console.log("Is deeplink, open in main window");
options.webPreferences.affinity = "main-window";
return;
}
if (new RegExp(outlookUrls.join("|")).test(url)) {
// Open calendar, contacts and tasks in the same window
console.log("Is outlook URL, open in application");
e.preventDefault();
this.loadURL(url);
return;
}
}
// Send everything else to the browser
console.log("Is external URL, open in browser");
e.preventDefault();
shell.openExternal(url);
}

show() {
Expand Down Expand Up @@ -253,7 +266,6 @@ class MailWindowController {
);
}
//console.log(params)

for (const flag in params.editFlags) {
let actionLabel = flag.substring(3); //remove "can"
if (flag == "canSelectAll") {
Expand Down
Loading