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' );
"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"),
$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']);
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);
$profile_photo = '';
$connect_url = '';
$name = '';
+ $updated = '0000-00-00 00:00:00';
$name = $entry->displayName;
}
}
}
- if(isset($entry->photos)) {
+ if(isset($entry->photos)) {
foreach($entry->photos as $photo) {
if($photo->type == 'profile') {
$profile_photo = $photo->value;
}
}
+ if(isset($entry->updated))
+ $updated = date("Y-m-d H:i:s", strtotime($entry->updated));
+
if((! $name) || (! $profile_url) || (! $profile_photo))
continue;
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))
$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`
'id' => false,
'displayName' => false,
'urls' => false,
+ 'updated' => false,
'preferredUsername' => false,
'photos' => false
);
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;
if($format === 'json') {
header('Content-type: application/json');
echo json_encode($ret);
- killme();
+ killme();
}
else
http_status_exit(500);
<?php
-define( 'UPDATE_VERSION' , 1175 );
+define( 'UPDATE_VERSION' , 1177 );
/**
*