-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
No new mail notification #37
Comments
I think the problem is the check against the aria-label and the configured language. If the configured language is not english, the following check will fail
since The only thing which should work for each configured language is searching for div's with a left border (Unread message). At least in my environment this border is always set to class |
good to know that. this class value will change anytime when Microsoft update outlook.com It's been changed a few times in the passed. I'll have a look if there is a better solution for that |
Wouldn't it be easier to use the count of unread messages directly from the navigation bar instead trying to parse all messages? The mutation observer callback should already contain the span element that contains the count of unread messages, so it wouldn't even be necessary to parse the DOM for the unread message count. When storing the previous count it would be also possible to show the delta count of new messages received since last notification/application start. Or do i miss something? If you want I can create a pull request for this change. |
Maybe i found a even better way, that would also remove the need for the span class name at all. Every time a new mail is received, Outlook will perform multiple request to fetch the new mail, notification sound ..... In electron it's possible to register a callback for webrequests: https://www.electronjs.org/docs/api/web-request So it would be possible to listen for the webrequest of the e.g. newmail.mp3 this.win.webContents.on('dom-ready', () => {
this.win.webContents.insertCSS(CssInjector.main);
if (!showWindowFrame) this.win.webContents.insertCSS(CssInjector.noFrame);
// this.addUnreadNumberObserver();
session.defaultSession.webRequest.onBeforeRequest({urls: ["*://*/**/newmail.mp3"]},()=>{
this.win.webContents.executeJavaScript(`
try{
require('electron').ipcRenderer.send('updateUnread', true);
var notification = new Notification("Outlook - receiving new messages.", {
icon: "assets/outlook_linux_black.png"
});
notification.onclick = () => {
require('electron').ipcRenderer.send('show');
};
}catch(ex){
alert(ex);
}
`);
});
this.win.show()
}); This will even work if newmail.mp3 is cached by the browser I'm not sure if this also works for hotmail and if its possible to disable the sound so that the download of newmail.mp3 is not performed. |
I think it might be even possible to intercept the subscription response, to receive also the email body, but I haven't found out yet if the push is done via websocket or a SSE. Request executed to create the push seems to be same as described in https://docs.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/notify-rest-operations |
Just reconized that outlook uses fabric ui. Notifications/Callouts in fabri ui are rendered in special div, so it's also possible to add a observer to this area to receive email subject, body .... addUnreadNumberObserver() {
this.win.webContents.executeJavaScript(`
setTimeout(() => {
const layerDiv = document.querySelector(".ms-Layer-content");
const observer = new MutationObserver(mutations => {
const emailDiv = document.querySelector("._9Ie6sVh0VX-ro9NAPwFKb");
// First childnode == email adress, Second childnode == subject, Third child node == email body
if(emailDiv){
const notification = new Notification("Outlook - received new message " + emailDiv.childNodes[1].textContent, {
body: emailDiv.childNodes[0].textContent + "\\n" + emailDiv.childNodes[1].textContent + "\\n" + emailDiv.childNodes[2].textContent,
icon: "assets/outlook_linux_black.png"
});
notification.onclick = () => {
require('electron').ipcRenderer.send('show');
};
}
});
observer.observe(layerDiv, {childList: true, subtree: true});
}, 10000);
`)
} |
@roggenbrot listen to the newmail.mp3 sounds very hacky for me and I reckon it might not working in the variate user settings. I am quite like your fabric ui solution. Could you make a pull request? and I'll test on the hotmail account see if that works. Many thanks. |
I think i found a even better solution. In the browser you are able to enable desktop notifications in the settings This feature is disabled in the electron app because of the missing/wrong user-agent header. So instead registering a observer, parsing the DOM .... the easiest solution is to set the user-agent when loading the page:
After setting the user-agent, the desktop notification can be enabled in the settings and will also work for other O365 notifications (e.g. calendar notifications ...) I've changed the pull request |
@roggenbrot have you changed this solution in the PR? I still see the previous observer in the PR. Let me know when you change it, I'll merge it in with your spell checking logic as well. |
The outlook desktop notification do not work as I expected. They only show notifications when outlook is closed, but browser is still open. In my local test it just worked because firefox was still running, so it was firefox that showed the notification, not electron :( So back to observer ...... I'm trying to find a better approach to get rid of the class names. I'm trying to implement a function at the moment that searches on startup based on a checksum the correct class name, and only fallback to configured class names if the user changes it in the settings. Normally content of component styles are changed not very often in a apps like owa,so if the class name changes cause of a recompile/new version, the checksum mechanism should still work |
Finished the pull request. Can someone test if the notifications for emails/reminders also work on hotmail? |
@hookumsnivy You can try the pull request if this will fix your problems (I could also create a AppImage of the pull request) I've also fixed a bug in the pull request that caused settings to reset on next startup |
This solution looks very hacky and can stopped to work in any time. I'd like to keep this open until have a better solution. Any idea is welcomed. |
OS: Fedora 32
Freelook Ver: 1.0.1
when receive new mail don't show notification.
The text was updated successfully, but these errors were encountered: