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

View file

@ -261,7 +261,7 @@ function dfrn_request_post(&$a) {
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
AND `contact`.`network` != '%s' AND `contact`.`network` != '%s'
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ", AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ",
dbesc(NETWORK_MAIL) dbesc(NETWORK_MAIL2)
); );
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
@ -286,7 +286,7 @@ function dfrn_request_post(&$a) {
WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0
AND `contact`.`network` = '%s' AND `contact`.`network` = '%s'
AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ", AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 3 DAY ",
dbesc(NETWORK_MAIL) dbesc(NETWORK_MAIL2)
); );
if(count($r)) { if(count($r)) {
foreach($r as $rr) { 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']); $url = trim($_POST['dfrn_url']);
if(! strlen($url)) { if(! strlen($url)) {
@ -308,17 +310,60 @@ function dfrn_request_post(&$a) {
return; return;
} }
// Canonicalise email-style profile locator
$hcard = ''; $hcard = '';
$url = webfinger_dfrn($url,$hcard);
if(substr($url,0,5) === 'stat:') { if($email_follow) {
$network = NETWORK_OSTATUS;
$url = substr($url,5); 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 { else {
$network = NETWORK_DFRN;
// Canonicalise email-style profile locator
$url = webfinger_dfrn($url,$hcard);
if(substr($url,0,5) === 'stat:') {
$network = NETWORK_OSTATUS;
$url = substr($url,5);
}
else {
$network = NETWORK_DFRN;
}
} }
logger('dfrn_request: url: ' . $url); logger('dfrn_request: url: ' . $url);