diff options
author | Friendika <info@friendika.com> | 2011-09-20 01:49:08 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-09-20 01:49:08 -0700 |
commit | 9edf15d3ef0548a35862fab37eee1fd310705285 (patch) | |
tree | d8c6e34b8e83116d1c9151b58ca63d24845923cb | |
parent | 8a11cec61a87600273f1349e3d112e7fc1e65486 (diff) | |
download | volse-hubzilla-9edf15d3ef0548a35862fab37eee1fd310705285.tar.gz volse-hubzilla-9edf15d3ef0548a35862fab37eee1fd310705285.tar.bz2 volse-hubzilla-9edf15d3ef0548a35862fab37eee1fd310705285.zip |
structures for batch mode (Diaspora/zot)
-rw-r--r-- | boot.php | 2 | ||||
-rw-r--r-- | database.sql | 1 | ||||
-rw-r--r-- | include/Scrape.php | 5 | ||||
-rw-r--r-- | include/diaspora.php | 11 | ||||
-rw-r--r-- | include/network.php | 73 | ||||
-rw-r--r-- | mod/follow.php | 5 | ||||
-rw-r--r-- | update.php | 10 |
7 files changed, 76 insertions, 31 deletions
@@ -9,7 +9,7 @@ require_once("include/pgettext.php"); define ( 'FRIENDIKA_VERSION', '2.3.1109' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); -define ( 'DB_UPDATE_VERSION', 1090 ); +define ( 'DB_UPDATE_VERSION', 1091 ); define ( 'EOL', "<br />\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index b1580ec2c..cb73f732b 100644 --- a/database.sql +++ b/database.sql @@ -70,6 +70,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( `alias` char(255) NOT NULL, `pubkey` text NOT NULL, `prvkey` text NOT NULL, + `batch` char(255) NOT NULL, `request` text NOT NULL, `notify` text NOT NULL, `poll` text NOT NULL, diff --git a/include/Scrape.php b/include/Scrape.php index 58468a40d..0115bf2e7 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -496,8 +496,10 @@ function probe_url($url, $mode = PROBE_NORMAL) { } if($diaspora && $diaspora_base && $diaspora_guid) { - if($mode == PROBE_DIASPORA || ! $notify) + if($mode == PROBE_DIASPORA || ! $notify) { $notify = $diaspora_base . 'receive/users/' . $diaspora_guid; + $batch = $diaspora_base . 'receive/public' ; + } if(strpos($url,'@')) $addr = str_replace('acct:', '', $url); } @@ -675,6 +677,7 @@ function probe_url($url, $mode = PROBE_NORMAL) { $result['nick'] = $vcard['nick']; $result['url'] = $profile; $result['addr'] = $addr; + $result['batch'] = $batch; $result['notify'] = $notify; $result['poll'] = $poll; $result['request'] = $request; diff --git a/include/diaspora.php b/include/diaspora.php index 425bc722f..94c4e3098 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -68,6 +68,7 @@ function diaspora_get_contact_by_handle($uid,$handle) { } function find_diaspora_person_by_handle($handle) { + $update = false; $r = q("select * from fcontact where network = '%s' and addr = '%s' limit 1", dbesc(NETWORK_DIASPORA), dbesc($handle) @@ -75,18 +76,14 @@ function find_diaspora_person_by_handle($handle) { if(count($r)) { // update record occasionally so it doesn't get stale $d = strtotime($r[0]['updated'] . ' +00:00'); - if($d < strtotime('now - 14 days')) { - q("delete from fcontact where id = %d limit 1", - intval($r[0]['id']) - ); - } - else + if($d > strtotime('now - 14 days')) return $r[0]; + $update = true; } require_once('include/Scrape.php'); $r = probe_url($handle, PROBE_DIASPORA); if((count($r)) && ($r['network'] === NETWORK_DIASPORA)) { - add_fcontact($r); + add_fcontact($r,$update); return ($r); } return false; diff --git a/include/network.php b/include/network.php index deb257ff3..ec99d1e0d 100644 --- a/include/network.php +++ b/include/network.php @@ -701,24 +701,59 @@ function parse_xml_string($s,$strict = true) { return $x; }} -function add_fcontact($arr) { - - $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`, - `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` ) - values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", - dbesc($arr['url']), - dbesc($arr['name']), - dbesc($arr['photo']), - dbesc($arr['request']), - dbesc($arr['nick']), - dbesc($arr['addr']), - dbesc($arr['notify']), - dbesc($arr['poll']), - dbesc($arr['confirm']), - dbesc($arr['network']), - dbesc($arr['alias']), - dbesc($arr['pubkey']), - dbesc(datetime_convert()) - ); +function add_fcontact($arr,$update = false) { + + if($update) { + $r = q("UPDATE `fcontact` SET + `name` = '%s', + `photo` = '%s', + `request` = '%s', + `nick` = '%s', + `addr` = '%s', + `batch` = '%s', + `notify` = '%s', + `poll` = '%s', + `confirm` = '%s', + `alias` = '%s', + `pubkey` = '%s', + `updated` = '%s' + WHERE `url` = '%s' AND `network` = '%s' LIMIT 1", + dbesc($arr['name']), + dbesc($arr['photo']), + dbesc($arr['request']), + dbesc($arr['nick']), + dbesc($arr['addr']), + dbesc($arr['batch']), + dbesc($arr['notify']), + dbesc($arr['poll']), + dbesc($arr['confirm']), + dbesc($arr['network']), + dbesc($arr['alias']), + dbesc($arr['pubkey']), + dbesc(datetime_convert()), + dbesc($arr['url']), + dbesc($arr['network']) + ); + } + else { + $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`, + `batch`, `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` ) + values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", + dbesc($arr['url']), + dbesc($arr['name']), + dbesc($arr['photo']), + dbesc($arr['request']), + dbesc($arr['nick']), + dbesc($arr['addr']), + dbesc($arr['batch']), + dbesc($arr['notify']), + dbesc($arr['poll']), + dbesc($arr['confirm']), + dbesc($arr['network']), + dbesc($arr['alias']), + dbesc($arr['pubkey']), + dbesc(datetime_convert()) + ); + } return $r; } diff --git a/mod/follow.php b/mod/follow.php index df4d2e630..77c8ae18f 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -100,14 +100,15 @@ function follow_post(&$a) { $new_relation = CONTACT_IS_FOLLOWER; // create contact record - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, + $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `batch`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, `writable`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", intval(local_user()), dbesc(datetime_convert()), dbesc($ret['url']), dbesc($ret['addr']), dbesc($ret['alias']), + dbesc($ret['batch']), dbesc($ret['notify']), dbesc($ret['poll']), dbesc($ret['name']), diff --git a/update.php b/update.php index 94d0b6274..c5752e4e7 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1090 ); +define( 'UPDATE_VERSION' , 1091 ); /** * @@ -753,3 +753,11 @@ function update_1088() { function update_1089() { q("ALTER TABLE `user` ADD `blocktags` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `hidewall` "); } + +function update_1090() { + q("ALTER TABLE `contact` ADD `batch` char(255) NOT NULL AFTER `prvkey` "); + + q("UPDATE `contact` SET `batch` = concat(substring_index(`url`,'/',3),'/receive/public') WHERE `network` = 'dspr' "); + +} + |