Diaspora: Auto-adding users as friend who already sharing with us

This commit is contained in:
Michael - piratica.eu 2013-01-20 14:08:28 +01:00
parent 452ff19d73
commit 7ab335c9d6
6 changed files with 33 additions and 18 deletions

View File

@ -346,7 +346,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$network = null; $network = null;
$diaspora = false; $diaspora = false;
$diaspora_base = ''; $diaspora_base = '';
$diaspora_guid = ''; $diaspora_guid = '';
$diaspora_key = ''; $diaspora_key = '';
$has_lrdd = false; $has_lrdd = false;
$email_conversant = false; $email_conversant = false;
@ -485,7 +485,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
} }
} }
} }
} }
if($mode == PROBE_NORMAL) { if($mode == PROBE_NORMAL) {
if(strlen($zot)) { if(strlen($zot)) {
@ -531,7 +531,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
} }
if(strpos($url,'@')) if(strpos($url,'@'))
$addr = str_replace('acct:', '', $url); $addr = str_replace('acct:', '', $url);
} }
if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
if($diaspora) if($diaspora)
@ -544,13 +544,13 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard = scrape_vcard($hcard); $vcard = scrape_vcard($hcard);
// Google doesn't use absolute url in profile photos // Google doesn't use absolute url in profile photos
if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') { if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') {
$h = @parse_url($hcard); $h = @parse_url($hcard);
if($h) if($h)
$vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo']; $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo'];
} }
logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA); logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA);
} }
@ -561,7 +561,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard['nick'] = $addr_parts[0]; $vcard['nick'] = $addr_parts[0];
} }
if($twitter) { if($twitter) {
logger('twitter: setup'); logger('twitter: setup');
$tid = basename($url); $tid = basename($url);
$tapi = 'https://api.twitter.com/1/statuses/user_timeline.rss'; $tapi = 'https://api.twitter.com/1/statuses/user_timeline.rss';

View File

@ -557,7 +557,7 @@ function diaspora_decode($importer,$xml) {
} }
function diaspora_request($importer,$xml) { function diaspora_request($importer,$xml) {
$a = get_app(); $a = get_app();
@ -567,7 +567,7 @@ function diaspora_request($importer,$xml) {
if(! $sender_handle || ! $recipient_handle) if(! $sender_handle || ! $recipient_handle)
return; return;
$contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle); $contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
if($contact) { if($contact) {
@ -752,6 +752,20 @@ function diaspora_request($importer,$xml) {
} }
function diaspora_post_allow($importer,$contact) { function diaspora_post_allow($importer,$contact) {
// perhaps we were already sharing with this person. Now they're sharing with us.
// That makes us friends.
// Normally this should have handled by getting a request - but this could get lost
if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval(CONTACT_IS_FRIEND),
intval($contact['id']),
intval($importer['uid'])
);
$contact['rel'] = CONTACT_IS_FRIEND;
logger('diaspora_post_allow: defining user '.$contact["nick"].' as friend');
}
if(($contact['blocked']) || ($contact['readonly']) || ($contact['archive'])) if(($contact['blocked']) || ($contact['readonly']) || ($contact['archive']))
return false; return false;
if($contact['rel'] == CONTACT_IS_SHARING || $contact['rel'] == CONTACT_IS_FRIEND) if($contact['rel'] == CONTACT_IS_SHARING || $contact['rel'] == CONTACT_IS_FRIEND)

View File

@ -48,9 +48,9 @@ function new_contact($uid,$url,$interactive = false) {
$myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']); $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
else else
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname()); $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
goaway($ret['request'] . "&addr=$myaddr"); goaway($ret['request'] . "&addr=$myaddr");
// NOTREACHED // NOTREACHED
} }
} }
@ -61,7 +61,7 @@ function new_contact($uid,$url,$interactive = false) {
return $result; return $result;
} }
} }

View File

@ -367,6 +367,7 @@ function lrdd($uri, $debug = false) {
logger('lrdd: constructed url: ' . $url); logger('lrdd: constructed url: ' . $url);
$xml = fetch_url($url); $xml = fetch_url($url);
$headers = $a->get_curl_headers(); $headers = $a->get_curl_headers();
if (! $xml) if (! $xml)

View File

@ -9,7 +9,7 @@ function poller_run(&$argv, &$argc){
if(is_null($a)) { if(is_null($a)) {
$a = new App; $a = new App;
} }
if(is_null($db)) { if(is_null($db)) {
@include(".htconfig.php"); @include(".htconfig.php");
require_once("include/dba.php"); require_once("include/dba.php");
@ -57,17 +57,17 @@ function poller_run(&$argv, &$argc){
load_hooks(); load_hooks();
logger('poller: start'); logger('poller: start');
// run queue delivery process in the background // run queue delivery process in the background
proc_run('php',"include/queue.php"); proc_run('php',"include/queue.php");
// expire any expired accounts // expire any expired accounts
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0 q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
AND `account_expires_on` != '0000-00-00 00:00:00' AND `account_expires_on` != '0000-00-00 00:00:00'
AND `account_expires_on` < UTC_TIMESTAMP() "); AND `account_expires_on` < UTC_TIMESTAMP() ");
// delete user and contact records for recently removed accounts // delete user and contact records for recently removed accounts
$r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); $r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
@ -77,12 +77,12 @@ function poller_run(&$argv, &$argc){
q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid'])); q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
} }
} }
$abandon_days = intval(get_config('system','account_abandon_days')); $abandon_days = intval(get_config('system','account_abandon_days'));
if($abandon_days < 1) if($abandon_days < 1)
$abandon_days = 0; $abandon_days = 0;
// once daily run birthday_updates and then expire in background // once daily run birthday_updates and then expire in background

View File

@ -18,7 +18,7 @@
</ul> </ul>
</div> </div>
{{ else }} {{ else }}
<!-- <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles/$profid" ></a></div> --> <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles" ></a></div>
{{ endif }} {{ endif }}
</div> </div>