Commit 98b35d06 authored by Julian Andres Klode's avatar Julian Andres Klode

Make sure to only add one of INBOX, SPAM, TRASH labels

The gmail API fails with an error otherwise.

fixes #26
parent 9d03eea3
......@@ -111,3 +111,5 @@ You can get an [api key](https://console.developers.google.com/flows/enableapi?a
The GMail API does not let you sync `muted` messages. Until the [Google
bug](https://issuetracker.google.com/issues/36759067) is fixed, the `mute` and `muted` tags are not synchronized with the remote.
Only one of the tags `inbox`, `spam`, and `trash` may be added to an email. For
the time being, `trash` will be prefered over `spam`, and `spam` over inbox.
......@@ -435,6 +435,18 @@ class Remote:
self.all_updated = False
return None
if 'TRASH' in add:
if 'SPAM' in add:
print ("update: %s: Trying to add both TRASH and SPAM, dropping SPAM (add: %s, rem: %s)" % (mid, add, rem))
add.remove('SPAM')
if 'INBOX' in add:
print ("update: %s: Trying to add both TRASH and INBOX, dropping INBOX (add: %s, rem: %s)" % (mid, add, rem))
add.remove('INBOX')
elif 'SPAM' in add:
if 'INBOX' in add:
print ("update: %s: Trying to add both SPAM and INBOX, dropping INBOX (add: %s, rem: %s)" % (mid, add, rem))
add.remove('INBOX')
if self.dry_run:
print ("(dry-run) mid: %s: add: %s, remove: %s" % (mid, str(add), str(rem)))
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment