From a46ba0b54842ae304a642030e006ead5dbe6361f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 6 Sep 2010 08:54:04 -0400 Subject: save Twitter mentions as StatusNet replies --- .../TwitterBridge/daemons/twitterstatusfetcher.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'plugins/TwitterBridge/daemons') diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php index b310b8f36..e092cd1dd 100755 --- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php @@ -348,6 +348,9 @@ class TwitterStatusFetcher extends ParallelizingDaemon } Notice_to_status::saveNew($notice->id, $status->id); + + $this->saveStatusMentions($notice, $status); + $notice->blowOnInsert(); return $notice; @@ -776,6 +779,29 @@ class TwitterStatusFetcher extends ParallelizingDaemon { return "@{$object->screen_name}"; } + + function saveStatusMentions($notice, $status) + { + $mentions = array(); + + if (empty($status->entities) || empty($status->entities->user_mentions)) { + return; + } + + foreach ($status->entities->user_mentions as $mention) { + $flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE); + if (!empty($flink)) { + $user = User::staticGet('id', $flink->user_id); + if (!empty($user)) { + $reply = new Reply(); + $reply->notice_id = $notice->id; + $reply->profile_id = $user->id; + common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}"); + $id = $reply->insert(); + } + } + } + } } $id = null; -- cgit v1.2.3-54-g00ecf