From d321b6e76f3d683b080db19cc63500d159fc0053 Mon Sep 17 00:00:00 2001 From: Luke Fitzgerald Date: Mon, 9 Aug 2010 07:03:54 -0700 Subject: [PATCH] Requeue waiting messages on start/connection loss --- plugins/Msn/msnmanager.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/Msn/msnmanager.php b/plugins/Msn/msnmanager.php index 42eb18b9c4..235c8a9430 100644 --- a/plugins/Msn/msnmanager.php +++ b/plugins/Msn/msnmanager.php @@ -42,6 +42,7 @@ class MsnManager extends ImManager { */ public function start($master) { if (parent::start($master)) { + $this->requeue_waiting_messages(); $this->connect(); return true; } else { @@ -185,6 +186,21 @@ class MsnManager extends ImManager { } } + /** + * Requeue messages from the waiting table so we try + * to send them again + * + * @return void + */ + protected function requeue_waiting_messages() { + $wm = Msn_waiting_message::top($data['to']); + while ($wm != NULL) { + $this->plugin->send_message($wm->screenname, $wm->message); + $wm->delete(); + $wm = Msn_waiting_message::top($data['to']); + } + } + /** * Called by callback to log failure during connect * @@ -203,6 +219,8 @@ class MsnManager extends ImManager { */ public function handle_reconnect($data) { common_log(LOG_NOTICE, 'MSN reconnecting'); + // Requeue messages waiting in the DB + $this->requeue_waiting_messages(); } /** -- 2.39.5