- // potentially more than one recipient. Start a new process and space them out a bit.
- // we will deliver single recipient types of message and email recipients here.
-
- if((! $mail) && (! $fsuggest) && (! $followup)) {
-
- $this_batch[] = $contact['id'];
-
- if(count($this_batch) == $deliveries_per_process) {
- proc_run('php','include/delivery.php',$cmd,$item_id,$this_batch);
- $this_batch = array();
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
- }
- continue;
- }
-
- $deliver_status = 0;
-
- logger("main delivery by notifier: followup=$followup mail=$mail fsuggest=$fsuggest");
-
- switch($contact['network']) {
- case NETWORK_DFRN:
-
- // perform local delivery if we are on the same site
-
- $basepath = implode('/', array_slice(explode('/',$contact['url']),0,3));
-
- if(link_compare($basepath,$a->get_baseurl())) {
-
- $nickname = basename($contact['url']);
- if($contact['issued-id'])
- $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
- else
- $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
-
- $x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
- `contact`.`pubkey` AS `cpubkey`,
- `contact`.`prvkey` AS `cprvkey`,
- `contact`.`thumb` AS `thumb`,
- `contact`.`url` as `url`,
- `contact`.`name` as `senderName`,
- `user`.*
- FROM `contact`
- LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
- WHERE `contact`.`blocked` = 0 AND `contact`.`archive` = 0
- AND `contact`.`pending` = 0
- AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
- $sql_extra
- AND `user`.`account_expired` = 0 AND `user`.`account_removed` = 0 LIMIT 1",
- dbesc(NETWORK_DFRN),
- dbesc($nickname)
- );
-
- if($x && count($x)) {
- $write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
- if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) {
- q("update contact set writable = 1 where id = %d limit 1",
- intval($x[0]['id'])
- );
- $x[0]['writable'] = 1;
- }
-
- // if contact's ssl policy changed, which we just determined
- // is on our own server, update our contact links
-
- $ssl_policy = get_config('system','ssl_policy');
- fix_contact_ssl_policy($x[0],$ssl_policy);
-
- // If we are setup as a soapbox we aren't accepting input from this person
-
- if($x[0]['page-flags'] == PAGE_SOAPBOX)
- break;
-
- require_once('library/simplepie/simplepie.inc');
- logger('mod-delivery: local delivery');
- local_delivery($x[0],$atom);
- break;
- }
- }
-
-
-
- logger('notifier: dfrndelivery: ' . $contact['name']);
- $deliver_status = dfrn_deliver($owner,$contact,$atom);
-
- logger('notifier: dfrn_delivery returns ' . $deliver_status);
-
- if($deliver_status == (-1)) {
- logger('notifier: delivery failed: queuing message');
- // queue message for redelivery
- add_to_queue($contact['id'],NETWORK_DFRN,$atom);
- }
- break;
- case NETWORK_OSTATUS:
-
- // Do not send to ostatus if we are not configured to send to public networks
- if($owner['prvnets'])
- break;
- if(get_config('system','ostatus_disabled') || get_config('system','dfrn_only'))
- break;
-
- if($followup && $contact['notify']) {
- logger('notifier: slapdelivery: ' . $contact['name']);
- $deliver_status = slapper($owner,$contact['notify'],$slap);
-
- if($deliver_status == (-1)) {
- // queue message for redelivery
- add_to_queue($contact['id'],NETWORK_OSTATUS,$slap);
- }
- }
- else {
-
- // only send salmon if public - e.g. if it's ok to notify
- // a public hub, it's ok to send a salmon
-
- if((count($slaps)) && ($public_message) && (! $expire)) {
- logger('notifier: slapdelivery: ' . $contact['name']);
- foreach($slaps as $slappy) {
- if($contact['notify']) {
- $deliver_status = slapper($owner,$contact['notify'],$slappy);
- 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.