support auto-friend page types for Diaspora

This commit is contained in:
friendica 2012-01-04 14:30:25 -08:00
parent c1cf6e48c2
commit d0b743529d

View File

@ -464,7 +464,7 @@ function diaspora_request($importer,$xml) {
intval($importer['uid']) intval($importer['uid'])
); );
if((count($r)) && ($r[0]['hide-friends'] == 0)) { if((count($r)) && (! $r[0]['hide-friends']) && (! $contact['hidden'])) {
require_once('include/items.php'); require_once('include/items.php');
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
@ -527,6 +527,8 @@ function diaspora_request($importer,$xml) {
$batch = (($ret['batch']) ? $ret['batch'] : implode('/', array_slice(explode('/',$ret['url']),0,3)) . '/receive/public'); $batch = (($ret['batch']) ? $ret['batch'] : implode('/', array_slice(explode('/',$ret['url']),0,3)) . '/receive/public');
$r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`nurl`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`) $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`nurl`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
VALUES ( %d, '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ", VALUES ( %d, '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
intval($importer['uid']), intval($importer['uid']),
@ -550,9 +552,15 @@ function diaspora_request($importer,$xml) {
$contact_record = diaspora_get_contact_by_handle($importer['uid'],$sender_handle); $contact_record = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
$hash = random_string() . (string) time(); // Generate a confirm_key if(! $contact_record) {
logger('diaspora_request: unable to locate newly created contact record.');
return;
}
if($importer['page-flags'] == PAGE_NORMAL) {
$hash = random_string() . (string) time(); // Generate a confirm_key
if($contact_record) {
$ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime` ) $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime` )
VALUES ( %d, %d, %d, %d, '%s', '%s', '%s' )", VALUES ( %d, %d, %d, %d, '%s', '%s', '%s' )",
intval($importer['uid']), intval($importer['uid']),
@ -564,6 +572,45 @@ function diaspora_request($importer,$xml) {
dbesc(datetime_convert()) dbesc(datetime_convert())
); );
} }
else {
// automatic friend approval
require_once('include/Photo.php');
$photos = import_profile_photo($contact_record['photo'],$importer['uid'],$contact_record['id']);
// technically they are sharing with us (CONTACT_IS_SHARING),
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
// we are going to change the relationship and make them a follower.
if($importer['page-flags'] == PAGE_FREELOVE)
$new_relation = CONTACT_IS_FRIEND;
else
$new_relation = CONTACT_IS_FOLLOWER;
$r = q("UPDATE `contact` SET
`photo` = '%s',
`thumb` = '%s',
`micro` = '%s',
`rel` = %d,
`name-date` = '%s',
`uri-date` = '%s',
`avatar-date` = '%s',
`blocked` = 0,
`pending` = 0,
WHERE `id` = %d LIMIT 1
",
dbesc($photos[0]),
dbesc($photos[1]),
dbesc($photos[2]),
intval($new_relation),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($contact_record['id'])
);
}
return; return;
} }