Browse Source

more backend work on mail2 followers

pull/224/merge
friendica 9 years ago
parent
commit
19b636e7e8
2 changed files with 57 additions and 9 deletions
  1. +3
    -0
      include/items.php
  2. +54
    -9
      mod/dfrn_request.php

+ 3
- 0
include/items.php 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


+ 54
- 9
mod/dfrn_request.php 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,17 +310,60 @@ function dfrn_request_post(&$a) {
return;
}
// Canonicalise email-style profile locator
$hcard = '';
$url = webfinger_dfrn($url,$hcard);
if(substr($url,0,5) === 'stat:') {
$network = NETWORK_OSTATUS;
$url = substr($url,5);
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 {
$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);


Loading…
Cancel
Save