|
|
@ -90,7 +90,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
$expire = false; |
|
|
|
$mail = false; |
|
|
|
$fsuggest = false; |
|
|
|
$relocate = false; |
|
|
|
$relocate = false; |
|
|
|
$top_level = false; |
|
|
|
$recipients = array(); |
|
|
|
$url_recipients = array(); |
|
|
@ -110,11 +110,10 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
$recipients[] = $message[0]['contact-id']; |
|
|
|
$item = $message[0]; |
|
|
|
|
|
|
|
} |
|
|
|
elseif($cmd === 'expire') { |
|
|
|
} elseif($cmd === 'expire') { |
|
|
|
$normal_mode = false; |
|
|
|
$expire = true; |
|
|
|
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
|
|
|
|
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
|
|
|
|
AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE",
|
|
|
|
intval($item_id) |
|
|
|
); |
|
|
@ -122,8 +121,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
$item_id = 0; |
|
|
|
if(! count($items)) |
|
|
|
return; |
|
|
|
} |
|
|
|
elseif($cmd === 'suggest') { |
|
|
|
} elseif($cmd === 'suggest') { |
|
|
|
$normal_mode = false; |
|
|
|
$fsuggest = true; |
|
|
|
|
|
|
@ -135,8 +133,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
$uid = $suggest[0]['uid']; |
|
|
|
$recipients[] = $suggest[0]['cid']; |
|
|
|
$item = $suggest[0]; |
|
|
|
} |
|
|
|
elseif($cmd === 'removeme') { |
|
|
|
} elseif($cmd === 'removeme') { |
|
|
|
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($item_id)); |
|
|
|
if (! $r) |
|
|
|
return; |
|
|
@ -156,13 +153,11 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
terminate_friendship($user, $self, $contact); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
elseif($cmd === 'relocate') { |
|
|
|
$normal_mode = false; |
|
|
|
} elseif($cmd === 'relocate') { |
|
|
|
$normal_mode = false; |
|
|
|
$relocate = true; |
|
|
|
$uid = $item_id; |
|
|
|
} |
|
|
|
else { |
|
|
|
$uid = $item_id; |
|
|
|
} else { |
|
|
|
// find ancestors
|
|
|
|
$r = q("SELECT * FROM `item` WHERE `id` = %d and visible = 1 and moderated = 0 LIMIT 1", |
|
|
|
intval($item_id) |
|
|
@ -181,7 +176,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
if(! $parent_id) |
|
|
|
return; |
|
|
|
|
|
|
|
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
|
|
|
|
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
|
|
|
|
FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d and visible = 1 and moderated = 0 ORDER BY `id` ASC",
|
|
|
|
intval($parent_id) |
|
|
|
); |
|
|
@ -204,10 +199,10 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
|
|
|
|
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, |
|
|
|
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
|
|
|
|
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, |
|
|
|
`user`.`page-flags`, `user`.`prvnets` |
|
|
|
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` |
|
|
|
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` |
|
|
|
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
|
|
|
intval($uid) |
|
|
|
); |
|
|
@ -306,9 +301,9 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if((strlen($parent['allow_cid'])) |
|
|
|
|| (strlen($parent['allow_gid'])) |
|
|
|
|| (strlen($parent['deny_cid'])) |
|
|
|
if((strlen($parent['allow_cid'])) |
|
|
|
|| (strlen($parent['allow_gid'])) |
|
|
|
|| (strlen($parent['deny_cid'])) |
|
|
|
|| (strlen($parent['deny_gid']))) { |
|
|
|
$public_message = false; // private recipients, not public
|
|
|
|
} |
|
|
@ -410,8 +405,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
'$content' => xmlify($body), |
|
|
|
'$parent_id' => xmlify($item['parent-uri']) |
|
|
|
)); |
|
|
|
} |
|
|
|
elseif($fsuggest) { |
|
|
|
} elseif($fsuggest) { |
|
|
|
$public_message = false; // suggestions are not public
|
|
|
|
|
|
|
|
$sugg_template = get_markup_template('atom_suggest.tpl'); |
|
|
@ -430,9 +424,8 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
intval($item['id']) |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
elseif($relocate) { |
|
|
|
$public_message = false; // suggestions are not public
|
|
|
|
} elseif($relocate) { |
|
|
|
$public_message = false; // suggestions are not public
|
|
|
|
|
|
|
|
$sugg_template = get_markup_template('atom_relocate.tpl'); |
|
|
|
|
|
|
@ -444,8 +437,8 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
set_config('system','site_pubkey', $res['pubkey']); |
|
|
|
} |
|
|
|
|
|
|
|
$rp = q("SELECT `resource-id` , `scale`, type FROM `photo`
|
|
|
|
WHERE `profile` = 1 AND `uid` = %d ORDER BY scale;", $uid);
|
|
|
|
$rp = q("SELECT `resource-id` , `scale`, type FROM `photo`
|
|
|
|
WHERE `profile` = 1 AND `uid` = %d ORDER BY scale;", $uid);
|
|
|
|
$photos = array(); |
|
|
|
$ext = Photo::supportedTypes(); |
|
|
|
foreach($rp as $p){ |
|
|
@ -453,24 +446,23 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
} |
|
|
|
unset($rp, $ext); |
|
|
|
|
|
|
|
$atom .= replace_macros($sugg_template, array( |
|
|
|
'$name' => xmlify($owner['name']), |
|
|
|
'$photo' => xmlify($photos[4]), |
|
|
|
'$thumb' => xmlify($photos[5]), |
|
|
|
'$micro' => xmlify($photos[6]), |
|
|
|
'$url' => xmlify($owner['url']), |
|
|
|
'$request' => xmlify($owner['request']), |
|
|
|
'$confirm' => xmlify($owner['confirm']), |
|
|
|
'$notify' => xmlify($owner['notify']), |
|
|
|
'$poll' => xmlify($owner['poll']), |
|
|
|
'$sitepubkey' => xmlify(get_config('system','site_pubkey')), |
|
|
|
//'$pubkey' => xmlify($owner['pubkey']),
|
|
|
|
//'$prvkey' => xmlify($owner['prvkey']),
|
|
|
|
)); |
|
|
|
$recipients_relocate = q("SELECT * FROM contact WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN); |
|
|
|
$atom .= replace_macros($sugg_template, array( |
|
|
|
'$name' => xmlify($owner['name']), |
|
|
|
'$photo' => xmlify($photos[4]), |
|
|
|
'$thumb' => xmlify($photos[5]), |
|
|
|
'$micro' => xmlify($photos[6]), |
|
|
|
'$url' => xmlify($owner['url']), |
|
|
|
'$request' => xmlify($owner['request']), |
|
|
|
'$confirm' => xmlify($owner['confirm']), |
|
|
|
'$notify' => xmlify($owner['notify']), |
|
|
|
'$poll' => xmlify($owner['poll']), |
|
|
|
'$sitepubkey' => xmlify(get_config('system','site_pubkey')), |
|
|
|
//'$pubkey' => xmlify($owner['pubkey']),
|
|
|
|
//'$prvkey' => xmlify($owner['prvkey']),
|
|
|
|
)); |
|
|
|
$recipients_relocate = q("SELECT * FROM contact WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN); |
|
|
|
unset($photos); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
if($followup) { |
|
|
|
foreach($items as $item) { // there is only one item
|
|
|
|
if(! $item['parent']) |
|
|
@ -481,8 +473,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
$atom .= atom_entry($item,'text',null,$owner,false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
foreach($items as $item) { |
|
|
|
|
|
|
|
if(! $item['parent']) |
|
|
@ -510,7 +501,7 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
else |
|
|
|
$atom .= atom_entry($item,'text',null,$owner,true); |
|
|
|
|
|
|
|
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire)) |
|
|
|
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire)) |
|
|
|
$slaps[] = atom_entry($item,'html',null,$owner,true); |
|
|
|
} |
|
|
|
} |
|
|
@ -545,12 +536,12 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
else |
|
|
|
$recip_str = implode(', ', $recipients); |
|
|
|
|
|
|
|
if ($relocate) |
|
|
|
$r = $recipients_relocate; |
|
|
|
else |
|
|
|
$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ", |
|
|
|
dbesc($recip_str) |
|
|
|
); |
|
|
|
if ($relocate) |
|
|
|
$r = $recipients_relocate; |
|
|
|
else |
|
|
|
$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ", |
|
|
|
dbesc($recip_str) |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
require_once('include/salmon.php'); |
|
|
@ -700,13 +691,33 @@ function notifier_run(&$argv, &$argc){ |
|
|
|
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); |
|
|
|
$ostatus_contact = $contact; |
|
|
|
|
|
|
|
// If the contact doesn't fit with the contact, then fetch the correct contact
|
|
|
|
// This is more a test than a good solution. The whole OStatus stuff needs a rework.
|
|
|
|
if ($followup) { |
|
|
|
$thrparent = q("SELECT `author-link` FROM `item` WHERE `uri` = '%s'", dbesc($target_item["thr-parent"])); |
|
|
|
if (count($thrparent) AND (normalise_link($contact["url"]) != normalise_link($thrparent[0]["author-link"]))) { |
|
|
|
require_once("include/Scrape.php"); |
|
|
|
$probed_contact = probe_url($thrparent[0]["author-link"]); |
|
|
|
if ($probed_contact["network"] != NETWORK_FEED) { |
|
|
|
$ostatus_contact = $probed_contact; |
|
|
|
$ostatus_contact["nurl"] = normalise_link($probed_contact["url"]); |
|
|
|
$ostatus_contact["thumb"] = $probed_contact["photo"]; |
|
|
|
$ostatus_contact["micro"] = $probed_contact["photo"]; |
|
|
|
} |
|
|
|
logger('scrape data for slapper: '.print_r($ostatus_contact, true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if($followup && $ostatus_contact['notify']) { |
|
|
|
|
|
|
|
logger('notifier: slapdelivery: ' . $ostatus_contact['name']); |
|
|
|
$deliver_status = slapper($owner,$ostatus_contact['notify'],$slap); |
|
|
|
|
|
|
|
if($deliver_status == (-1)) { |
|
|
|
// queue message for redelivery
|
|
|
|
add_to_queue($contact['id'],NETWORK_OSTATUS,$slap); |
|
|
|
add_to_queue($ostatus_contact['id'],NETWORK_OSTATUS,$slap); |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|