]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/daemons/twitterstatusfetcher.php
truncate retweeted stuff if it's too long
[quix0rs-gnu-social.git] / plugins / TwitterBridge / daemons / twitterstatusfetcher.php
index 027e572b029d6a3ad25ddf0afc1102e318bc4705..e897cc6ea0e7f215a1edc89cadb2a233c2b5cb6c 100755 (executable)
@@ -274,11 +274,18 @@ class TwitterStatusFetcher extends ParallelizingDaemon
                 $content = sprintf(_('RT @%1$s %2$s'),
                                    $author->nickname,
                                    $original->content);
+
+                if (Notice::contentTooLong($content)) {
+                    $contentlimit = Notice::maxContent();
+                    $content = mb_substr($content, 0, $contentlimit - 4) . ' ...';
+                }
+
                 $repeat = Notice::saveNew($profile->id,
                                           $content,
                                           'twitter',
                                           array('repeat_of' => $original->id,
-                                                'uri' => $statusUri));
+                                                'uri' => $statusUri,
+                                                'is_local' => Notice::GATEWAY));
                 common_log(LOG_INFO, "Saved {$repeat->id} as a repeat of {$original->id}");
                 Notice_to_status::saveNew($repeat->id, $status->id);
                 return $repeat;
@@ -301,14 +308,18 @@ class TwitterStatusFetcher extends ParallelizingDaemon
 
         if (!empty($status->in_reply_to_status_id)) {
             common_log(LOG_INFO, "Status {$status->id} is a reply to status {$status->in_reply_to_status_id}");
-            $replyUri = $this->makeStatusURI($status->in_reply_to_screen_name, $status->in_reply_to_status_id);
-            $reply = Notice::staticGet('uri', $replyUri);
-            if (empty($reply)) {
+            $n2s = Notice_to_status::staticGet('status_id', $status->in_reply_to_status_id);
+            if (empty($n2s)) {
                 common_log(LOG_INFO, "Couldn't find local notice for status {$status->in_reply_to_status_id}");
             } else {
-                common_log(LOG_INFO, "Found local notice {$reply->id} for status {$status->in_reply_to_status_id}");
-                $notice->reply_to     = $reply->id;
-                $notice->conversation = $reply->conversation;
+                $reply = Notice::staticGet('id', $n2s->notice_id);
+                if (empty($reply)) {
+                    common_log(LOG_INFO, "Couldn't find local notice for status {$status->in_reply_to_status_id}");
+                } else {
+                    common_log(LOG_INFO, "Found local notice {$reply->id} for status {$status->in_reply_to_status_id}");
+                    $notice->reply_to     = $reply->id;
+                    $notice->conversation = $reply->conversation;
+                }
             }
         }