]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Requeue waiting messages on start/connection loss
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Mon, 9 Aug 2010 14:03:54 +0000 (07:03 -0700)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Mon, 9 Aug 2010 14:03:54 +0000 (07:03 -0700)
plugins/Msn/msnmanager.php

index 42eb18b9c464a7bb1c9aa6bdd2d1019e41d7badb..235c8a9430d1a9c90c8142c38bc380d25115406f 100644 (file)
@@ -42,6 +42,7 @@ class MsnManager extends ImManager {
      */\r
     public function start($master) {\r
         if (parent::start($master)) {\r
+            $this->requeue_waiting_messages();\r
             $this->connect();\r
             return true;\r
         } else {\r
@@ -185,6 +186,21 @@ class MsnManager extends ImManager {
         }\r
     }\r
 \r
+    /**\r
+    * Requeue messages from the waiting table so we try\r
+    * to send them again\r
+    *\r
+    * @return void\r
+    */\r
+    protected function requeue_waiting_messages() {\r
+        $wm = Msn_waiting_message::top($data['to']);\r
+        while ($wm != NULL) {\r
+            $this->plugin->send_message($wm->screenname, $wm->message);\r
+            $wm->delete();\r
+            $wm = Msn_waiting_message::top($data['to']);\r
+        }\r
+    }\r
+\r
     /**\r
     * Called by callback to log failure during connect\r
     *\r
@@ -203,6 +219,8 @@ class MsnManager extends ImManager {
     */\r
     public function handle_reconnect($data) {\r
         common_log(LOG_NOTICE, 'MSN reconnecting');\r
+        // Requeue messages waiting in the DB\r
+        $this->requeue_waiting_messages();\r
     }\r
 \r
     /**\r