Browse Source

DFRN: "Hidewall" is now transmitted, "hide" is respected in dfrn and ostatus.

pull/2503/head
Michael Vogel 4 years ago
parent
commit
fbc5404522
4 changed files with 37 additions and 41 deletions
  1. +25
    -4
      include/dfrn.php
  2. +3
    -35
      include/diaspora.php
  3. +2
    -0
      include/ostatus.php
  4. +7
    -2
      include/socgraph.php

+ 25
- 4
include/dfrn.php View File

@ -561,6 +561,13 @@ class dfrn {
}
}
// Is the profile hidden or shouldn't be published in the net? Then add the "hide" element
$r = q("SELECT `id` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `hidewall` OR NOT `net-publish` AND `user`.`uid` = %d",
intval($owner['uid']));
if ($r)
xml::add_element($doc, $author, "dfrn:hide", "true");
return $author;
}
@ -1126,7 +1133,7 @@ class dfrn {
$author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
$r = q("SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
`name`, `nick`, `about`, `location`, `keywords`, `bdyear`, `bd`
`name`, `nick`, `about`, `location`, `keywords`, `bdyear`, `bd`, `hidden`
FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
intval($importer["uid"]), dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
if ($r) {
@ -1210,6 +1217,19 @@ class dfrn {
/// - poco:region
/// - poco:country
// The profile is searchable if it contains poco data
$searchable = (isset($poco["name"]) OR isset($poco["nick"]) OR isset($poco["about"]) OR isset($poco["location"]));
// If the "hide" element is present then the profile isn't searchable.
// Since this element is new (version >= 3.5), we need the check above as well.
if ($xpath->evaluate($element."/dfrn:hide/text()", $context)->item(0)->nodeValue == "true")
$searchable = false;
// If the contact isn't searchable then set the contact to "hidden".
// Problem: This can be manually overridden by the user.
if (!$searchable)
$contact["hidden"] = true;
// Save the keywords into the contact table
$tags = array();
$tagelements = $xpath->evaluate($element."/poco:tags/text()", $context);
@ -1280,13 +1300,13 @@ class dfrn {
logger("Update contact data for contact ".$contact["id"]." (".$contact["nick"].")", LOGGER_DEBUG);
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s',
`addr` = '%s', `keywords` = '%s', `bdyear` = '%s', `bd` = '%s',
`addr` = '%s', `keywords` = '%s', `bdyear` = '%s', `bd` = '%s', `hidden` = %d,
`name-date` = '%s', `uri-date` = '%s'
WHERE `id` = %d AND `network` = '%s'",
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]),
dbesc($contact["bd"]), dbesc($contact["name-date"]), dbesc($contact["uri-date"]),
intval($contact["id"]), dbesc($contact["network"]));
dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["name-date"]),
dbesc($contact["uri-date"]), intval($contact["id"]), dbesc($contact["network"]));
}
update_contact_avatar($author["avatar"], $importer["uid"], $contact["id"],
@ -1299,6 +1319,7 @@ class dfrn {
$poco["generation"] = 2;
$poco["photo"] = $author["avatar"];
$poco["hide"] = !$searchable;
update_gcontact($poco);
}


+ 3
- 35
include/diaspora.php View File

@ -2,43 +2,11 @@
/**
* @file include/diaspora.php
* @brief The implementation of the diaspora protocol
*
* Checklist:
*
* Checked:
* - send status
* - send comment
* - send like
* - send mail
* - send status retraction
* - send comment retraction on own post
* - send like retraction on own post
* - send comment retraction on diaspora post
* - send like retraction on diaspora post
* - receive status
* - receive reshare
* - receive comment
* - receive like
* - receive connect request
* - receive profile data
* - receive mail
* - receive comment retraction
* - receive like retraction
* - relay comment
* - relay like
* - relay comment retraction from diaspora
* - relay comment retraction from friendica
* - relay like retraction from diaspora
* - relay like retraction from friendica
* - send share
*
* Should work:
* - receive account deletion
* - send unshare
*
* Unchecked:
*/
/// @todo reshare of some reshare doesn't work well, see guid c1d534b0ed19013358694860008dbc6c
// 14f571c0f244013358694860008dbc6c
require_once("include/items.php");
require_once("include/bb2diaspora.php");
require_once("include/Scrape.php");


+ 2
- 0
include/ostatus.php View File

@ -161,6 +161,7 @@ class ostatus {
}
$contact["generation"] = 2;
$contact["hide"] = false; // OStatus contacts are never hidden
$contact["photo"] = $author["author-avatar"];
update_gcontact($contact);
}
@ -691,6 +692,7 @@ class ostatus {
}
}
$contact["hide"] = false; // OStatus contacts are never hidden
update_gcontact($contact);
}


+ 7
- 2
include/socgraph.php View File

@ -1447,6 +1447,10 @@ function get_gcontact_id($contact) {
if ($contact["network"] == NETWORK_STATUSNET)
$contact["network"] = NETWORK_OSTATUS;
// All new contacts are hidden by default
if (!isset($contact["hide"]))
$contact["hide"] = true;
// Replace alternate OStatus user format with the primary one
fix_alternate_contact_address($contact);
@ -1469,8 +1473,8 @@ function get_gcontact_id($contact) {
$doprobing = (((time() - $last_contact) > (90 * 86400)) AND ((time() - $last_failure) > (90 * 86400)));
}
} else {
q("INSERT INTO `gcontact` (`name`, `nick`, `addr` , `network`, `url`, `nurl`, `photo`, `created`, `updated`, `location`, `about`, `generation`)
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
q("INSERT INTO `gcontact` (`name`, `nick`, `addr` , `network`, `url`, `nurl`, `photo`, `created`, `updated`, `location`, `about`, `hide`, `generation`)
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
dbesc($contact["name"]),
dbesc($contact["nick"]),
dbesc($contact["addr"]),
@ -1482,6 +1486,7 @@ function get_gcontact_id($contact) {
dbesc(datetime_convert()),
dbesc($contact["location"]),
dbesc($contact["about"]),
intval($contact["hide"]),
intval($contact["generation"])
);


Loading…
Cancel
Save