From e40ed1fd56bc02dbae20e0839c507911bc27cf4c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 8 Sep 2010 16:10:07 -0400 Subject: [PATCH] move notice_to_status initialization code to run-once script --- plugins/TwitterBridge/README | 8 +++ plugins/TwitterBridge/TwitterBridgePlugin.php | 21 -------- .../scripts/initialize_notice_to_status.php | 51 +++++++++++++++++++ 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 plugins/TwitterBridge/scripts/initialize_notice_to_status.php diff --git a/plugins/TwitterBridge/README b/plugins/TwitterBridge/README index d7dfe20de5..10ea35b2b6 100644 --- a/plugins/TwitterBridge/README +++ b/plugins/TwitterBridge/README @@ -62,6 +62,14 @@ unless you configure it with a consumer key and secret.) $config['twitter']['global_consumer_key'] = 'YOUR_CONSUMER_KEY'; $config['twitter']['global_consumer_secret'] = 'YOUR_CONSUMER_SECRET'; +Upgrade +------- + +If you've used the Twitter bridge plugin prior to version 0.9.5, +you'll need to run the new scripts/initialize_notice_to_status.php +script to initialize the new notice-to-status mapping file, which +greatly improves the integration between StatusNet and Twitter. + Administration panel -------------------- diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index 21a10775dd..e641c10091 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -404,27 +404,6 @@ class TwitterBridgePlugin extends Plugin new ColumnDef('created', 'datetime', null, false))); - // We update any notices that may have come in from - // Twitter that we don't have a status_id for. Note that - // this won't catch notices that originated at this StatusNet site. - - $n = new Notice(); - - $n->query('SELECT notice.id, notice.uri ' . - 'FROM notice LEFT JOIN notice_to_status ' . - 'ON notice.id = notice_to_status.notice_id ' . - 'WHERE notice.source = "twitter"' . - 'AND notice_to_status.status_id IS NULL'); - - while ($n->fetch()) { - if (preg_match('#^http://twitter.com/[\w_.]+/status/(\d+)$#', $n->uri, $match)) { - - $status_id = $match[1]; - - Notice_to_status::saveNew($n->id, $status_id); - } - } - return true; } diff --git a/plugins/TwitterBridge/scripts/initialize_notice_to_status.php b/plugins/TwitterBridge/scripts/initialize_notice_to_status.php new file mode 100644 index 0000000000..d1acfd53fa --- /dev/null +++ b/plugins/TwitterBridge/scripts/initialize_notice_to_status.php @@ -0,0 +1,51 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$helptext = <<query('SELECT notice.id, notice.uri ' . + 'FROM notice LEFT JOIN notice_to_status ' . + 'ON notice.id = notice_to_status.notice_id ' . + 'WHERE notice.source = "twitter"' . + 'AND notice_to_status.status_id IS NULL'); + +while ($n->fetch()) { + if (preg_match('#^http://twitter.com/[\w_.]+/status/(\d+)$#', $n->uri, $match)) { + $status_id = $match[1]; + Notice_to_status::saveNew($n->id, $status_id); + } +} -- 2.39.5