def delete(self, id):
self.db.execute("DELETE FROM user_messages WHERE id = %s", id)
+ def process_queue(self):
+ # Get 10 messages at a time and send them one after the other
+ while True:
+ messages = self.get_all(limit=10)
+
+ for message in messages:
+ self.send_msg(message)
+ else:
+ break
+
def send_to_all(self, recipients, subject, body, format=None):
"""
Sends an email to all recipients and does the translation.
if p.returncode:
raise Exception, "Could not send mail: %s" % stderr
+
+ # If everything was okay, we can delete the message in the database.
+ self.delete(msg.id)
\ No newline at end of file
# Initialise backend
self.backend = pakfire.buildservice.Backend(*args, **kwargs)
- self._commands = {}
+ self._commands = {
+ # Sends all queued messages
+ "process-message-queue" : self.backend.messages.process_queue,
+ }
def __call__(self, *args):
if not len(args) >= 2: