more backend work on mail2 followers

This commit is contained in:
friendica 2012-04-10 19:15:52 -07:00
parent ed608694ce
commit 19b636e7e8
2 changed files with 57 additions and 9 deletions

View file

@ -1856,6 +1856,8 @@ function local_delivery($importer,$data) {
$feed->enable_order_by_date(false);
$feed->init();
/*
// Currently unsupported - needs a lot of work
$reloc = $feed->get_feed_tags( NAMESPACE_DFRN, 'relocate' );
if(isset($reloc[0]['child'][NAMESPACE_DFRN])) {
$base = $reloc[0]['child'][NAMESPACE_DFRN];
@ -1880,6 +1882,7 @@ function local_delivery($importer,$data) {
// schedule a scan?
}
*/
// handle friend suggestion notification

View file

@ -261,7 +261,7 @@ function dfrn_request_post(&$a) {
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
AND `contact`.`network` != '%s'
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
dbesc(NETWORK_MAIL)
dbesc(NETWORK_MAIL2)
);
if(count($r)) {
foreach($r as $rr) {
@ -286,7 +286,7 @@ function dfrn_request_post(&$a) {
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
AND `contact`.`network` = '%s'
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
dbesc(NETWORK_MAIL)
dbesc(NETWORK_MAIL2)
);
if(count($r)) {
foreach($r as $rr) {
@ -301,6 +301,8 @@ function dfrn_request_post(&$a) {
}
}
$email_follow = (x($_POST,'email_follow') ? intval($_POST['email_follow']) : 0);
$real_name = (x($_POST,'realname') ? notags(trim($_POST['realname'])) : '');
$url = trim($_POST['dfrn_url']);
if(! strlen($url)) {
@ -308,9 +310,51 @@ function dfrn_request_post(&$a) {
return;
}
$hcard = '';
if($email_follow) {
if(! strpos($url,'@')) {
notice( t('Invalid email address.') . EOL);
return;
}
$addr = $url;
$name = ($realname) ? $realname : $addr;
$nick = substr($addr,0,strpos($addr,'@'));
$url = 'http://' . substr($addr,strpos($addr,'@') + 1);
$nurl = normalise_url($host);
$poll = 'email ' . random_string();
$notify = 'smtp ' . random_string();
$blocked = 1;
$pending = 1;
$network = NETWORK_MAIL2;
$rel = CONTACT_IS_FOLLOWER;
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(get_config('system','dfrn_only'))
$mail_disabled = 1;
if(! $mail_disabled) {
$failed = false;
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid)
);
if(! count($r)) {
notice( t('This account has not been configured for email. Request failed.') . EOL);
return;
}
}
}
else {
// Canonicalise email-style profile locator
$hcard = '';
$url = webfinger_dfrn($url,$hcard);
if(substr($url,0,5) === 'stat:') {
@ -320,6 +364,7 @@ function dfrn_request_post(&$a) {
else {
$network = NETWORK_DFRN;
}
}
logger('dfrn_request: url: ' . $url);