Merge pull request #1879 from annando/1509-fixing-ostatus
Improvements to OStatus subscriptions
This commit is contained in:
commit
c67fbc89c4
8 changed files with 198 additions and 15 deletions
|
@ -170,6 +170,11 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
dbesc($ret['network'])
|
||||
);
|
||||
|
||||
if(!count($r))
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc(normalise_link($url)), dbesc($ret['network'])
|
||||
);
|
||||
|
||||
if(count($r)) {
|
||||
// update contact
|
||||
if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
|
||||
|
@ -180,7 +185,6 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
intval($uid)
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
@ -285,7 +289,7 @@ function new_contact($uid,$url,$interactive = false) {
|
|||
|
||||
// pull feed and consume it, which should subscribe to the hub.
|
||||
|
||||
proc_run('php',"include/poller.php","$contact_id");
|
||||
proc_run('php',"include/onepoll.php","$contact_id", "force");
|
||||
|
||||
// create a follow slap
|
||||
|
||||
|
|
|
@ -4300,7 +4300,7 @@ function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
|
|||
|
||||
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
|
||||
|
||||
if(! strlen($contact['hub-verify'])) {
|
||||
if(!strlen($contact['hub-verify']) OR ($contact['hub-verify'] != $verify_token)) {
|
||||
$r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d",
|
||||
dbesc($verify_token),
|
||||
intval($contact['id'])
|
||||
|
|
|
@ -295,7 +295,7 @@ function notifier_run(&$argv, &$argc){
|
|||
$relay_to_owner = false;
|
||||
|
||||
if($relay_to_owner) {
|
||||
logger('notifier: followup', LOGGER_DEBUG);
|
||||
logger('notifier: followup '.$target_item["guid"], LOGGER_DEBUG);
|
||||
// local followup to remote post
|
||||
$followup = true;
|
||||
$public_message = false; // not public
|
||||
|
@ -331,6 +331,8 @@ function notifier_run(&$argv, &$argc){
|
|||
} else {
|
||||
$followup = false;
|
||||
|
||||
logger('Distributing directly '.$target_item["guid"], LOGGER_DEBUG);
|
||||
|
||||
// don't send deletions onward for other people's stuff
|
||||
|
||||
if($target_item['deleted'] && (! intval($target_item['wall']))) {
|
||||
|
@ -378,7 +380,7 @@ function notifier_run(&$argv, &$argc){
|
|||
}
|
||||
|
||||
if (count($url_recipients))
|
||||
logger('notifier: url_recipients ' . print_r($url_recipients,true));
|
||||
logger('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true));
|
||||
|
||||
$conversants = array_unique($conversants);
|
||||
|
||||
|
@ -394,6 +396,8 @@ function notifier_run(&$argv, &$argc){
|
|||
// We have not only to look at the parent, since it could be a Friendica thread.
|
||||
if (($thr_parent AND ($thr_parent[0]['network'] == NETWORK_OSTATUS)) OR ($parent['network'] == NETWORK_OSTATUS)) {
|
||||
|
||||
logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
|
||||
|
||||
// Send a salmon notification to every person we mentioned in the post
|
||||
$arr = explode(',',$target_item['tag']);
|
||||
foreach($arr as $x) {
|
||||
|
@ -650,7 +654,7 @@ function notifier_run(&$argv, &$argc){
|
|||
if($contact['self'])
|
||||
continue;
|
||||
|
||||
logger("Deliver to ".$contact['url'], LOGGER_DEBUG);
|
||||
logger("Deliver ".$target_item["guid"]." to ".$contact['url'], LOGGER_DEBUG);
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -53,6 +53,9 @@ function onepoll_run(&$argv, &$argc){
|
|||
if(($argc > 1) && (intval($argv[1])))
|
||||
$contact_id = intval($argv[1]);
|
||||
|
||||
if(($argc > 2) && ($argv[2] == "force"))
|
||||
$force = true;
|
||||
|
||||
if(! $contact_id) {
|
||||
logger('onepoll: no contact');
|
||||
return;
|
||||
|
@ -595,8 +598,10 @@ function onepoll_run(&$argv, &$argc){
|
|||
return;
|
||||
}
|
||||
|
||||
consume_feed($xml,$importer,$contact,$hub,1,1);
|
||||
|
||||
logger("Consume feed of contact ".$contact['id']);
|
||||
|
||||
consume_feed($xml,$importer,$contact,$hub,1,1);
|
||||
|
||||
// do it twice. Ensures that children of parents which may be later in the stream aren't tossed
|
||||
|
||||
|
@ -609,6 +614,11 @@ function onepoll_run(&$argv, &$argc){
|
|||
if(($contact['network'] === NETWORK_OSTATUS || $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify']))
|
||||
$hub_update = true;
|
||||
|
||||
if ($force)
|
||||
$hub_update = true;
|
||||
|
||||
logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
|
||||
|
||||
if((strlen($hub)) && ($hub_update) && (($contact['rel'] != CONTACT_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED) ) {
|
||||
logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
|
||||
$hubs = explode(',', $hub);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue