sort out notify x-domain

This commit is contained in:
Mike Macgirvin 2010-08-22 20:57:20 -07:00
parent 024f2019e6
commit b02e30f1cf
7 changed files with 67 additions and 34 deletions

View file

@ -149,6 +149,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`parent-uri` char(255) CHARACTER SET ascii NOT NULL, `parent-uri` char(255) CHARACTER SET ascii NOT NULL,
`created` datetime NOT NULL, `created` datetime NOT NULL,
`edited` datetime NOT NULL, `edited` datetime NOT NULL,
`changed` datetime NOT NULL,
`owner-name` char(255) NOT NULL, `owner-name` char(255) NOT NULL,
`owner-link` char(255) NOT NULL, `owner-link` char(255) NOT NULL,
`owner-avatar` char(255) NOT NULL, `owner-avatar` char(255) NOT NULL,

View file

@ -67,10 +67,11 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 WHERE `item`.`uid` = %d AND `item`.`visible` = 1
AND NOT `item`.`type` IN ( 'remote', 'net-comment' ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND NOT `item`.`type` IN ( 'remote', 'net-comment' ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`edited` > '%s' AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
$sql_extra $sql_extra
ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300", ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300",
intval($owner_id), intval($owner_id),
dbesc($check_date),
dbesc($check_date) dbesc($check_date)
); );
if(! count($r)) if(! count($r))
@ -209,6 +210,7 @@ function post_remote($a,$arr) {
$arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); $arr['owner-avatar'] = notags(trim($arr['owner-avatar']));
$arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $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['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s');
$arr['changed'] = datetime_convert();
$arr['title'] = notags(trim($arr['title'])); $arr['title'] = notags(trim($arr['title']));
$arr['location'] = notags(trim($arr['location'])); $arr['location'] = notags(trim($arr['location']));
$arr['body'] = escape_tags(trim($arr['body'])); $arr['body'] = escape_tags(trim($arr['body']));

View file

@ -17,7 +17,7 @@
if($argc < 3) if($argc < 3)
exit; exit;
$a->set_baseurl(get_config('system',url')); $a->set_baseurl(get_config('system','url'));
$baseurl = $argv[1]; $baseurl = $argv[1];
$a->set_baseurl($argv[1]); $a->set_baseurl($argv[1]);
@ -34,6 +34,8 @@
break; break;
} }
if($debugging)
dbg(3);
$recipients = array(); $recipients = array();

View file

@ -191,18 +191,20 @@ echo "Length:" . strlen($xml) . "\r\n";
); );
if(count($r)) { if(count($r)) {
if($r[0]['uri'] == $r[0]['parent-uri']) { if($r[0]['uri'] == $r[0]['parent-uri']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = '' `body` = '', `title` = ''
WHERE `parent-uri` = '%s'", WHERE `parent-uri` = '%s'",
dbesc($when), dbesc($when),
dbesc(datetime_convert()),
dbesc($r[0]['uri']) dbesc($r[0]['uri'])
); );
} }
else { else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = '' `body` = '', `title` = ''
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($when), dbesc($when),
dbesc(datetime_convert()),
dbesc($uri), dbesc($uri),
intval($importer['uid']) intval($importer['uid'])
); );
@ -233,13 +235,20 @@ echo "Length:" . strlen($xml) . "\r\n";
); );
// FIXME update content if 'updated' changes // FIXME update content if 'updated' changes
if(count($r)) { if(count($r)) {
$allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
if($allow && $allow[0]['data'] != $r[0]['last-child']) { if($allow && $allow[0]['data'] != $r[0]['last-child']) {
$r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s'",
dbesc(datetime_convert()),
dbesc($parent_uri)
);
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
intval($allow[0]['data']), intval($allow[0]['data']),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
} }
continue; continue;
} }
@ -260,10 +269,11 @@ echo "Length:" . strlen($xml) . "\r\n";
intval($importer['uid']) intval($importer['uid'])
); );
if(count($r)) { if(count($r)) {
$allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
if($allow && $allow[0]['data'] != $r[0]['last-child']) { if($allow && $allow[0]['data'] != $r[0]['last-child']) {
$r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
intval($allow[0]['data']), intval($allow[0]['data']),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );

View file

@ -124,16 +124,18 @@ function dfrn_notify_post(&$a) {
); );
if(count($r)) { if(count($r)) {
if($r[0]['uri'] == $r[0]['parent-uri']) { if($r[0]['uri'] == $r[0]['parent-uri']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s' $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
WHERE `parent-uri` = '%s'", WHERE `parent-uri` = '%s'",
dbesc($when), dbesc($when),
dbesc(datetime_convert()),
dbesc($r[0]['uri']) dbesc($r[0]['uri'])
); );
} }
else { else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s' $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($when), dbesc($when),
dbesc(datetime_convert()),
dbesc($uri), dbesc($uri),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -166,12 +168,14 @@ function dfrn_notify_post(&$a) {
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if(count($r)) { if(count($r)) {
$r1 = q("UPDATE `item` SET `last-child` = 0 WHERE `uid` = %d AND `parent` = %d", $r1 = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `uid` = %d AND `parent` = %d",
dbesc(datetime_convert()),
intval($importer['importer_uid']), intval($importer['importer_uid']),
intval($r[0]['parent']) intval($r[0]['parent'])
); );
} }
$r2 = q("UPDATE `item` SET `last-child` = 1 WHERE `uid` = %d AND `id` = %d LIMIT 1", $r2 = q("UPDATE `item` SET `last-child` = 1, `changed` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(datetime_convert()),
intval($importer['importer_uid']), intval($importer['importer_uid']),
intval($posted_id) intval($posted_id)
); );
@ -214,8 +218,9 @@ function dfrn_notify_post(&$a) {
if(count($r)) { if(count($r)) {
$allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow'); $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
if($allow && $allow[0]['data'] != $r[0]['last-child']) { if($allow && $allow[0]['data'] != $r[0]['last-child']) {
$r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `last-child` = %d, `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
intval($allow[0]['data']), intval($allow[0]['data']),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -272,8 +277,9 @@ function dfrn_notify_post(&$a) {
if(count($r)) { if(count($r)) {
$allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow'); $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
if($allow && $allow[0]['data'] != $r[0]['last-child']) { if($allow && $allow[0]['data'] != $r[0]['last-child']) {
$r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `last-child` = %d, `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
intval($allow[0]['data']), intval($allow[0]['data']),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );

View file

@ -143,8 +143,8 @@ function item_post(&$a) {
$r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `author-name`, `author-link`, `author-avatar`, `created`,
`edited`, `uri`, `title`, `body`, `location`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) `edited`, `changed`, `uri`, `title`, `body`, `location`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($profile_uid), intval($profile_uid),
dbesc($post_type), dbesc($post_type),
intval($contact_id), intval($contact_id),
@ -154,8 +154,9 @@ function item_post(&$a) {
dbesc($author['name']), dbesc($author['name']),
dbesc($author['url']), dbesc($author['url']),
dbesc($author['thumb']), dbesc($author['thumb']),
datetime_convert(), dbesc(datetime_convert()),
datetime_convert(), dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($uri), dbesc($uri),
dbesc($title), dbesc($title),
dbesc($body), dbesc($body),
@ -173,7 +174,8 @@ function item_post(&$a) {
if($parent) { if($parent) {
// This item is the last leaf and gets the comment box, clear any ancestors // This item is the last leaf and gets the comment box, clear any ancestors
$r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent` = %d ", $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ",
dbesc(datetime_convert()),
intval($parent) intval($parent)
); );
@ -227,10 +229,11 @@ function item_post(&$a) {
} }
} }
$r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `last-child` = 1, `visible` = 1 $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1
WHERE `id` = %d LIMIT 1", WHERE `id` = %d LIMIT 1",
intval($parent), intval($parent),
dbesc(($parent == $post_id) ? $uri : $parent_item['uri']), dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
dbesc(datetime_convert()),
intval($post_id) intval($post_id)
); );
// photo comments turn the corresponding item visible to the profile wall // photo comments turn the corresponding item visible to the profile wall
@ -279,7 +282,8 @@ function item_content(&$a) {
// delete the item // delete the item
$r = q("UPDATE `item` SET `deleted` = 1, `body` = '', `edited` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `item` SET `deleted` = 1, `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($item['id']) intval($item['id'])
); );
@ -300,9 +304,10 @@ function item_content(&$a) {
// If it's the parent of a comment thread, kill all the kids // If it's the parent of a comment thread, kill all the kids
if($item['uri'] == $item['parent-uri']) { if($item['uri'] == $item['parent-uri']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `body` = '' $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = ''
WHERE `parent-uri` = '%s' AND `uid` = %d ", WHERE `parent-uri` = '%s' AND `uid` = %d ",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($item['parent-uri']), dbesc($item['parent-uri']),
intval($item['uid']) intval($item['uid'])
); );

View file

@ -117,7 +117,8 @@ function photos_post(&$a) {
); );
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
q("UPDATE `item` SET `deleted` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc($rr['parent-uri']), dbesc($rr['parent-uri']),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
@ -153,7 +154,9 @@ function photos_post(&$a) {
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
if(count($i)) { if(count($i)) {
q("UPDATE `item` SET `deleted` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($i[0]['uri']), dbesc($i[0]['uri']),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
@ -219,8 +222,8 @@ function photos_post(&$a) {
$r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`, $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,
`owner-name`,`owner-link`,`owner-avatar`, `created`, `owner-name`,`owner-link`,`owner-avatar`, `created`,
`edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) `edited`, `changed`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($_SESSION['uid']), intval($_SESSION['uid']),
dbesc('photo'), dbesc('photo'),
dbesc($p[0]['resource-id']), dbesc($p[0]['resource-id']),
@ -228,8 +231,9 @@ function photos_post(&$a) {
dbesc($contact_record['name']), dbesc($contact_record['name']),
dbesc($contact_record['url']), dbesc($contact_record['url']),
dbesc($contact_record['thumb']), dbesc($contact_record['thumb']),
datetime_convert(), dbesc(datetime_convert()),
datetime_convert(), dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($uri), dbesc($uri),
dbesc($uri), dbesc($uri),
dbesc($title), dbesc($title),
@ -254,8 +258,10 @@ function photos_post(&$a) {
} }
} }
$r = q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
dbesc($tags), dbesc($tags),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item_id), intval($item_id),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
@ -386,8 +392,8 @@ function photos_post(&$a) {
$r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`, $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,
`edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `visible`) `edited`, `changed`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `visible`)
VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )",
intval($_SESSION['uid']), intval($_SESSION['uid']),
dbesc('photo'), dbesc('photo'),
dbesc($photo_hash), dbesc($photo_hash),
@ -395,8 +401,9 @@ function photos_post(&$a) {
dbesc($contact_record['name']), dbesc($contact_record['name']),
dbesc($contact_record['url']), dbesc($contact_record['url']),
dbesc($contact_record['thumb']), dbesc($contact_record['thumb']),
datetime_convert(), dbesc(datetime_convert()),
datetime_convert(), dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($uri), dbesc($uri),
dbesc($uri), dbesc($uri),
dbesc($title), dbesc($title),