summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-06 08:54:04 -0400
committerEvan Prodromou <evan@status.net>2010-09-06 08:54:04 -0400
commit8e131652d675e9855bc26484f4d996944fc62337 (patch)
tree49b7c5ae50131af83b932c2df4dab66a2d915358
parent033712b1f2afcb6f29b3a1bd10544cc323af9da3 (diff)
save Twitter mentions as StatusNet replies
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterstatusfetcher.php26
1 files changed, 26 insertions, 0 deletions
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 "@<a href='http://twitter.com/{$object->screen_name}' title='{$object->name}'>{$object->screen_name}</a>";
}
+
+ 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;