jashephe / Gmail-Notifier

Minimalist Gmail inbox notifications for Mac OS X.
BSD 2-Clause "Simplified" License
111 stars 11 forks source link

Multiple notifications if email is unread in inbox #30

Closed tetov closed 8 years ago

tetov commented 8 years ago

Firstly, thanks for the great work!

Recently, Gmail-notifier shows notifications every time it checks my inbox if an email is unread. So I keep getting notifications of the same email until I read it. My update interval is 5 minutes.

jashephe commented 8 years ago

Huh, that's interesting. The method that controls this can be seen here — it compares the ID of the message we are planning to deliver against the IDs of the messages that are already in the notification center. In your case, it sounds like this is always returning true.

Just before I go too much further, have you tried logging out of Gmail Notifier, quitting it, clearing any notifications in the Notification Center, restarting Gmail Notifier, and logging back in?

tetov commented 8 years ago

I think I understand the method, roughly. Is there a log file I can look at?

I logged out, quit the app, cleared Notification Center and restarted but still get notifications for same emails.

Thanks for looking into this!

jashephe commented 8 years ago

Weird. There isn't any logging in the pre-built binaries, but I can look into making a debug build for you. That might take me a few days, though — if you're comfortable building it, you can always try sticking in a few NSLog statements in that method and see if you get anything interesting. Maybe the messages aren't getting their uniqueIDs set when the inbox feed is parsed — probably would be best to add some logging here to check for that.

A few more questions:

tetov commented 8 years ago

I'll try to build it, haven't done any development in XCode before though so might not work out.

tetov commented 8 years ago

I just tried to add som NSLog statements, but there are lots of errors and warnings that I don't understand. I'm probably not knowledgable enough to build this on my own. Sorry.

jashephe commented 8 years ago

No worries; since you're on macOS 10.12 Sierra, it shouldn't be too hard for me to make another build.

It's interesting, though, because something like Little Snitch is exactly what I was thinking of when I asked if you had anything that was proxying your network connections. I can't imagine why that would cause any problems, but it doesn't make sense why you're the only person with this problem (at least, I don't have it, so n=2). Usually when there are problems like this, it's because Google has changed the inbox feed format or something, but then it breaks for everyone.

I'll try to make a debug build this evening. Just a few more questions:

tetov commented 8 years ago

I can do some testing with Little Snitch turned off, would that help?

Yeah, I'm v2.1.0

screen shot 2016-10-03 at 17 03 46

It is a typical account, *@gmail.com.

Thanks again for looking into this.

jashephe commented 8 years ago

Feel free to test things on your end — turning Little Snitch off briefly (if it isn't too much of a hassle) could be a good thing to try.

Before changing any settings, though, you should try visiting https://mail.google.com/mail/feed/atom in a browser where you've logged in to your email. Can you see an id tag for each message? Does the format look like the sample I've included below? If it looks the same, try refreshing after 5 minutes (your refresh interval) — does anything change?

<feed xmlns="http://purl.org/atom/ns#" version="0.3">
    <title>Gmail - Inbox for [redacted]</title>
    <tagline>New messages in your Gmail Inbox</tagline>
    <fullcount>1</fullcount>
    <link rel="alternate" href="https://mail.google.com/mail" type="text/html"/>
    <modified>2016-10-03T15:08:24Z</modified>
    <entry>
        <title>
            [jashephe/Gmail-Notifier] Multiple notifications if email is unread in inbox (#30)
        </title>
        <summary>
            I can do some testing with Little Snitch turned off, would that help? Yeah, I'm v2.1.0 screen shot 2016-10-03 at 17 03 46 It is a typical account, *@gmail.com. Thanks again for looking into this. —
        </summary>
        <link rel="alternate" href="https://mail.google.com/mail?account_id=[redacted]&message_id=1578b14285634734&view=conv&extsrc=atom" type="text/html"/>
        <modified>2016-10-03T15:05:36Z</modified>
        <issued>2016-10-03T15:05:36Z</issued>
        <id>tag:gmail.google.com,2004:1547181371265599284</id>
        <author>
            <name>sonyamamurin</name>
            <email>notifications@github.com</email>
        </author>
    </entry>
</feed>
tetov commented 8 years ago

I turned of network filtering for half an hour, still got multiple notifications for same emails. I'm going to test it with Little Snitch turned off next.

The XML output shows IDs consistent over time, so there seems to be nothing wrong with the feed.

<feed xmlns="http://purl.org/atom/ns#" version="0.3">
    <title>Gmail - Inbox for [redacted]</title>
    <tagline>New messages in your Gmail Inbox</tagline>
    <fullcount>2</fullcount>
    <link rel="alternate" href="https://mail.google.com/mail" type="text/html"/>
    <modified>2016-10-03T15:57:13Z</modified>
    <entry>
        <title>i</title>
        <summary/>
        <link rel="alternate" href="https://mail.google.com/mail?account_id=[redacted]&message_id=1578b3e5f15afee3&view=conv&extsrc=atom" type="text/html"/>
        <modified>2016-10-03T15:51:43Z</modified>
        <issued>2016-10-03T15:51:43Z</issued>
        <id>tag:gmail.google.com,2004:1547184272179920611</id>
        <author>
            <name>[redacted]</name>
            <email>[redacted]</email>
        </author>
    </entry>
    <entry>
        <title>t</title>
    <summary/>
    <link rel="alternate" href="https://mail.google.com/mail?account_id=[redacted]&message_id=1578b14e6e9b2977&view=conv&extsrc=atom" type="text/html"/>
    <modified>2016-10-03T15:06:25Z</modified>
    <issued>2016-10-03T15:06:25Z</issued>
    <id>tag:gmail.google.com,2004:1547181422422993271</id>
    <author>
            <name>[redacted]</name>
            <email>[redacted]</email>
        </author>
    </entry>
</feed>
jashephe commented 8 years ago

The format of the feed looks normal, but I notice that there's no summary content — did you redact that?

Just an update — I spent all evening wrangling with my SSH keys, because I was having a problem that was preventing me from accessing GitHub. Everything seems to be fixed now, so I'm hoping that I can have a debug build for you tomorrow. Sorry for the delay.

As for something to try in the meantime, if you have access to any other mac computers, could you try configuring Gmail Notifier with your account on a different machine to see if you have the same problem?

tetov commented 8 years ago

I just sent myself emails with no content, here is another example:

<feed xmlns="http://purl.org/atom/ns#" version="0.3">
   <title>Gmail - Inbox for [x]</title>
   <tagline>New messages in your Gmail Inbox</tagline>
   <fullcount>1</fullcount>
   <link rel="alternate" href="https://mail.google.com/mail" type="text/html"/>
   <modified>2016-10-04T08:31:47Z</modified>
   <entry>
      <title>Test</title>
      <summary>
         Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pharetra felis sapien, suscipit rhoncus eros placerat id. Suspendisse tincidunt nibh lorem. Nulla a nunc a nulla ornare condimentum quis
      </summary>
      <link rel="alternate" href="https://mail.google.com/mail?account_id=[x]&message_id=1578ed1c01fc6adf&view=conv&extsrc=atom" type="text/html"/>
      <modified>2016-10-04T08:31:33Z</modified>
      <issued>2016-10-04T08:31:33Z</issued>
      <id>tag:gmail.google.com,2004:1547247176549952223</id>
      <author>
         <name>[x]</name>
         <email>[x]</email>
      </author>
   </entry>
</feed>

No problem. I'm going away for a few days, back on Sunday. I'll try my account on my friends Mac today but I might not be able to test a debug build until next week.

tetov commented 8 years ago

Okay, two things.

jashephe commented 8 years ago

Well, that's useful information. Sorry that this is turning out to be such an endeavor. The next thing to try, maybe, would be to test Gmail Notifier with a different user account (i.e. same gmail account, different user login) on your computer. That could help us pinpoint whether whatever's causing this is a system-wide configuration or something specific to your user setup. If you don't have any other accounts on your computer, maybe you could enable the guest account.

tetov commented 8 years ago

I think I figured it out.

Under System Preferences --> Notifications --> Gmail Notifier I have had Alert style: Alerts. (See screenshot below)

When using Gmail Notifications with Banners instead I only got one notification per email. When I tested on my friends macbook I used banners since that is standard I believe. I will test this on another account now.

screen shot 2016-10-04 at 14 55 48

EDIT: Just tried it out on my admin account and reproduced it, multiple notifications when using alerts and normal behaviour when using banners.

jashephe commented 8 years ago

Interesting. I'm going to guess that if the alert is actively displayed on the screen, then it doesn't yet count as a "delivered notification." It seems like a potential solution could be to check both scheduledNotifications and deliveredNotifications, and look at the presented attribute. I wonder which categories alerts fall into — I'll have to do some testing.

Gmail Notifier defaults to banner alerts; do you prefer the alert style? I would assume that the alert buttons aren't active, because I didn't write any specialized code for them.

tetov commented 8 years ago

Hm, interesting that they are handled differently.

I prefer the alert style since I can't miss the notification even if I step away from the computer. (Maybe it shouldn't matter since my phone gets notified as well but it's convenient for me to handle email on desktop).

View and close works well, view takes you to your inbox/email (can't remember) and close closes the alert window.

jashephe commented 8 years ago

Ah, I think I've finally got it. Of course, when you click "Close" on the notification, it doesn't put the notification into the list of delivered notifications, because you've dismissed it. But Gmail Notifier doesn't keep a running list of the emails you've received — it just checks the inbox every n minutes, and for each message it finds, if there isn't already a corresponding notification in the Notification Center list, it sends a new notification.

But in your case, with the alert style, when you dismiss the alert it gets removed from the Notification Center's list of delivered notifications. Meaning that when the next update rolls around, that message is interpreted as a "new" message, and an alert gets sent again.

Unfortunately, this is largely working as intended (for this version, anyway). I designed Gmail Notifier with the idea that the Notification Center's delivered notifications list would be a mirror of what's currently in the inbox. I never really considered what would happen if you used an alert style, and it seems like it's not compatible with the current intended behavior. The application could be updated to keep a running list of all delivered emails, but this would require not-insignificant restructuring, and I would rather focus on version 3.0, which will eventually resolve this problem through the implementation of #29.

Sorry to have such an unsatisfying resolution, but the best advice I can offer is to use the banner style until the next version drops (or, of course, find an alternative that better fits your desired usage).

tetov commented 8 years ago

Okay, no problem! I'll use banner style instead. Thanks for all the help!

jashephe commented 8 years ago

Sure, thanks for the help. Feel free to subscribe to notifications on Issue #21 if you'd like to know when version 3 is ready.

tetov commented 8 years ago

Thanks, I just did!