aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-07-18 23:23:18 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-07-18 23:23:18 -0700
commit9b0584e59338f0b75c6b8a9a1b5def33da5de5f6 (patch)
treee0d4e2f339f4960ff8b8bc20a3ac9d1badf0a055 /include
parent3c0c8a2dc1bdc196c2fb94da52c07c44c9690fd3 (diff)
downloadvolse-hubzilla-9b0584e59338f0b75c6b8a9a1b5def33da5de5f6.tar.gz
volse-hubzilla-9b0584e59338f0b75c6b8a9a1b5def33da5de5f6.tar.bz2
volse-hubzilla-9b0584e59338f0b75c6b8a9a1b5def33da5de5f6.zip
revamp of item structure
Diffstat (limited to 'include')
-rw-r--r--include/items.php69
-rw-r--r--include/notifier.php58
-rw-r--r--include/poller.php14
3 files changed, 63 insertions, 78 deletions
diff --git a/include/items.php b/include/items.php
index e6a78f9ec..d583ffecc 100644
--- a/include/items.php
+++ b/include/items.php
@@ -95,7 +95,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
foreach($items as $item) {
if($item['deleted']) {
$atom .= replace_macros($tomb_template, array(
- '$id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")),
+ '$id' => xmlify($item['uri']),
'$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
));
}
@@ -109,7 +109,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
'$owner_name' => xmlify($item['owner-name']),
'$owner_profile_page' => xmlify($item['owner-link']),
'$owner_thumb' => xmlify($item['owner-avatar']),
- '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")),
+ '$item_id' => xmlify($item['uri']),
'$title' => xmlify($item['name']),
'$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
'$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
@@ -122,14 +122,12 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
'$name' => xmlify($item['name']),
'$profile_page' => xmlify($item['url']),
'$thumb' => xmlify($item['thumb']),
- '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")),
+ '$item_id' => xmlify($item['uri']),
'$title' => xmlify($item['title']),
'$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
'$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
'$content' =>xmlify($item['body']),
-
- // ......this is wrong!!!!
- '$parent_id' => xmlify("urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$items[0]['hash']}"),
+ '$parent_id' => xmlify($item['parent-uri']),
'$comment_allow' => (($item['last-child']) ? 1 : 0)
));
}
@@ -149,10 +147,10 @@ function get_atom_elements($item) {
$res = array();
$author = $item->get_author();
- $res['remote-name'] = unxmlify($author->get_name());
- $res['remote-link'] = unxmlify($author->get_link());
- $res['remote-avatar'] = unxmlify($author->get_avatar());
- $res['remote-id'] = unxmlify($item->get_id());
+ $res['author-name'] = unxmlify($author->get_name());
+ $res['author-link'] = unxmlify($author->get_link());
+ $res['author-avatar'] = unxmlify($author->get_avatar());
+ $res['uri'] = unxmlify($item->get_id());
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
@@ -187,19 +185,16 @@ function get_atom_elements($item) {
function post_remote($a,$arr) {
- $arr['hash'] = random_string();
+
if(! x($arr,'type'))
$arr['type'] = 'remote';
- $arr['remote-name'] = notags(trim($arr['remote-name']));
- $arr['remote-link'] = notags(trim($arr['remote-link']));
- $arr['remote-avatar'] = notags(trim($arr['remote-avatar']));
+ $arr['uri'] = notags(trim($arr['uri']));
+ $arr['author-name'] = notags(trim($arr['author-name']));
+ $arr['author-link'] = notags(trim($arr['author-link']));
+ $arr['author-avatar'] = notags(trim($arr['author-avatar']));
$arr['owner-name'] = notags(trim($arr['owner-name']));
$arr['owner-link'] = notags(trim($arr['owner-link']));
$arr['owner-avatar'] = notags(trim($arr['owner-avatar']));
- if(! strlen($arr['remote-avatar']))
- $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg';
- if(! strlen($arr['owner-avatar']))
- $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg';
$arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s');
$arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s');
$arr['title'] = notags(trim($arr['title']));
@@ -207,18 +202,7 @@ function post_remote($a,$arr) {
$arr['last-child'] = intval($arr['last-child']);
$arr['visible'] = 1;
$arr['deleted'] = 0;
-
- $local_parent = false;
-
- if(isset($arr['parent_hash'])) {
- $local_parent = true;
- $parent = $arr['parent_hash'];
- unset($arr['parent_hash']);
- }
- else {
- $parent = $arr['parent_urn'];
- unset($arr['parent_urn']);
- }
+ $arr['parent-uri'] = notags(trim($arr['parent-uri']));
$parent_id = 0;
@@ -230,24 +214,19 @@ dbg(3);
. implode("', '", array_values($arr))
. "')" );
- if($local_parent) {
- $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($parent),
- intval($arr['uid'])
- );
- }
- else {
- $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($parent),
- intval($arr['uid'])
- );
- }
+ $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($arr['parent-uri']),
+ intval($arr['uid'])
+ );
+
if(count($r))
$parent_id = $r[0]['id'];
-
+ else {
+ // if parent is missing, what do we do?
+ }
- $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
- $arr['remote-id'],
+ $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $arr['uri'],
intval($arr['uid'])
);
if(count($r))
diff --git a/include/notifier.php b/include/notifier.php
index 68ff8a5c3..76694f4ae 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -12,11 +12,12 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
require_once("session.php");
require_once("datetime.php");
-dbg(3);
+
if($argc < 3)
exit;
- $baseurl = trim(hex2bin($argv[1]));
+ $baseurl = $argv[1]);
+ $a->set_baseurl($argv[1]);
$cmd = $argv[2];
@@ -65,7 +66,8 @@ if($argc < 3)
$parent = $items[0];
- if((strlen($parent['remote-id'])) && ($parent['type'] == 'remote')) {
+ if($parent['type'] == 'remote') {
+ // local followup to remote post
$followup = true;
$conversant_str = dbesc($parent['contact-id']);
}
@@ -94,7 +96,7 @@ if($argc < 3)
$conversant_str = dbesc(implode(', ',$conversants));
}
- $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) ");
+ $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 ");
if( ! count($r))
killme();
@@ -111,9 +113,10 @@ if($argc < 3)
$atom .= replace_macros($feed_template, array(
- '$feed_id' => xmlify($baseurl),
+ '$feed_id' => xmlify($a->get_baseurl()),
'$feed_title' => xmlify($owner['name']),
- '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+ '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC',
+ $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
'$name' => xmlify($owner['name']),
'$profile_page' => xmlify($owner['url']),
'$photo' => xmlify($owner['photo'])
@@ -126,12 +129,14 @@ if($argc < 3)
'$name' => xmlify($owner['name']),
'$profile_page' => xmlify($owner['url']),
'$thumb' => xmlify($owner['thumb']),
- '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"),
+ '$item_id' => xmlify($item['uri']),
'$title' => xmlify($item['title']),
- '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
- '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+ '$published' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+ '$updated' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
'$content' =>xmlify($item['body']),
- '$parent_id' => xmlify("{$items[0]['remote-id']}"),
+ '$parent_id' => xmlify($item['parent-uri']),
'$comment_allow' => 0
));
}
@@ -141,8 +146,9 @@ if($argc < 3)
foreach($items as $item) {
if($item['deleted']) {
$atom .= replace_macros($tomb_template, array(
- '$id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"),
- '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
+ '$id' => xmlify($item['uri']),
+ '$updated' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
));
}
else {
@@ -156,12 +162,14 @@ if($argc < 3)
'$owner_name' => xmlify($item['owner-name']),
'$owner_profile_page' => xmlify($item['owner-link']),
'$owner_thumb' => xmlify($item['owner-avatar']),
- '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")),
+ '$item_id' => xmlify($item['uri']),
'$title' => xmlify($contact['name']),
- '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
- '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+ '$published' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+ '$updated' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
'$content' =>xmlify($item['body']),
- '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'] && (! $contact['blocked']))) ? 1 : 0)
+ '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0)
));
}
else {
@@ -169,12 +177,14 @@ if($argc < 3)
'$name' => xmlify($contact['name']),
'$profile_page' => xmlify($contact['url']),
'$thumb' => xmlify($contact['thumb']),
- '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")),
+ '$item_id' => xmlify($item['uri']),
'$title' => xmlify($item['title']),
- '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
- '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+ '$published' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+ '$updated' => xmlify(datetime_convert('UTC', 'UTC',
+ $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
'$content' =>xmlify($item['body']),
- '$parent_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$items[0]['hash']}"),
+ '$parent_id' => xmlify($item['parent-uri']),
'$comment_allow' => (($item['last-child']) ? 1 : 0)
));
}
@@ -187,7 +197,7 @@ if($argc < 3)
// create a clone of this feed but with comments disabled to send to those who can't respond.
- $atom_nowrite = str_replace('<dfrn:comment-allow>1</dfrn:comment-allow>','<dfrn:comment-allow>0</dfrn:comment-allow>',$atom);
+ $atom_nowrite = str_replace('<dfrn:comment-allow>1','<dfrn:comment-allow>0',$atom);
if($followup)
@@ -206,7 +216,6 @@ if($argc < 3)
foreach($r as $rr) {
-echo "In delivery loop:";
if($rr['self'])
continue;
@@ -235,11 +244,8 @@ echo "In delivery loop:";
$postvars['data'] = $atom;
else
$postvars['data'] = $atom_nowrite;
-echo "URL:" . $url;
-echo "POSTVARS:" . print_r($postvars);
- $xml = post_url($url,$postvars);
-echo "XML response:" . $xml;
+ $xml = post_url($rr['notify'],$postvars);
}
diff --git a/include/poller.php b/include/poller.php
index 8c3110746..08028cdee 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -89,7 +89,7 @@ echo "Length:" . strlen($xml) . "\r\n";
$rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to');
if(isset($rawthread[0]['attribs']['']['ref'])) {
$is_reply = true;
- $parent_urn = $rawthread[0]['attribs']['']['ref'];
+ $parent_uri = $rawthread[0]['attribs']['']['ref'];
}
@@ -99,7 +99,7 @@ echo "Length:" . strlen($xml) . "\r\n";
$item_id = $item->get_id();
- $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id),
intval($importer['uid'])
);
@@ -107,7 +107,7 @@ echo "Length:" . strlen($xml) . "\r\n";
if(count($r)) {
$allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow');
if($allow && $allow[0]['data'] != $r[0]['last-child']) {
- $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
intval($allow[0]['data']),
dbesc($item_id),
intval($importer['uid'])
@@ -116,7 +116,7 @@ echo "Length:" . strlen($xml) . "\r\n";
continue;
}
$datarray = get_atom_elements($item);
- $datarray['parent_urn'] = $parent_urn;
+ $datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $importer['id'];
$r = post_remote($a,$datarray);
@@ -127,14 +127,14 @@ echo "Length:" . strlen($xml) . "\r\n";
// Head post of a conversation. Have we seen it? If not, import it.
$item_id = $item->get_id();
- $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id),
intval($importer['uid'])
);
if(count($r)) {
$allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow');
if($allow && $allow[0]['data'] != $r[0]['last-child']) {
- $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
intval($allow[0]['data']),
dbesc($item_id),
intval($importer['uid'])
@@ -144,7 +144,7 @@ echo "Length:" . strlen($xml) . "\r\n";
}
$datarray = get_atom_elements($item);
- $datarray['parent_urn'] = $item_id;
+ $datarray['parent-uri'] = $item_id;
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $importer['id'];
$r = post_remote($a,$datarray);