$expire = false;
$mail = false;
$fsuggest = false;
- $relocate = false;
+ $relocate = false;
$top_level = false;
$recipients = array();
$url_recipients = array();
$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)
);
$item_id = 0;
if(! count($items))
return;
- }
- elseif($cmd === 'suggest') {
+ } elseif($cmd === 'suggest') {
$normal_mode = false;
$fsuggest = true;
$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;
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)
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)
);
}
- $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)
);
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
}
'$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');
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');
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){
}
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'])
$atom .= atom_entry($item,'text',null,$owner,false);
}
}
- }
- else {
+ } else {
foreach($items as $item) {
if(! $item['parent'])
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);
}
}
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');
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 {
if($last) {
$next = $last + ($poll_interval * 60);
if($next > time()) {
- logger('complete_conversation: poll interval not reached');
+ logger('poll interval not reached');
return;
}
}
- logger('complete_conversation: cron_start');
+ logger('cron_start');
$start = date("Y-m-d H:i:s", time() - ($poll_timeframe * 60));
$conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'",
complete_conversation($id, $url);
}
- logger('complete_conversation: cron_end');
+ logger(' cron_end');
set_config('system','ostatus_last_poll', time());
}
$a->last_ostatus_conversation_url = $conversation_url;
- //logger('complete_conversation: completing conversation url '.$conversation_url.' for id '.$itemid);
-
$messages = q("SELECT `uid`, `parent`, `created` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
if (!$messages)
return;
do {
$conv_as = fetch_url($conv."?page=".$pageno);
- //$conv_as = fetch_url($conv."?page=".$pageno, false, 0, 10);
- //$conv_as = file_get_contents($conv."?page=".$pageno);
$conv_as = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
$conv_as = json_decode($conv_as);
$items = array_reverse($items);
foreach ($items as $single_conv) {
- // identi.ca just changed the format of the activity streams. This is a quick fix.
+ // status.net changed the format of the activity streams. This is a quick fix.
if (@is_string($single_conv->object->id))
$single_conv->id = $single_conv->object->id;
intval($message["uid"]), dbesc($first_id));
if ($new_parents) {
$parent = $new_parents[0];
- logger('complete_conversation: adopting new parent '.$parent["id"].' for '.$itemid);
+ logger('adopting new parent '.$parent["id"].' for '.$itemid);
} else {
$parent["id"] = 0;
$parent["uri"] = $first_id;
if ($message_exists) {
if ($parent["id"] != 0) {
$existing_message = $message_exists[0];
+
+ // This is partly bad, since the entry in the thread table isn't updated
$r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d",
intval($parent["id"]),
dbesc($parent["uri"]),
continue;
}
+ $contact = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
+ $message["uid"], normalise_link($single_conv->actor->id), NETWORK_STATUSNET);
+
+ if (count($contact)) {
+ logger("Found contact for url ".$single_conv->actor->id, LOGGER_DEBUG);
+ $contact_id = $contact[0]["id"];
+ } else {
+ logger("No contact found for url ".$single_conv->actor->id, LOGGER_DEBUG);
+ $contact_id = $parent["contact-id"];
+ }
+
$arr = array();
$arr["network"] = NETWORK_OSTATUS;
$arr["uri"] = $single_conv->id;
$arr["plink"] = $single_conv->id;
$arr["uid"] = $message["uid"];
- $arr["contact-id"] = $parent["contact-id"]; // To-Do
+ $arr["contact-id"] = $contact_id;
if ($parent["id"] != 0)
$arr["parent"] = $parent["id"];
$arr["parent-uri"] = $parent["uri"];
// If the newly created item is the top item then change the parent settings of the thread
if ($newitem AND ($arr["uri"] == $first_id)) {
- logger('complete_conversation: setting new parent to id '.$newitem);
+ logger('setting new parent to id '.$newitem);
$new_parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($message["uid"]), intval($newitem));
if ($new_parents) {
$parent = $new_parents[0];
- logger('complete_conversation: done changing parents to parent '.$newitem);
+ logger('done changing parents to parent '.$newitem);
}
-
- /*logger('complete_conversation: changing parents to parent '.$newitem.' old parent: '.$parent["id"].' new uri: '.$arr["uri"]);
- $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s' WHERE `parent` = %d",
- intval($newitem),
- dbesc($arr["uri"]),
- intval($parent["id"]));
- logger('complete_conversation: done changing parents to parent '.$newitem.' '.print_r($r, true));*/
}
}
}