Merge pull request #3756 from annando/ostatus-blocked

Better handling of blocked contacts in OStatus
This commit is contained in:
Tobias Diekershoff 2017-10-04 05:00:49 +00:00 committed by GitHub
commit 098eba9256

View file

@ -78,6 +78,9 @@ class ostatus {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$found = true; $found = true;
if ($r['blocked']) {
$r['id'] = -1;
}
$contact = $r; $contact = $r;
$author["contact-id"] = $r["id"]; $author["contact-id"] = $r["id"];
$author["author-link"] = $r["url"]; $author["author-link"] = $r["url"];
@ -90,6 +93,9 @@ class ostatus {
$r = dba::select('contact', array(), $condition, array('limit' => 1)); $r = dba::select('contact', array(), $condition, array('limit' => 1));
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if ($r['blocked']) {
$r['id'] = -1;
}
$contact = $r; $contact = $r;
$author["contact-id"] = $r["id"]; $author["contact-id"] = $r["id"];
$author["author-link"] = $r["url"]; $author["author-link"] = $r["url"];
@ -128,7 +134,7 @@ class ostatus {
$author["owner-avatar"] = $author["author-avatar"]; $author["owner-avatar"] = $author["author-avatar"];
// Only update the contacts if it is an OStatus contact // Only update the contacts if it is an OStatus contact
if ($r && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) { if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
// Update contact data // Update contact data
@ -483,6 +489,8 @@ class ostatus {
$found = dba::exists('item', array('uid' => $importer["uid"], 'uri' => $item["uri"])); $found = dba::exists('item', array('uid' => $importer["uid"], 'uri' => $item["uri"]));
if ($found) { if ($found) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG); logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
} elseif ($item['contact-id'] < 0) {
logger("Item with uri ".$item["uri"]." is from a blocked contact.", LOGGER_DEBUG);
} else { } else {
// We are having duplicated entries. Hopefully this solves it. // We are having duplicated entries. Hopefully this solves it.
if (Lock::set('ostatus_process_item_store')) { if (Lock::set('ostatus_process_item_store')) {