diff options
author | Evan Prodromou <evan@status.net> | 2010-09-04 23:45:55 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-09-07 04:00:58 -0400 |
commit | a1981770ce113d0fa20e5f1b57ddcf3d88177102 (patch) | |
tree | a58c2bb272a061f2954e84eb190b02c16e3d1e80 /plugins/TwitterBridge/twitter.php | |
parent | 17a16026ff9e0bce287b607e587a9ac7a9c3b74c (diff) |
Save notice-to-status mapping in its own table
Introduce a table mapping notices to Twitter statuses. Initialize
this table at checkSchema() time. Save the mapping when we push
or pull statuses. Use the table to determine if a notice has a
Twitter equivalent.
Diffstat (limited to 'plugins/TwitterBridge/twitter.php')
-rw-r--r-- | plugins/TwitterBridge/twitter.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index 33d5443c2..94eaedee5 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -129,14 +129,9 @@ function is_twitter_bound($notice, $flink) { function is_twitter_notice($id) { - $notice = Notice::staticGet('id', $id); + $n2s = Notice_to_status::staticGet('notice_id', $id); - if (empty($notice)) { - // it's not any kind of notice, so it's definitely not a Twitter notice. - return false; - } - - return ($notice->source == 'twitter'); + return (!empty($n2s)); } function broadcast_twitter($notice) @@ -166,6 +161,9 @@ function retweet_notice($flink, $notice) try { $status = $client->statusesRetweet($id); + if (!empty($status)) { + Notice_to_status::saveNew($notice->id, $status->id); + } } catch (OAuthClientException $e) { return process_error($e, $flink, $notice); } @@ -173,12 +171,12 @@ function retweet_notice($flink, $notice) function twitter_status_id($notice) { - if ($notice->source == 'twitter' && - preg_match('#^http://twitter.com/[\w_.]+/status/(\d+)$#', $notice->uri, $match)) { - return $match[1]; + $n2s = Notice_to_status::staticGet('notice_id', $id); + if (empty($n2s)) { + return null; + } else { + return $n2s->status_id; } - - return null; } /** @@ -214,6 +212,9 @@ function broadcast_oauth($notice, $flink) { try { $status = $client->statusesUpdate($statustxt, $params); + if (!empty($status)) { + Notice_to_status::saveNew($notice->id, $status->id); + } } catch (OAuthClientException $e) { return process_error($e, $flink, $notice); } |