本文整理汇总了Python中dbclient.DbClient.deleteMessageFromOutbox方法的典型用法代码示例。如果您正苦于以下问题:Python DbClient.deleteMessageFromOutbox方法的具体用法?Python DbClient.deleteMessageFromOutbox怎么用?Python DbClient.deleteMessageFromOutbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbclient.DbClient
的用法示例。
在下文中一共展示了DbClient.deleteMessageFromOutbox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flushOutboxInSeparateThread
# 需要导入模块: from dbclient import DbClient [as 别名]
# 或者: from dbclient.DbClient import deleteMessageFromOutbox [as 别名]
def flushOutboxInSeparateThread(self):
'''This can take quite a while to do the flush'''
if self._flushing:
return
print("Outgoing postman is flushing the outbox...")
self._flushing = True
# Look in the outbox for messages
messagesFound = 0
messagesSent = 0
failedRecpts = set()
for m in DbClient.getOutboxMessages():
messagesFound += 1
# Get recipient, timestamp, relays, message
message = m['message']
sendTimestamp = m.get('timestamp', None) # not used yet
# TODO: if the timestamp is too old, then either just delete the message (if it's not to be queued) or move to inbox
# Some messages have a single recipient (and maybe relays), others only have a recipientList
recipient = m.get('recipient', None)
if recipient:
sendSuccess = self.RC_MESSAGE_FAILED if recipient in failedRecpts else self.sendMessage(message, recipient)
if sendSuccess == self.RC_MESSAGE_IGNORED:
print("Dealt with message so I should delete it from the db:", m["_id"])
DbClient.deleteMessageFromOutbox(m["_id"])
elif sendSuccess == self.RC_MESSAGE_SENT:
print("Sent message so I should delete it from the db:", m["_id"])
DbClient.deleteMessageFromOutbox(m["_id"])
messagesSent += 1
testMsg = "Message sent, type was %s and recipient was %s" % (m.get("msgType", "unknown"), recipient)
# TODO: Pass these values with the signal as an object, not a string
self.emit(QtCore.SIGNAL("messageSent"), testMsg)
elif not m.get('queue', False):
print("I failed to send a message but it shouldn't be queued, deleting it")
DbClient.deleteMessageFromOutbox(m["_id"])
failedRecpts.add(recipient)
else:
print("I failed to send but I'll keep the message and try again later")
failedRecpts.add(recipient)
else:
# There isn't a direct recipient, so let's hope there's a recipient list
recipientList = m.get('recipientList', None)
if recipientList:
print("I've got a message to relay to: ", recipientList)
failedRecipientsForThisMessage = set()
# TODO: Try to send to each in the list
# TODO: Does the parent even need to know when a send has worked?
if messagesSent > 0:
self.parent.postmanKnock() # only once
if messagesFound > 0:
print("For %d found messages, I managed to send %d copies" % (messagesFound, messagesSent))
# We tried to send a message to these recipients but failed - set them to be offline
for r in failedRecpts:
Contacts.goneOffline(r)
self._flushing = False