Merge develop into 3011_hcard_vcard

This commit is contained in:
rabuzarus 2015-12-01 18:34:13 +01:00
commit 39b37281a7
14 changed files with 1081 additions and 804 deletions

View file

@ -1386,11 +1386,6 @@ function diaspora_asphoto($importer,$xml,$msg) {
}
function diaspora_comment($importer,$xml,$msg) {
$a = get_app();
@ -1510,16 +1505,27 @@ function diaspora_comment($importer,$xml,$msg) {
}
}
// Fetch the contact id - if we know this contact
$r = q("SELECT `id`, `network` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
dbesc(normalise_link($person['url'])), intval($importer['uid']));
if ($r) {
$cid = $r[0]['id'];
$network = $r[0]['network'];
} else {
$cid = $contact['id'];
$network = NETWORK_DIASPORA;
}
$body = diaspora2bb($text);
$message_id = $diaspora_handle . ':' . $guid;
$datarray = array();
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
$datarray['contact-id'] = $cid;
$datarray['type'] = 'remote-comment';
$datarray['wall'] = $parent_item['wall'];
$datarray['network'] = NETWORK_DIASPORA;
$datarray['network'] = $network;
$datarray['verb'] = ACTIVITY_POST;
$datarray['gravity'] = GRAVITY_COMMENT;
$datarray['guid'] = $guid;
@ -2155,13 +2161,24 @@ function diaspora_like($importer,$xml,$msg) {
EOT;
$bodyverb = t('%1$s likes %2$s\'s %3$s');
// Fetch the contact id - if we know this contact
$r = q("SELECT `id`, `network` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
dbesc(normalise_link($person['url'])), intval($importer['uid']));
if ($r) {
$cid = $r[0]['id'];
$network = $r[0]['network'];
} else {
$cid = $contact['id'];
$network = NETWORK_DIASPORA;
}
$arr = array();
$arr['uri'] = $uri;
$arr['uid'] = $importer['uid'];
$arr['guid'] = $guid;
$arr['network'] = NETWORK_DIASPORA;
$arr['contact-id'] = $contact['id'];
$arr['network'] = $network;
$arr['contact-id'] = $cid;
$arr['type'] = 'activity';
$arr['wall'] = $parent_item['wall'];
$arr['gravity'] = GRAVITY_LIKE;

View file

@ -203,8 +203,8 @@ function feed_import($xml,$importer,&$contact, &$hub) {
//$item["object"] = $xml;
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` = '%s'",
intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED));
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s', '%s')",
intval($importer["uid"]), dbesc($item["uri"]), dbesc(NETWORK_FEED), dbesc(NETWORK_DFRN));
if ($r) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
continue;

View file

@ -725,6 +725,16 @@ if(! function_exists('profile_tabs')){
);
}
if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
$tabs[] = array(
'label' => t('Contacts'),
'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname,
'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
'title' => t('Contacts'),
'id' => 'viewcontacts-tab',
'accesskey' => 'k',
);
}
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
call_hooks('profile_tabs', $arr);

View file

@ -1196,6 +1196,24 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
}
}
// Do we already have this item?
// We have to check several networks since Friendica posts could be repeated via OStatus (maybe Diasporsa as well)
if (in_array(trim($arr['network']), array(NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""))) {
$r = q("SELECT `id`, `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` IN ('%s', '%s', '%s') LIMIT 1",
dbesc(trim($arr['uri'])),
intval($uid),
dbesc(NETWORK_DIASPORA),
dbesc(NETWORK_DFRN),
dbesc(NETWORK_OSTATUS)
);
if ($r) {
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives
if ($uid != 0)
logger("Item with uri ".$arr['uri']." already existed for user ".$uid." with id ".$r[0]["id"]." target network ".$r[0]["network"]." - new network: ".$arr['network']);
return($r[0]["id"]);
}
}
// If there is no guid then take the same guid that was taken before for the same uri
if ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "") AND (trim($arr['network']) != "")) {
logger('item_store: checking for an existing guid for uri '.$arr['uri'], LOGGER_DEBUG);
@ -1425,9 +1443,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
}
}
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1",
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `network` IN ('%s', '%s') AND `uid` = %d LIMIT 1",
dbesc($arr['uri']),
dbesc($arr['network']),
dbesc(NETWORK_DFRN),
intval($arr['uid'])
);
if($r && count($r)) {
@ -1488,14 +1507,24 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
// And restore it
$arr = $unescaped;
// find the item we just created
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` = '%s' ORDER BY `id` ASC ",
// find the item that we just created
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` = '%s' ORDER BY `id` ASC",
dbesc($arr['uri']),
intval($arr['uid']),
dbesc($arr['network'])
);
if(count($r)) {
if(count($r) > 1) {
// There are duplicates. Keep the oldest one, delete the others
logger('item_store: duplicated post occurred. Removing newer duplicates. uri = '.$arr['uri'].' uid = '.$arr['uid']);
q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` = '%s' AND `id` > %d",
dbesc($arr['uri']),
intval($arr['uid']),
dbesc($arr['network']),
intval($r[0]["id"])
);
return 0;
} elseif(count($r)) {
// Store the guid and other relevant data
add_guid($arr);
@ -1528,14 +1557,6 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
logger('item_store: could not locate created item');
return 0;
}
if(count($r) > 1) {
logger('item_store: duplicated post occurred. Removing duplicates. uri = '.$arr['uri'].' uid = '.$arr['uid']);
q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `id` != %d ",
dbesc($arr['uri']),
intval($arr['uid']),
intval($current_post)
);
}
if((! $parent_id) || ($arr['parent-uri'] === $arr['uri']))
$parent_id = $current_post;

View file

@ -87,7 +87,6 @@ function add_shadow_entry($item) {
// Is there already a shadow entry?
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
if (count($r))
return;