示例#1
0
文件: message.py 项目: haystack/YouPS
 def add_flags_gmail(self, flags):
     # TODO see remove_flags_gmail same issue applies here
     if not self._imap_account.is_gmail:
         raise IsNotGmailException()
     if self._is_simulate:
         flags = message_helpers._check_flags(self, flags)
     uids = [m._uid for m in self.thread]
     if not self._is_simulate:
         message_helpers._flag_change_helper(self, uids, flags, self._imap_client.add_gmail_labels, self._imap_client.add_flags)
     for m in self.thread:
         message_helpers._save_flags(m, list(set(m.flags + flags)))
示例#2
0
文件: message.py 项目: haystack/YouPS
    def remove_flags_gmail(self, flags):

        # TODO this still feels broken. flags need to be removed from each message which has that flag
        # we need to go from the base message of this message to all the related messages
        # and then for each of those related messages if it contains a flag we want to remove
        # this from we need to remove that flag. but that requires calling imap_client.select_folder() which
        # i want to avoid

        if not self._imap_account.is_gmail:
            raise IsNotGmailException()
        uids = [m._uid for m in self.thread]
        if not self._is_simulate:
            message_helpers._flag_change_helper(self, uids, flags, self._imap_client.remove_gmail_labels, self._imap_client.remove_flags)
        for m in self.thread:
            message_helpers._save_flags(m, list(set(m.flags) - set(flags)))
示例#3
0
文件: message.py 项目: soyapark/YouPS
    def remove_flags(self, flags):
        # type: (t.Union[t.Iterable[t.AnyStr], t.AnyStr]) -> None
        """Remove each of the flags in a list of flags from the message

        This method can also optionally take a single string as a flag.
        """
        if self._is_simulate:
            flags = message_helpers._check_flags(self, flags)
        if not self._is_simulate:
            message_helpers._flag_change_helper(
                self, self._uid, flags, self._imap_client.remove_gmail_labels,
                self._imap_client.remove_flags)

        # update the local flags
        message_helpers._save_flags(self, list(set(self.flags) - set(flags)))
示例#4
0
文件: message.py 项目: soyapark/YouPS
    def add_flags(self, flags):
        # type: (t.Union[t.Iterable[t.AnyStr], t.AnyStr]) -> None
        """Add each of the flags in a list of flags to the message

        This method can also optionally take a single string as a flag.
        """
        if self._is_simulate:
            flags = message_helpers._check_flags(self, flags)
        # add known flags to the correct place. i.e. \\Seen flag is not a gmail label
        if not self._is_simulate:
            message_helpers._flag_change_helper(
                self, self._uid, flags, self._imap_client.add_gmail_labels,
                self._imap_client.add_flags)

        message_helpers._save_flags(self, list(set(self.flags + flags)))