def add_gmail_attrs(db_session, log, new_uid, flags, folder, g_thrid, g_msgid, g_labels, created): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = g_thrid new_uid.update_imap_flags(flags, g_labels) thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels new_labels = account.update_thread_labels(thread, folder.name, g_labels, db_session) # Reconciliation for Drafts, Sent Mail folders: if (('draft' in new_labels or 'sent' in new_labels) and not created and new_uid.message.inbox_uid): reconcile_message(db_session, log, new_uid.message.inbox_uid, new_uid.message) return new_uid
def add_message_attrs(self, db_session, new_uid, msg, folder): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = msg.g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = msg.g_thrid # we rely on Gmail's threading instead of our threading algorithm. new_uid.message.thread_order = 0 new_uid.update_imap_flags(msg.flags, msg.g_labels) # FIXME: @karim not sure if it's necessary to clean up strings like # \\Inbox, \\Trash, etc. new_uid.g_labels = [label for label in msg.g_labels] thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels common.update_thread_labels(thread, folder.name, msg.g_labels, db_session) return new_uid
def add_message_attrs(self, db_session, new_uid, msg, folder): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = msg.g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = msg.g_thrid # we rely on Gmail's threading instead of our threading algorithm. new_uid.message.thread_order = 0 new_uid.update_imap_flags(msg.flags, msg.g_labels) thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels new_labels = common.update_thread_labels(thread, folder.name, msg.g_labels, db_session) # Reconciliation for Drafts, Sent Mail folders: if (('draft' in new_labels or 'sent' in new_labels) and not msg.created and new_uid.message.inbox_uid): reconcile_message(db_session, new_uid.message.inbox_uid, new_uid.message) return new_uid
def add_message_attrs(self, db_session, new_uid, msg, folder): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = msg.g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = msg.g_thrid # we rely on Gmail's threading instead of our threading algorithm. new_uid.message.thread_order = 0 new_uid.update_imap_flags(msg.flags, msg.g_labels) thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels new_labels = common.update_thread_labels(thread, folder.name, msg.g_labels, db_session) # Reconciliation for Drafts, Sent Mail folders: if (('draft' in new_labels or 'sent' in new_labels) and not msg.created and new_uid.message.inbox_uid): reconcile_message(db_session, new_uid.message.inbox_uid, new_uid.message) return new_uid
def add_message_to_thread(self, db_session, message_obj, raw_message): """Associate message_obj to the right Thread object, creating a new thread if necessary. We rely on Gmail's threading as defined by X-GM-THRID instead of our threading algorithm.""" # NOTE: g_thrid == g_msgid on the first message in the thread message_obj.g_msgid = raw_message.g_msgid message_obj.g_thrid = raw_message.g_thrid with db_session.no_autoflush: # Disable autoflush so we don't try to flush a message with null # thread_id. message_obj.thread = ImapThread.from_gmail_message(db_session, self.namespace_id, message_obj)
def add_message_to_thread(self, db_session, message_obj, raw_message): """Associate message_obj to the right Thread object, creating a new thread if necessary. We rely on Gmail's threading as defined by X-GM-THRID instead of our threading algorithm.""" # NOTE: g_thrid == g_msgid on the first message in the thread message_obj.g_msgid = raw_message.g_msgid message_obj.g_thrid = raw_message.g_thrid with db_session.no_autoflush: # Disable autoflush so we don't try to flush a message with null # thread_id. message_obj.thread = ImapThread.from_gmail_message( db_session, self.namespace_id, message_obj)
def add_message_attrs(self, db_session, new_uid, msg): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_msgid = msg.g_msgid new_uid.message.g_thrid = msg.g_thrid # We rely on Gmail's threading instead of our threading algorithm. new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) return new_uid
def add_message_attrs(self, db_session, new_uid, msg): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_msgid = msg.g_msgid new_uid.message.g_thrid = msg.g_thrid # We rely on Gmail's threading instead of our threading algorithm. new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) return new_uid
def add_message_attrs(self, db_session, new_uid, msg): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = msg.g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = msg.g_thrid # we rely on Gmail's threading instead of our threading algorithm. new_uid.update_flags_and_labels(msg.flags, msg.g_labels) thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels common.add_any_new_thread_labels(thread, new_uid, db_session) return new_uid
def add_message_attrs(self, db_session, new_uid, msg): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = msg.g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = msg.g_thrid # we rely on Gmail's threading instead of our threading algorithm. new_uid.update_flags_and_labels(msg.flags, msg.g_labels) thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels common.add_any_new_thread_labels(thread, new_uid, db_session) return new_uid
def add_message_attrs(self, db_session, new_uid, msg, folder): """ Gmail-specific post-create-message bits. """ # Disable autoflush so we don't try to flush a message with null # thread_id, causing a crash, and so that we don't flush on each # added/removed label. with db_session.no_autoflush: new_uid.message.g_msgid = msg.g_msgid # NOTE: g_thrid == g_msgid on the first message in the thread :) new_uid.message.g_thrid = msg.g_thrid # we rely on Gmail's threading instead of our threading algorithm. new_uid.message.thread_order = 0 new_uid.update_imap_flags(msg.flags, msg.g_labels) # FIXME: @karim not sure if it's necessary to clean up strings like # \\Inbox, \\Trash, etc. new_uid.g_labels = [label for label in msg.g_labels] thread = new_uid.message.thread = ImapThread.from_gmail_message( db_session, new_uid.account.namespace, new_uid.message) # make sure this thread has all the correct labels common.add_any_new_thread_labels(thread, new_uid, db_session) return new_uid