Removing connectors we won't be needing - this is probably going to break some shit.
This commit is contained in:
@@ -119,10 +119,6 @@ function terminate_friendship($user,$self,$contact) {
|
||||
slapper($user,$contact['notify'],$slap);
|
||||
}
|
||||
}
|
||||
elseif($contact['network'] === NETWORK_DIASPORA) {
|
||||
require_once('include/diaspora.php');
|
||||
diaspora_unshare($user,$contact);
|
||||
}
|
||||
elseif($contact['network'] === NETWORK_DFRN) {
|
||||
require_once('include/items.php');
|
||||
dfrn_deliver($user,$contact,'placeholder', 1);
|
||||
|
||||
@@ -333,7 +333,6 @@ function scrape_feed($url) {
|
||||
|
||||
|
||||
define ( 'PROBE_NORMAL', 0);
|
||||
define ( 'PROBE_DIASPORA', 1);
|
||||
|
||||
function probe_url($url, $mode = PROBE_NORMAL) {
|
||||
require_once('include/email.php');
|
||||
@@ -344,10 +343,6 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
||||
return $result;
|
||||
|
||||
$network = null;
|
||||
$diaspora = false;
|
||||
$diaspora_base = '';
|
||||
$diaspora_guid = '';
|
||||
$diaspora_key = '';
|
||||
$has_lrdd = false;
|
||||
$email_conversant = false;
|
||||
|
||||
@@ -384,19 +379,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
||||
$profile = unamp($link['@attributes']['href']);
|
||||
if($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0')
|
||||
$poco = unamp($link['@attributes']['href']);
|
||||
if($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') {
|
||||
$diaspora_base = unamp($link['@attributes']['href']);
|
||||
$diaspora = true;
|
||||
}
|
||||
if($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') {
|
||||
$diaspora_guid = unamp($link['@attributes']['href']);
|
||||
$diaspora = true;
|
||||
}
|
||||
if($link['@attributes']['rel'] === 'diaspora-public-key') {
|
||||
$diaspora_key = base64_decode(unamp($link['@attributes']['href']));
|
||||
$pubkey = rsatopem($diaspora_key);
|
||||
$diaspora = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Status.Net can have more than one profile URL. We need to match the profile URL
|
||||
@@ -521,19 +504,8 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
||||
}
|
||||
}
|
||||
|
||||
if($diaspora && $diaspora_base && $diaspora_guid) {
|
||||
if($mode == PROBE_DIASPORA || ! $notify) {
|
||||
$notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
|
||||
$batch = $diaspora_base . 'receive/public' ;
|
||||
}
|
||||
if(strpos($url,'@'))
|
||||
$addr = str_replace('acct:', '', $url);
|
||||
}
|
||||
|
||||
if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
|
||||
if($diaspora)
|
||||
$network = NETWORK_DIASPORA;
|
||||
elseif($has_lrdd)
|
||||
if($has_lrdd)
|
||||
$network = NETWORK_OSTATUS;
|
||||
$priority = 0;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ function delivery_run($argv, $argc){
|
||||
require_once("datetime.php");
|
||||
require_once('include/items.php');
|
||||
require_once('include/bbcode.php');
|
||||
require_once('include/diaspora.php');
|
||||
require_once('include/email.php');
|
||||
|
||||
load_config('config');
|
||||
@@ -191,11 +190,6 @@ function delivery_run($argv, $argc){
|
||||
// be notified during this run.
|
||||
// Other DFRN conversation members will be alerted during polled updates.
|
||||
|
||||
// Diaspora members currently are not notified of expirations, and other networks have
|
||||
// either limited or no ability to process deletions. We should at least fix Diaspora
|
||||
// by stringing togther an array of retractions and sending them onward.
|
||||
|
||||
|
||||
$localhost = $a->get_hostname();
|
||||
if(strpos($localhost,':'))
|
||||
$localhost = substr($localhost,0,strpos($localhost,':'));
|
||||
@@ -363,177 +357,6 @@ function delivery_run($argv, $argc){
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_OSTATUS :
|
||||
|
||||
if(get_config('system','ostatus_disabled') || get_config('system','dfrn_only'))
|
||||
break;
|
||||
|
||||
// only send salmon if public - e.g. if it's ok to notify
|
||||
// a public hub, it's ok to send a salmon
|
||||
|
||||
if(($public_message) && (! $expire)) {
|
||||
$slaps = array();
|
||||
|
||||
foreach($items as $item) {
|
||||
if(! $item['parent'])
|
||||
continue;
|
||||
|
||||
// private emails may be in included in public conversations. Filter them.
|
||||
if(($public_message) && $item['private'] == 1)
|
||||
continue;
|
||||
|
||||
$item_contact = get_item_contact($item,$icontacts);
|
||||
if(! $item_contact)
|
||||
continue;
|
||||
|
||||
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
||||
$slaps[] = atom_entry($item,'html',null,$owner,true);
|
||||
}
|
||||
|
||||
logger('notifier: slapdelivery: ' . $contact['name']);
|
||||
foreach($slaps as $slappy) {
|
||||
if($contact['notify']) {
|
||||
if(! was_recently_delayed($contact['id']))
|
||||
$deliver_status = slapper($owner,$contact['notify'],$slappy);
|
||||
else
|
||||
$deliver_status = (-1);
|
||||
|
||||
if($deliver_status == (-1)) {
|
||||
// queue message for redelivery
|
||||
add_to_queue($contact['id'],NETWORK_OSTATUS,$slappy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NETWORK_MAIL :
|
||||
case NETWORK_MAIL2:
|
||||
|
||||
if(get_config('system','dfrn_only'))
|
||||
break;
|
||||
// WARNING: does not currently convert to RFC2047 header encodings, etc.
|
||||
|
||||
$addr = $contact['addr'];
|
||||
if(! strlen($addr))
|
||||
break;
|
||||
|
||||
if($cmd === 'wall-new' || $cmd === 'comment-new') {
|
||||
|
||||
$it = null;
|
||||
if($cmd === 'wall-new')
|
||||
$it = $items[0];
|
||||
else {
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($argv[2]),
|
||||
intval($uid)
|
||||
);
|
||||
if(count($r))
|
||||
$it = $r[0];
|
||||
}
|
||||
if(! $it)
|
||||
break;
|
||||
|
||||
|
||||
$local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
if(! count($local_user))
|
||||
break;
|
||||
|
||||
$reply_to = '';
|
||||
$r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
if($r1 && $r1[0]['reply_to'])
|
||||
$reply_to = $r1[0]['reply_to'];
|
||||
|
||||
$subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
|
||||
|
||||
// only expose our real email address to true friends
|
||||
|
||||
if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked']))
|
||||
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
|
||||
else
|
||||
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
|
||||
|
||||
if($reply_to)
|
||||
$headers .= 'Reply-to: ' . $reply_to . "\n";
|
||||
|
||||
// for testing purposes: Collect exported mails
|
||||
// $file = tempnam("/tmp/friendica/", "mail-out-");
|
||||
// file_put_contents($file, json_encode($it));
|
||||
|
||||
$headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n";
|
||||
|
||||
//logger("Mail: uri: ".$it['uri']." parent-uri ".$it['parent-uri'], LOGGER_DEBUG);
|
||||
//logger("Mail: Data: ".print_r($it, true), LOGGER_DEBUG);
|
||||
//logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
|
||||
|
||||
if($it['uri'] !== $it['parent-uri']) {
|
||||
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
|
||||
if(!strlen($it['title'])) {
|
||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
||||
dbesc($it['parent-uri']));
|
||||
|
||||
if(count($r) AND ($r[0]['title'] != ''))
|
||||
$subject = $r[0]['title'];
|
||||
}
|
||||
if(strncasecmp($subject,'RE:',3))
|
||||
$subject = 'Re: '.$subject;
|
||||
}
|
||||
email_send($addr, $subject, $headers, $it);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_DIASPORA :
|
||||
if($public_message)
|
||||
$loc = 'public batch ' . $contact['batch'];
|
||||
else
|
||||
$loc = $contact['name'];
|
||||
|
||||
logger('delivery: diaspora batch deliver: ' . $loc);
|
||||
|
||||
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
|
||||
break;
|
||||
|
||||
if((! $contact['pubkey']) && (! $public_message))
|
||||
break;
|
||||
|
||||
if($target_item['verb'] === ACTIVITY_DISLIKE) {
|
||||
// unsupported
|
||||
break;
|
||||
}
|
||||
elseif(($target_item['deleted']) && ($target_item['uri'] === $target_item['parent-uri'])) {
|
||||
// top-level retraction
|
||||
logger('delivery: diaspora retract: ' . $loc);
|
||||
|
||||
diaspora_send_retraction($target_item,$owner,$contact,$public_message);
|
||||
break;
|
||||
}
|
||||
elseif($target_item['uri'] !== $target_item['parent-uri']) {
|
||||
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
||||
logger('delivery: diaspora relay: ' . $loc);
|
||||
|
||||
diaspora_send_relay($target_item,$owner,$contact,$public_message);
|
||||
break;
|
||||
}
|
||||
elseif(($top_level) && (! $walltowall)) {
|
||||
// currently no workable solution for sending walltowall
|
||||
logger('delivery: diaspora status: ' . $loc);
|
||||
diaspora_send_status($target_item,$owner,$contact,$public_message);
|
||||
break;
|
||||
}
|
||||
|
||||
logger('delivery: diaspora unknown mode: ' . $contact['name']);
|
||||
|
||||
break;
|
||||
|
||||
case NETWORK_FEED :
|
||||
case NETWORK_FACEBOOK :
|
||||
if(get_config('system','dfrn_only'))
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
2571
include/diaspora.php
2571
include/diaspora.php
File diff suppressed because it is too large
Load Diff
@@ -62,16 +62,6 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// This extra param just confuses things, remove it
|
||||
if($ret['network'] === NETWORK_DIASPORA)
|
||||
$ret['url'] = str_replace('?absolute=true','',$ret['url']);
|
||||
|
||||
|
||||
// do we have enough information?
|
||||
|
||||
if(! ((x($ret,'name')) && (x($ret,'poll')) && ((x($ret,'url')) || (x($ret,'addr'))))) {
|
||||
@@ -107,14 +97,7 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
|
||||
$subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
|
||||
|
||||
$hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
|
||||
|
||||
if($ret['network'] === NETWORK_MAIL) {
|
||||
$writeable = 1;
|
||||
|
||||
}
|
||||
if($ret['network'] === NETWORK_DIASPORA)
|
||||
$writeable = 1;
|
||||
$hidden = 0;
|
||||
|
||||
// check if we already have a contact
|
||||
// the poll url is more reliable than the profile url, as we may have
|
||||
@@ -166,8 +149,6 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
}
|
||||
|
||||
$new_relation = (($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
|
||||
if($ret['network'] === NETWORK_DIASPORA)
|
||||
$new_relation = CONTACT_IS_FOLLOWER;
|
||||
|
||||
// create contact record
|
||||
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
|
||||
@@ -244,41 +225,6 @@ function new_contact($uid,$url,$interactive = false) {
|
||||
|
||||
proc_run('php',"include/poller.php","$contact_id");
|
||||
|
||||
// create a follow slap
|
||||
|
||||
$tpl = get_markup_template('follow_slap.tpl');
|
||||
$slap = replace_macros($tpl, array(
|
||||
'$name' => $a->user['username'],
|
||||
'$profile_page' => $a->get_baseurl() . '/profile/' . $a->user['nickname'],
|
||||
'$photo' => $a->contact['photo'],
|
||||
'$thumb' => $a->contact['thumb'],
|
||||
'$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME),
|
||||
'$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':follow:' . random_string(),
|
||||
'$title' => '',
|
||||
'$type' => 'text',
|
||||
'$content' => t('following'),
|
||||
'$nick' => $a->user['nickname'],
|
||||
'$verb' => ACTIVITY_FOLLOW,
|
||||
'$ostat_follow' => ''
|
||||
));
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
|
||||
require_once('include/salmon.php');
|
||||
slapper($r[0],$contact['notify'],$slap);
|
||||
}
|
||||
if($contact['network'] == NETWORK_DIASPORA) {
|
||||
require_once('include/diaspora.php');
|
||||
$ret = diaspora_share($a->user,$contact);
|
||||
logger('mod_follow: diaspora_share returns: ' . $ret);
|
||||
}
|
||||
}
|
||||
|
||||
$result['success'] = true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -474,21 +474,8 @@ function get_atom_elements($feed,$item) {
|
||||
$apps = $item->get_item_tags(NAMESPACE_STATUSNET,'notice_info');
|
||||
if($apps && $apps[0]['attribs']['']['source']) {
|
||||
$res['app'] = strip_tags(unxmlify($apps[0]['attribs']['']['source']));
|
||||
if($res['app'] === 'web')
|
||||
$res['app'] = 'OStatus';
|
||||
}
|
||||
|
||||
// base64 encoded json structure representing Diaspora signature
|
||||
|
||||
$dsig = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_signature');
|
||||
if($dsig) {
|
||||
$res['dsprsig'] = unxmlify($dsig[0]['data']);
|
||||
}
|
||||
|
||||
$dguid = $item->get_item_tags(NAMESPACE_DFRN,'diaspora_guid');
|
||||
if($dguid)
|
||||
$res['guid'] = unxmlify($dguid[0]['data']);
|
||||
|
||||
/**
|
||||
* If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it.
|
||||
*/
|
||||
@@ -800,22 +787,11 @@ function encode_rel_links($links) {
|
||||
|
||||
function item_store($arr,$force_parent = false) {
|
||||
|
||||
// If a Diaspora signature structure was passed in, pull it out of the
|
||||
// item array and set it aside for later storage.
|
||||
|
||||
$dsprsig = null;
|
||||
if(x($arr,'dsprsig')) {
|
||||
$dsprsig = json_decode(base64_decode($arr['dsprsig']));
|
||||
unset($arr['dsprsig']);
|
||||
}
|
||||
|
||||
if(! $arr['uid']) {
|
||||
logger('item_store: no uid');
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(x($arr, 'gravity'))
|
||||
$arr['gravity'] = intval($arr['gravity']);
|
||||
elseif($arr['parent-uri'] === $arr['uri'])
|
||||
@@ -1152,15 +1128,10 @@ function tag_deliver($uid,$item_id) {
|
||||
|
||||
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
|
||||
|
||||
// Diaspora uses their own hardwired link URL in @-tags
|
||||
// instead of the one we supply with webfinger
|
||||
|
||||
$dlink = normalise_link($a->get_baseurl() . '/u/' . $u[0]['nickname']);
|
||||
|
||||
$cnt = preg_match_all('/[\@\!]\[url\=(.*?)\](.*?)\[\/url\]/ism',$item['body'],$matches,PREG_SET_ORDER);
|
||||
if($cnt) {
|
||||
foreach($matches as $mtch) {
|
||||
if(link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
|
||||
if(link_compare($link,$mtch[1])) {
|
||||
$mention = true;
|
||||
logger('tag_deliver: mention found: ' . $mtch[2]);
|
||||
}
|
||||
@@ -3080,11 +3051,7 @@ function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
|
||||
);
|
||||
}
|
||||
|
||||
// Diaspora has different message-ids in feeds than they do
|
||||
// through the direct Diaspora protocol. If we try and use
|
||||
// the feed, we'll get duplicates. So don't.
|
||||
|
||||
if((! count($r)) || $contact['network'] === NETWORK_DIASPORA)
|
||||
if(! count($r))
|
||||
return;
|
||||
|
||||
$push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
|
||||
@@ -3194,13 +3161,6 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
|
||||
if($item['app'])
|
||||
$o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n";
|
||||
|
||||
if($item['guid'])
|
||||
$o .= '<dfrn:diaspora_guid>' . $item['guid'] . '</dfrn:diaspora_guid>' . "\r\n";
|
||||
|
||||
if($item['signed_text']) {
|
||||
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
|
||||
$o .= '<dfrn:diaspora_signature>' . xmlify($sign) . '</dfrn:diaspora_signature>' . "\r\n";
|
||||
}
|
||||
|
||||
$verb = construct_verb($item);
|
||||
$o .= '<as:verb>' . xmlify($verb) . '</as:verb>' . "\r\n";
|
||||
@@ -3610,8 +3570,6 @@ function drop_item($id,$interactive = true) {
|
||||
);
|
||||
}
|
||||
|
||||
// Add a relayable_retraction signature for Diaspora.
|
||||
store_diaspora_retract_sig($item, $a->user, $a->get_baseurl());
|
||||
}
|
||||
$drop_id = intval($item['id']);
|
||||
|
||||
@@ -3703,54 +3661,6 @@ function posted_date_widget($url,$uid,$wall) {
|
||||
}
|
||||
|
||||
|
||||
function store_diaspora_retract_sig($item, $user, $baseurl) {
|
||||
// Note that we can't add a target_author_signature
|
||||
// if the comment was deleted by a remote user. That should be ok, because if a remote user is deleting
|
||||
// the comment, that means we're the home of the post, and Diaspora will only
|
||||
// check the parent_author_signature of retractions that it doesn't have to relay further
|
||||
//
|
||||
// I don't think this function gets called for an "unlike," but I'll check anyway
|
||||
|
||||
$enabled = intval(get_config('system','diaspora_enabled'));
|
||||
if(! $enabled) {
|
||||
logger('drop_item: diaspora support disabled, not storing retraction signature', LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
logger('drop_item: storing diaspora retraction signature');
|
||||
|
||||
$signed_text = $item['guid'] . ';' . ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
|
||||
|
||||
if(local_user() == $item['uid']) {
|
||||
|
||||
$handle = $user['nickname'] . '@' . substr($baseurl, strpos($baseurl,'://') + 3);
|
||||
$authorsig = base64_encode(rsa_sign($signed_text,$user['prvkey'],'sha256'));
|
||||
}
|
||||
else {
|
||||
$r = q("SELECT `nick`, `url` FROM `contact` WHERE `id` = '%d' LIMIT 1",
|
||||
$item['contact-id'] // If this function gets called, drop_item() has already checked remote_user() == $item['contact-id']
|
||||
);
|
||||
if(count($r)) {
|
||||
// The below handle only works for NETWORK_DFRN. I think that's ok, because this function
|
||||
// only handles DFRN deletes
|
||||
$handle_baseurl_start = strpos($r['url'],'://') + 3;
|
||||
$handle_baseurl_length = strpos($r['url'],'/profile') - $handle_baseurl_start;
|
||||
$handle = $r['nick'] . '@' . substr($r['url'], $handle_baseurl_start, $handle_baseurl_length);
|
||||
$authorsig = '';
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($handle))
|
||||
q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
|
||||
intval($item['id']),
|
||||
dbesc($signed_text),
|
||||
dbesc($authorsig),
|
||||
dbesc($handle)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function fetch_post_tags($items) {
|
||||
|
||||
$tag_finder = array();
|
||||
|
||||
@@ -196,11 +196,6 @@ function notifier_run($argv, $argc){
|
||||
|
||||
|
||||
|
||||
// Diaspora members currently are not notified of expirations, and other networks have
|
||||
// either limited or no ability to process deletions. We should at least fix Diaspora
|
||||
// by stringing togther an array of retractions and sending them onward.
|
||||
|
||||
|
||||
$localhost = str_replace('www.','',$a->get_hostname());
|
||||
if(strpos($localhost,':'))
|
||||
$localhost = substr($localhost,0,strpos($localhost,':'));
|
||||
@@ -468,8 +463,6 @@ function notifier_run($argv, $argc){
|
||||
|
||||
foreach($r as $contact) {
|
||||
if((! $mail) && (! $fsuggest) && (! $followup) && (! $contact['self'])) {
|
||||
if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
|
||||
continue;
|
||||
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
|
||||
dbesc($cmd),
|
||||
intval($item_id),
|
||||
@@ -628,140 +621,6 @@ function notifier_run($argv, $argc){
|
||||
}
|
||||
break;
|
||||
|
||||
case NETWORK_MAIL:
|
||||
case NETWORK_MAIL2:
|
||||
|
||||
if(get_config('system','dfrn_only'))
|
||||
break;
|
||||
|
||||
// WARNING: does not currently convert to RFC2047 header encodings, etc.
|
||||
|
||||
$addr = $contact['addr'];
|
||||
if(! strlen($addr))
|
||||
break;
|
||||
|
||||
if($cmd === 'wall-new' || $cmd === 'comment-new') {
|
||||
|
||||
$it = null;
|
||||
if($cmd === 'wall-new')
|
||||
$it = $items[0];
|
||||
else {
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($argv[2]),
|
||||
intval($uid)
|
||||
);
|
||||
if(count($r))
|
||||
$it = $r[0];
|
||||
}
|
||||
if(! $it)
|
||||
break;
|
||||
|
||||
|
||||
|
||||
$local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
if(! count($local_user))
|
||||
break;
|
||||
|
||||
$reply_to = '';
|
||||
$r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
if($r1 && $r1[0]['reply_to'])
|
||||
$reply_to = $r1[0]['reply_to'];
|
||||
|
||||
$subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
|
||||
|
||||
// only expose our real email address to true friends
|
||||
|
||||
if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked']))
|
||||
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
|
||||
else
|
||||
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
|
||||
|
||||
if($reply_to)
|
||||
$headers .= 'Reply-to: ' . $reply_to . "\n";
|
||||
|
||||
// for testing purposes: Collect exported mails
|
||||
//$file = tempnam("/tmp/friendica/", "mail-out2-");
|
||||
//file_put_contents($file, json_encode($it));
|
||||
|
||||
$headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n";
|
||||
|
||||
if($it['uri'] !== $it['parent-uri']) {
|
||||
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
|
||||
if(!strlen($it['title'])) {
|
||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
||||
dbesc($it['parent-uri']));
|
||||
|
||||
if(count($r) AND ($r[0]['title'] != ''))
|
||||
$subject = $r[0]['title'];
|
||||
}
|
||||
if(strncasecmp($subject,'RE:',3))
|
||||
$subject = 'Re: '.$subject;
|
||||
}
|
||||
email_send($addr, $subject, $headers, $it);
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
require_once('include/diaspora.php');
|
||||
|
||||
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')))
|
||||
break;
|
||||
|
||||
if($mail) {
|
||||
diaspora_send_mail($item,$owner,$contact);
|
||||
break;
|
||||
}
|
||||
|
||||
if(! $normal_mode)
|
||||
break;
|
||||
|
||||
// special handling for followup to public post
|
||||
// all other public posts processed as public batches further below
|
||||
|
||||
if($public_message) {
|
||||
if($followup)
|
||||
diaspora_send_followup($target_item,$owner,$contact, true);
|
||||
break;
|
||||
}
|
||||
|
||||
if(! $contact['pubkey'])
|
||||
break;
|
||||
|
||||
if($target_item['verb'] === ACTIVITY_DISLIKE) {
|
||||
// unsupported
|
||||
break;
|
||||
}
|
||||
elseif(($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
|
||||
// send both top-level retractions and relayable retractions for owner to relay
|
||||
diaspora_send_retraction($target_item,$owner,$contact);
|
||||
break;
|
||||
}
|
||||
elseif($followup) {
|
||||
// send comments and likes to owner to relay
|
||||
diaspora_send_followup($target_item,$owner,$contact);
|
||||
break;
|
||||
}
|
||||
elseif($target_item['uri'] !== $target_item['parent-uri']) {
|
||||
// we are the relay - send comments, likes and relayable_retractions
|
||||
// (of comments and likes) to our conversants
|
||||
diaspora_send_relay($target_item,$owner,$contact);
|
||||
break;
|
||||
}
|
||||
elseif(($top_level) && (! $walltowall)) {
|
||||
// currently no workable solution for sending walltowall
|
||||
diaspora_send_status($target_item,$owner,$contact);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case NETWORK_FEED:
|
||||
case NETWORK_FACEBOOK:
|
||||
if(get_config('system','dfrn_only'))
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -785,14 +644,7 @@ function notifier_run($argv, $argc){
|
||||
|
||||
if($public_message) {
|
||||
|
||||
$r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
|
||||
AND `uid` = %d AND `rel` != %d group by `batch` ORDER BY rand() ",
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
intval($owner['uid']),
|
||||
intval(CONTACT_IS_SHARING)
|
||||
);
|
||||
|
||||
$r2 = q("SELECT `id`, `name`,`network` FROM `contact`
|
||||
$r = q("SELECT `id`, `name`,`network` FROM `contact`
|
||||
WHERE `network` in ( '%s', '%s') AND `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
|
||||
AND `rel` != %d order by rand() ",
|
||||
dbesc(NETWORK_DFRN),
|
||||
@@ -801,7 +653,6 @@ function notifier_run($argv, $argc){
|
||||
intval(CONTACT_IS_SHARING)
|
||||
);
|
||||
|
||||
$r = array_merge($r2,$r1);
|
||||
|
||||
if(count($r)) {
|
||||
logger('pubdeliver: ' . print_r($r,true), LOGGER_DEBUG);
|
||||
@@ -820,10 +671,7 @@ function notifier_run($argv, $argc){
|
||||
|
||||
foreach($r as $rr) {
|
||||
|
||||
// except for Diaspora batch jobs
|
||||
// Don't deliver to folks who have already been delivered to
|
||||
|
||||
if(($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
|
||||
if(in_array($rr['id'],$conversants)) {
|
||||
logger('notifier: already delivered id=' . $rr['id']);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('include/datetime.php');
|
||||
require_once('include/diaspora.php');
|
||||
require_once('include/queue_fn.php');
|
||||
|
||||
function profile_change() {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
// $url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
|
||||
// if($url && strlen(get_config('system','directory_submit_url')))
|
||||
// proc_run('php',"include/directory.php","$url");
|
||||
|
||||
$recips = q("SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
|
||||
AND `uid` = %d AND `rel` != %d ",
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
intval(local_user()),
|
||||
intval(CONTACT_IS_SHARING)
|
||||
);
|
||||
if(! count($recips))
|
||||
return;
|
||||
|
||||
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile`
|
||||
LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`uid` = %d AND `profile`.`is-default` = 1 LIMIT 1",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
if(! count($r))
|
||||
return;
|
||||
$profile = $r[0];
|
||||
|
||||
$handle = xmlify($a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3));
|
||||
$first = xmlify(((strpos($profile['name'],' '))
|
||||
? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']));
|
||||
$last = xmlify((($first === $profile['name']) ? '' : trim(substr($profile['name'],strlen($first)))));
|
||||
$large = xmlify($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg');
|
||||
$medium = xmlify($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg');
|
||||
$small = xmlify($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg');
|
||||
$searchable = xmlify((($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ));
|
||||
// $searchable = 'true';
|
||||
|
||||
if($searchable === 'true') {
|
||||
$dob = '1000-00-00';
|
||||
|
||||
if(($profile['dob']) && ($profile['dob'] != '0000-00-00'))
|
||||
$dob = ((intval($profile['dob'])) ? intval($profile['dob']) : '1000') . '-' . datetime_convert('UTC','UTC',$profile['dob'],'m-d');
|
||||
$gender = xmlify($profile['gender']);
|
||||
$about = xmlify($profile['about']);
|
||||
require_once('include/bbcode.php');
|
||||
$about = xmlify(strip_tags(bbcode($about)));
|
||||
$location = '';
|
||||
if($profile['locality'])
|
||||
$location .= $profile['locality'];
|
||||
if($profile['region']) {
|
||||
if($location)
|
||||
$location .= ', ';
|
||||
$location .= $profile['region'];
|
||||
}
|
||||
if($profile['country-name']) {
|
||||
if($location)
|
||||
$location .= ', ';
|
||||
$location .= $profile['country-name'];
|
||||
}
|
||||
$location = xmlify($location);
|
||||
$tags = '';
|
||||
if($profile['pub_keywords']) {
|
||||
$kw = str_replace(',',' ',$profile['pub_keywords']);
|
||||
$kw = str_replace(' ',' ',$kw);
|
||||
$arr = explode(' ',$profile['pub_keywords']);
|
||||
if(count($arr)) {
|
||||
for($x = 0; $x < 5; $x ++) {
|
||||
if(trim($arr[$x]))
|
||||
$tags .= '#' . trim($arr[$x]) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
$tags = xmlify(trim($tags));
|
||||
}
|
||||
|
||||
$tpl = get_markup_template('diaspora_profile.tpl');
|
||||
|
||||
$msg = replace_macros($tpl,array(
|
||||
'$handle' => $handle,
|
||||
'$first' => $first,
|
||||
'$last' => $last,
|
||||
'$large' => $large,
|
||||
'$medium' => $medium,
|
||||
'$small' => $small,
|
||||
'$dob' => $dob,
|
||||
'$gender' => $gender,
|
||||
'$about' => $about,
|
||||
'$location' => $location,
|
||||
'$searchable' => $searchable,
|
||||
'$tags' => $tags
|
||||
));
|
||||
logger('profile_change: ' . $msg, LOGGER_ALL);
|
||||
|
||||
foreach($recips as $recip) {
|
||||
$msgtosend = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$a->user,$recip,$a->user['prvkey'],$recip['pubkey'],false)));
|
||||
add_to_queue($recip['id'],NETWORK_DIASPORA,$msgtosend,false);
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,6 @@ function queue_run($argv, $argc){
|
||||
// delivery loop
|
||||
|
||||
require_once('include/salmon.php');
|
||||
require_once('include/diaspora.php');
|
||||
|
||||
foreach($r as $q_item) {
|
||||
|
||||
@@ -147,28 +146,6 @@ function queue_run($argv, $argc){
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
case NETWORK_OSTATUS:
|
||||
if($contact['notify']) {
|
||||
logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
|
||||
$deliver_status = slapper($owner,$contact['notify'],$data);
|
||||
|
||||
if($deliver_status == (-1))
|
||||
update_queue_time($q_item['id']);
|
||||
else
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
if($contact['notify']) {
|
||||
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
|
||||
$deliver_status = diaspora_transmit($owner,$contact,$data,$public,true);
|
||||
|
||||
if($deliver_status == (-1))
|
||||
update_queue_time($q_item['id']);
|
||||
else
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
|
||||
|
||||
Reference in New Issue
Block a user