]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/lib/tweetinqueuehandler.php
Merge branch 'master' into nightly
[quix0rs-gnu-social.git] / plugins / TwitterBridge / lib / tweetinqueuehandler.php
index 7f34ade23b8c5f1d58ecf7a10e5ea327efa9ce27..69ce5a61e97302518ee4011b8b15749adb34c414 100644 (file)
@@ -19,7 +19,7 @@
 
 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
-require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
+require_once dirname(__DIR__) . '/twitter.php';
 
 /**
  * Queue handler to deal with incoming Twitter status updates, as retrieved by
@@ -50,14 +50,20 @@ class TweetInQueueHandler extends QueueHandler
 
         $importer = new TwitterImport();
         $notice = $importer->importStatus($status);
-        if ($notice) {
-            $flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
-            if ($flink) {
+        if ($notice instanceof Notice) {
+            try {
+                $flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
                 common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice ".
-                           $notice->id." to inbox ".$flink->user_id);
-                // @fixme this should go through more regular channels?
-                Inbox::insertNotice($flink->user_id, $notice->id);
-            }else {
+                           $notice->id." to attentions for user ".$flink->user_id);
+                try {
+                    Attention::saveNew($notice, $flink->getProfile());
+                } catch (Exception $e) {
+                    // Log the exception, but make sure we don't bail out, we
+                    // still have a queue item to remove here-after.
+                    common_log(LOG_ERR, "Failed adding notice {$notice->id} to attentions for user {$flink->user_id}: " .
+                                        $e->getMessage());
+                }
+            } catch (NoResultException $e) {
                common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver);
             }
         }