]> git.mxchange.org Git - friendica.git/commitdiff
Poco now returns the last update date as well. This date will be stored in the gconta...
authorMichael Vogel <icarus@dabo.de>
Sun, 4 Jan 2015 18:19:47 +0000 (19:19 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 4 Jan 2015 18:19:47 +0000 (19:19 +0100)
boot.php
include/dbstructure.php
include/items.php
include/socgraph.php
mod/poco.php
update.php

index 34836a97aa6c570839577375abab5e455bea2d42..ec2a4a1acf0f5e12331efafb38d6ff04587581da 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -18,7 +18,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Ginger');
 define ( 'FRIENDICA_VERSION',      '3.3.2' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1175      );
+define ( 'DB_UPDATE_VERSION',      1177      );
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
 
index 66e67c0a9aaf977ca68f0086360fa955d26ca60e..08d772ef7c867148b3324c9903bcbf6ba915d4c1 100644 (file)
@@ -616,6 +616,7 @@ function db_definition() {
                                        "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
                                        "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
                                        "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
+                                       "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
                                        ),
                        "indexes" => array(
                                        "PRIMARY" => array("id"),
index d6da0ed5a5c0f5b02d4c5964730cdab6d089588c..b82b5dc9717773d77c7a043ff2a1ae7c6dce40f7 100644 (file)
@@ -1343,6 +1343,16 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                $current_post = $r[0]['id'];
                logger('item_store: created item ' . $current_post);
 
+               // Set "success_update" to the date of the last time we heard from this contact
+               // This can be used to filter for inactive contacts and poco.
+               // Only do this for public postings to avoid privacy problems, since poco data is public.
+               // Don't set this value if it isn't from the owner (could be an author that we don't know)
+               if (!$arr['private'] AND (($arr["author-link"] === $arr["owner-link"]) OR ($arr["parent-uri"] === $arr["uri"])))
+                       $r = q("UPDATE `contact` SET `success_update` = '%s' WHERE `id` = %d",
+                               dbesc($arr['received']),
+                               intval($arr['contact-id'])
+                       );
+
                // Only check for notifications on start posts
                if ($arr['parent-uri'] === $arr['uri']) {
                        add_thread($r[0]['id']);
index daec03726eb939085b5ea2a1f651d4e095d5b8a4..333d2f04b11b0fd413e107243923987c0e3b8eb0 100644 (file)
@@ -39,7 +39,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
        if(! $url)
                return;
 
-       $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos') ;
+       $url = $url . (($uid) ? '/@me/@all?fields=displayName,urls,photos' : '?fields=displayName,urls,photos,updated') ;
 
        logger('poco_load: ' . $url, LOGGER_DEBUG);
 
@@ -67,6 +67,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                $profile_photo = '';
                $connect_url = '';
                $name = '';
+               $updated = '0000-00-00 00:00:00';
 
                $name = $entry->displayName;
 
@@ -82,7 +83,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                                }
                        }
                }
-               if(isset($entry->photos)) { 
+               if(isset($entry->photos)) {
                        foreach($entry->photos as $photo) {
                                if($photo->type == 'profile') {
                                        $profile_photo = $photo->value;
@@ -91,6 +92,9 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                        }
                }
 
+               if(isset($entry->updated))
+                       $updated = date("Y-m-d H:i:s", strtotime($entry->updated));
+
                if((! $name) || (! $profile_url) || (! $profile_photo))
                        continue;
 
@@ -101,25 +105,27 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
                if(count($x)) {
                        $gcid = $x[0]['id'];
 
-                       if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
-                               q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
+                       if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo || $x[0]['updated'] < $updated) {
+                               q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s', `updated` = '%s'
                                        where `nurl` = '%s'",
                                        dbesc($name),
                                        dbesc($profile_photo),
                                        dbesc($connect_url),
                                        dbesc($profile_url),
+                                       dbesc($updated),
                                        dbesc(normalise_link($profile_url))
                                );
                        }
                }
                else {
-                       q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`)
+                       q("insert into `gcontact` (`name`,`url`,`nurl`,`photo`,`connect`, `updated`)
                                values ( '%s', '%s', '%s', '%s','%s') ",
                                dbesc($name),
                                dbesc($profile_url),
                                dbesc(normalise_link($profile_url)),
                                dbesc($profile_photo),
-                               dbesc($connect_url)
+                               dbesc($connect_url),
+                               dbesc($updated)
                        );
                        $x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
                                dbesc(normalise_link($profile_url))
index 624a48d9ff1768b4654e59a63d44b20076f8a7b3..9c08749f205656c6386c3c53cfa2b7a4ffce6bf5 100644 (file)
@@ -30,7 +30,7 @@ function poco_init(&$a) {
                $justme = true;
        if($a->argc > 4 && intval($a->argv[4]) && $justme == false)
                $cid = intval($a->argv[4]);
-               
 
        if(! $system_mode) {
                $r = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid`
@@ -106,6 +106,7 @@ function poco_init(&$a) {
                'id' => false,
                'displayName' => false,
                'urls' => false,
+               'updated' => false,
                'preferredUsername' => false,
                'photos' => false
        );
@@ -130,10 +131,24 @@ function poco_init(&$a) {
                                if($fields_ret['urls']) {
                                        $entry['urls'] = array(array('value' => $rr['url'], 'type' => 'profile'));
                                        if($rr['addr'] && ($rr['network'] !== NETWORK_MAIL))
-                                               $entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');  
+                                               $entry['urls'][] = array('value' => 'acct:' . $rr['addr'], 'type' => 'webfinger');
                                }
                                if($fields_ret['preferredUsername'])
                                        $entry['preferredUsername'] = $rr['nick'];
+                               if($fields_ret['updated']) {
+                                       $entry['updated'] = $rr['success_update'];
+
+                                       if ($rr['name-date'] > $entry['updated'])
+                                               $entry['updated'] = $rr['name-date'];
+
+                                       if ($rr['uri-date'] > $entry['updated'])
+                                               $entry['updated'] = $rr['uri-date'];
+
+                                       if ($rr['avatar-date'] > $entry['updated'])
+                                               $entry['updated'] = $rr['avatar-date'];
+
+                                       $entry['updated'] = date("c", strtotime($entry['updated']));
+                               }
                                if($fields_ret['photos'])
                                        $entry['photos'] = array(array('value' => $rr['photo'], 'type' => 'profile'));
                                $ret['entry'][] = $entry;
@@ -153,7 +168,7 @@ function poco_init(&$a) {
        if($format === 'json') {
                header('Content-type: application/json');
                echo json_encode($ret);
-               killme();       
+               killme();
        }
        else
                http_status_exit(500);
index 10195c1baa39414e56eea937f6861fd8a0c7a895..b4fb64048662efd187888c50033a53fe2a2e2622 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1175 );
+define( 'UPDATE_VERSION' , 1177 );
 
 /**
  *