From 632c5570086bdfd8c8a311ccec44648697a8ef8b Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Thu, 30 Sep 2010 21:00:06 -0700 Subject: [PATCH] pubsubhubbub db refinements --- boot.php | 2 +- database.sql | 11 ++++++++++- include/poller.php | 2 +- mod/pubsub.php | 4 ++-- update.php | 4 ++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/boot.php b/boot.php index 9ebdef1bff..5baaa218fa 100644 --- a/boot.php +++ b/boot.php @@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'BUILD_ID' , 1004 ); +define ( 'BUILD_ID' , 1005 ); define ( 'EOL', "
\r\n"); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index fd709878d6..78c7d27c22 100644 --- a/database.sql +++ b/database.sql @@ -69,6 +69,9 @@ CREATE TABLE IF NOT EXISTS `contact` ( `confirm` text NOT NULL, `aes_allow` tinyint(1) NOT NULL DEFAULT '0', `ret-aes` tinyint(1) NOT NULL DEFAULT '0', + `usehub` tinyint(1) NOT NULL DEFAULT '0', + `subhub` tinyint(1) NOT NULL DEFAULT '0', + `hub-verify` char(255) NOT NULL, `last-update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `name-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `uri-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -80,7 +83,13 @@ CREATE TABLE IF NOT EXISTS `contact` ( `rating` tinyint(1) NOT NULL DEFAULT '0', `reason` text NOT NULL, `profile-id` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `uid` (`uid`), + KEY `self` (`self`), + KEY `issued-id` (`issued-id`), + KEY `dfrn-id` (`dfrn-id`), + KEY `blocked` (`blocked`), + KEY `readonly` (`readonly`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- diff --git a/include/poller.php b/include/poller.php index 986c00913e..b9ef0d93a9 100644 --- a/include/poller.php +++ b/include/poller.php @@ -23,7 +23,7 @@ $contacts = q("SELECT * FROM `contact` WHERE ( `dfrn-id` != '' OR (`issued-id` != '' AND `duplex` = 1)) - AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 AND `usehub` = 0 ORDER BY RAND()"); + AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 AND `subhub` = 0 ORDER BY RAND()"); if(! count($contacts)) killme(); diff --git a/mod/pubsub.php b/mod/pubsub.php index 65705069af..1e6add9355 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -67,7 +67,7 @@ function pubsub_init(&$a) { if(($hub_mode === 'unsubscribe') && (! strlen($hub_verify))) hub_return(false, ''); - $r = q("UPDATE `contact` SET `usehub` = %d WHERE `id` = %d LIMIT 1", + $r = q("UPDATE `contact` SET `subhub` = %d WHERE `id` = %d LIMIT 1", intval($subscribe), intval($contact['id']) ); @@ -93,7 +93,7 @@ function pubsub_post(&$a) { $importer = $r[0]; - $r = q("SELECT * FROM `contact` WHERE `usehub` = 1 AND `id` = %d AND `uid` = %d AND `blocked` = 0 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `subhub` = 1 AND `id` = %d AND `uid` = %d AND `blocked` = 0 LIMIT 1", intval($contact_id), intval($importer['uid']) ); diff --git a/update.php b/update.php index 6b0bc770e9..5d2210107c 100644 --- a/update.php +++ b/update.php @@ -29,4 +29,8 @@ function update_1003() { q("ALTER TABLE `contact` ADD `hub-verify` CHAR( 255 ) NOT NULL AFTER `usehub`"); q("ALTER TABLE `contact` ADD INDEX ( `uid` ) , ADD INDEX ( `self` ), ADD INDEX ( `issued-id` ), ADD INDEX ( `dfrn-id` )"); q("ALTER TABLE `contact` ADD INDEX ( `blocked` ), ADD INDEX ( `readonly` )"); +} + +function update_1004() { + q("ALTER TABLE `contact` ADD `subhub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `usehub`"); } \ No newline at end of file