]> git.mxchange.org Git - friendica.git/commitdiff
structures for batch mode (Diaspora/zot)
authorFriendika <info@friendika.com>
Tue, 20 Sep 2011 08:49:08 +0000 (01:49 -0700)
committerFriendika <info@friendika.com>
Tue, 20 Sep 2011 08:49:08 +0000 (01:49 -0700)
boot.php
database.sql
include/Scrape.php
include/diaspora.php
include/network.php
mod/follow.php
update.php

index ea2d9df9d945195298f2bbf3b8f13f0bdf728a1f..b38855f358b7459267c6e5c7a27c818567958d5b 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -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' );
index b1580ec2cccef6d39bcda429f1e81ffba714c51a..cb73f732b8de756eaf0016e1208310e9a769780b 100644 (file)
@@ -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,
index 58468a40d021ab6de2f008bd704cffbbe1233cfa..0115bf2e71c9e1136d8bae666a48eb6dc212637e 100644 (file)
@@ -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;
index 425bc722fc528858836eb4713a3f3be698a8d8c5..94c4e3098816b6ace99088c4f8dcff566643b4a0 100644 (file)
@@ -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;
index deb257ff3d877720f1a866c1614b0d6bedf0f99b..ec99d1e0dc12a0c0ec1f206187ae958782d60f91 100644 (file)
@@ -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;
 }
index df4d2e630a9fb57d22e522a80cea8675c709267d..77c8ae18f3e796cf1c30dcd0c227e1990c789c40 100644 (file)
@@ -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']),
index 94d0b6274a31d5824f2143693e45935db1a10fe3..c5752e4e7253fe96431f66d40dff362dada5ec9c 100644 (file)
@@ -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' ");
+
+}
+