From: Luke Fitzgerald Date: Mon, 9 Aug 2010 14:03:54 +0000 (-0700) Subject: Requeue waiting messages on start/connection loss X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d321b6e76f3d683b080db19cc63500d159fc0053;p=quix0rs-gnu-social.git Requeue waiting messages on start/connection loss --- 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(); } /**