Beispiel #1
0
    def sync_folders(self):
        """
        Gmail-specific list of folders to sync.

        In Gmail, every message is in `All Mail`, with the exception of
        messages in the Trash and Spam folders. So we only sync the `All Mail`,
        Trash and Spam folders.

        Returns
        -------
        list
            Folders to sync (as strings).

        """
        present_folders = self.folder_names()

        if 'all' not in present_folders:
            raise GmailSettingError(
                "Account {} ({}) is missing the 'All Mail' folder. This is "
                "probably due to 'Show in IMAP' being disabled. "
                "Please enable at "
                "https://mail.google.com/mail/#settings/labels"
                .format(self.account_id, self.email_address))

        # If the account has Trash, Spam folders, sync those too.
        to_sync = []
        for folder in ['all', 'trash', 'spam']:
            if folder in present_folders:
                to_sync.append(present_folders[folder][0])
        return to_sync
Beispiel #2
0
    def sync_folders(self):
        """
        Gmail-specific list of folders to sync.

        In Gmail, every message is in `All Mail`, with the exception of
        messages in the Trash and Spam folders. So we only sync the `All Mail`,
        Trash and Spam folders.

        Returns
        -------
        list
            Folders to sync (as strings).

        """
        present_folders = self.folder_names()

        if 'all' not in present_folders:
            raise GmailSettingError(
                "Account {} is missing the 'All Mail' folder. This is "
                "probably due to 'Show in IMAP' being disabled. "
                "See https://support.nylas.com/hc/en-us/articles/217562277 "
                "for more details."
                .format(self.email_address))

        # If the account has Trash, Spam folders, sync those too.
        to_sync = []
        for folder in ['all', 'trash', 'spam']:
            if folder in present_folders:
                to_sync.append(present_folders[folder][0])
        return to_sync
Beispiel #3
0
def raise_setting_error(folder):
    raise GmailSettingError(folder)