]> git.mxchange.org Git - friendica.git/commitdiff
sort out notify x-domain
authorMike Macgirvin <mike@macgirvin.com>
Mon, 23 Aug 2010 03:57:20 +0000 (20:57 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Mon, 23 Aug 2010 03:57:20 +0000 (20:57 -0700)
database.sql
include/items.php
include/notifier.php
include/poller.php
mod/dfrn_notify.php
mod/item.php
mod/photos.php

index af1ec630f2ba5bafdf8f9d8789d2d3daf9b5419f..2541de76a3ed6f02e6ab6a1e1d7f9ed1a3bbe03b 100644 (file)
@@ -149,6 +149,7 @@ CREATE TABLE IF NOT EXISTS `item` (
   `parent-uri` char(255) CHARACTER SET ascii NOT NULL,
   `created` datetime NOT NULL,
   `edited` datetime NOT NULL,
+  `changed` datetime NOT NULL,
   `owner-name` char(255) NOT NULL,
   `owner-link` char(255) NOT NULL,
   `owner-avatar` char(255) NOT NULL,
index aeb89892ea7b0bd805d2d98c7ddaf2a1b5c375b0..f57f3a833b6aa98217bfe78e1e729b81abd0075b 100644 (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`
                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 `item`.`edited` > '%s'
+               AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
                $sql_extra
                ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300",
                intval($owner_id),
+               dbesc($check_date),
                dbesc($check_date)
        );
        if(! count($r))
@@ -209,6 +210,7 @@ function post_remote($a,$arr) {
        $arr['owner-avatar'] = notags(trim($arr['owner-avatar']));
        $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['changed'] = datetime_convert();
        $arr['title'] = notags(trim($arr['title']));
        $arr['location'] = notags(trim($arr['location']));
        $arr['body'] = escape_tags(trim($arr['body']));
index d00ef54f435e87a8b8cee31d0bb1f4c3b5bd23f3..fe1925c337268a05607c894385a145cd6e363783 100644 (file)
@@ -17,7 +17,7 @@
        if($argc < 3)
                exit;
 
-       $a->set_baseurl(get_config('system',url'));
+       $a->set_baseurl(get_config('system','url'));
 
        $baseurl = $argv[1];
        $a->set_baseurl($argv[1]);
@@ -34,6 +34,8 @@
                        break;
        }
 
+       if($debugging)
+               dbg(3);
 
        $recipients = array();
 
index fcd74fd69b17a83281e86c175a15dcb0f0b1560b..80b6f35129b27560ebf66bb557b2acdc8470e653 100644 (file)
@@ -191,18 +191,20 @@ echo "Length:" . strlen($xml) . "\r\n";
                                );
                                if(count($r)) {
                                        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` = ''
                                                        WHERE `parent-uri` = '%s'",
                                                        dbesc($when),
+                                                       dbesc(datetime_convert()),
                                                        dbesc($r[0]['uri'])
                                                );
                                        }
                                        else {
-                                               $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s',
+                                               $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
                                                        `body` = '', `title` = '' 
                                                        WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
                                                        dbesc($when),
+                                                       dbesc(datetime_convert()),
                                                        dbesc($uri),
                                                        intval($importer['uid'])
                                                );
@@ -233,13 +235,20 @@ echo "Length:" . strlen($xml) . "\r\n";
                                );
                                // FIXME update content if 'updated' changes
                                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']) {
-                                               $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']),
+                                                       dbesc(datetime_convert()),
                                                        dbesc($item_id),
                                                        intval($importer['uid'])
                                                );
+
+
                                        }
                                        continue;
                                }
@@ -260,10 +269,11 @@ echo "Length:" . strlen($xml) . "\r\n";
                                        intval($importer['uid'])
                                );
                                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']) {
-                                               $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']),
+                                                       dbesc(datetime_convert()),
                                                        dbesc($item_id),
                                                        intval($importer['uid'])
                                                );
index 2ac98af596d1b3f496e07871b1b6f9fa0eea1d66..089e508ad3feee2d4bf91e0706c71c6e6d85acbc 100644 (file)
@@ -68,7 +68,7 @@ function dfrn_notify_post(&$a) {
                $msg['uri'] = notags(unxmlify($base['id'][0]['data']));
                $msg['parent-uri'] = notags(unxmlify($base['in-reply-to'][0]['data']));
                $msg['created'] = datetime_convert(notags(unxmlify('UTC','UTC',$base['sentdate'][0]['data'])));
-
+               
                dbesc_array($msg);
 
                $r = q("INSERT INTO `mail` (`" . implode("`, `", array_keys($msg)) 
@@ -124,16 +124,18 @@ function dfrn_notify_post(&$a) {
                        );
                        if(count($r)) {
                                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'",
                                                dbesc($when),
+                                               dbesc(datetime_convert()),
                                                dbesc($r[0]['uri'])
                                        );
                                }
                                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",
                                                dbesc($when),
+                                               dbesc(datetime_convert()),
                                                dbesc($uri),
                                                intval($importer['importer_uid'])
                                        );
@@ -166,12 +168,14 @@ function dfrn_notify_post(&$a) {
                                        intval($importer['importer_uid'])
                                );
                                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($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($posted_id)
                                );
@@ -214,8 +218,9 @@ function dfrn_notify_post(&$a) {
                                if(count($r)) {
                                        $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
                                        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']),
+                                                       dbesc(datetime_convert()),
                                                        dbesc($item_id),
                                                        intval($importer['importer_uid'])
                                                );
@@ -272,8 +277,9 @@ function dfrn_notify_post(&$a) {
                        if(count($r)) {
                                $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
                                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']),
+                                               dbesc(datetime_convert()),
                                                dbesc($item_id),
                                                intval($importer['importer_uid'])
                                        );
index 5b81f13eeb55257daca551a0ee16699406475194..812216426b391be2b6d0106c6cc5a30e11744fcc 100644 (file)
@@ -143,8 +143,8 @@ function item_post(&$a) {
 
        $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, 
                `author-name`, `author-link`, `author-avatar`, `created`,
-               `edited`, `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' )",
+               `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', '%s' )",
                intval($profile_uid),
                dbesc($post_type),
                intval($contact_id),
@@ -154,8 +154,9 @@ function item_post(&$a) {
                dbesc($author['name']),
                dbesc($author['url']),
                dbesc($author['thumb']),
-               datetime_convert(),
-               datetime_convert(),
+               dbesc(datetime_convert()),
+               dbesc(datetime_convert()),
+               dbesc(datetime_convert()),
                dbesc($uri),
                dbesc($title),
                dbesc($body),
@@ -173,7 +174,8 @@ function item_post(&$a) {
                if($parent) {
 
                        // 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)
                        );
 
@@ -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",
                        intval($parent),
                        dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
+                       dbesc(datetime_convert()),
                        intval($post_id)
                );
                // photo comments turn the corresponding item visible to the profile wall
@@ -279,7 +282,8 @@ function item_content(&$a) {
 
                        // 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()),
                                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($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 ",
                                        dbesc(datetime_convert()),
+                                       dbesc(datetime_convert()),
                                        dbesc($item['parent-uri']),
                                        intval($item['uid'])
                                );
index bbc9c2df5c93dad6fd5f0e1587f618e491d8a9a8..0558f746a98e40d86136a8680277cfba016020bc 100644 (file)
@@ -117,7 +117,8 @@ function photos_post(&$a) {
                        );
                        if(count($r)) {
                                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']),
                                                intval($_SESSION['uid'])
                                        );
@@ -153,7 +154,9 @@ function photos_post(&$a) {
                                intval($_SESSION['uid'])
                        );
                        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']),
                                        intval($_SESSION['uid'])
                                );
@@ -219,8 +222,8 @@ function photos_post(&$a) {
 
                        $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`)
-                               VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
+                               `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', '%s' )",
                                intval($_SESSION['uid']),
                                dbesc('photo'),
                                dbesc($p[0]['resource-id']),                    
@@ -228,8 +231,9 @@ function photos_post(&$a) {
                                dbesc($contact_record['name']),
                                dbesc($contact_record['url']),
                                dbesc($contact_record['thumb']),
-                               datetime_convert(),
-                               datetime_convert(),
+                               dbesc(datetime_convert()),
+                               dbesc(datetime_convert()),
+                               dbesc(datetime_convert()),
                                dbesc($uri),
                                dbesc($uri),
                                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(datetime_convert()),
+                       dbesc(datetime_convert()),
                        intval($item_id),
                        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`,
-               `edited`, `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 )",
+               `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', '%s', %d )",
                intval($_SESSION['uid']),
                dbesc('photo'),
                dbesc($photo_hash),                     
@@ -395,8 +401,9 @@ function photos_post(&$a) {
                dbesc($contact_record['name']),
                dbesc($contact_record['url']),
                dbesc($contact_record['thumb']),
-               datetime_convert(),
-               datetime_convert(),
+               dbesc(datetime_convert()),
+               dbesc(datetime_convert()),
+               dbesc(datetime_convert()),
                dbesc($uri),
                dbesc($uri),
                dbesc($title),