working on long-term solution to relay issue

This commit is contained in:
Friendika 2011-10-15 03:26:37 -07:00
parent af6ab38100
commit 5dcc10a5d9
5 changed files with 27 additions and 16 deletions

View file

@ -8,9 +8,9 @@ require_once("include/pgettext.php");
require_once('include/nav.php'); require_once('include/nav.php');
define ( 'FRIENDIKA_PLATFORM', 'Free Friendika'); define ( 'FRIENDIKA_PLATFORM', 'Free Friendika');
define ( 'FRIENDIKA_VERSION', '2.3.1133' ); define ( 'FRIENDIKA_VERSION', '2.3.1134' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1096 ); define ( 'DB_UPDATE_VERSION', 1097 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View file

@ -214,6 +214,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`bookmark` tinyint(1) NOT NULL DEFAULT '0', `bookmark` tinyint(1) NOT NULL DEFAULT '0',
`unseen` tinyint(1) NOT NULL DEFAULT '1', `unseen` tinyint(1) NOT NULL DEFAULT '1',
`deleted` tinyint(1) NOT NULL DEFAULT '0', `deleted` tinyint(1) NOT NULL DEFAULT '0',
`origin` tinyint(1) NOT NULL DEFAULT '0',
`last-child` tinyint(1) unsigned NOT NULL DEFAULT '1', `last-child` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `guid` (`guid`), KEY `guid` (`guid`),
@ -231,6 +232,7 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `visible` (`visible`), KEY `visible` (`visible`),
KEY `starred` (`starred`), KEY `starred` (`starred`),
KEY `deleted` (`deleted`), KEY `deleted` (`deleted`),
KEY `origin` (`origin`),
KEY `last-child` (`last-child`), KEY `last-child` (`last-child`),
KEY `unseen` (`unseen`), KEY `unseen` (`unseen`),
FULLTEXT KEY `title` (`title`), FULLTEXT KEY `title` (`title`),

View file

@ -818,18 +818,10 @@ function item_store($arr,$force_parent = false) {
// find the item we just created // find the item we just created
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ",
$arr['uri'], // already dbesc'd $arr['uri'], // already dbesc'd
intval($arr['uid']) intval($arr['uid'])
); );
if(! count($r)) {
// This is not good, but perhaps we encountered a rare race/cache condition, so back off and try again.
sleep(3);
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1",
$arr['uri'], // already dbesc'd
intval($arr['uid'])
);
}
if(count($r)) { if(count($r)) {
$current_post = $r[0]['id']; $current_post = $r[0]['id'];
@ -1873,13 +1865,14 @@ function local_delivery($importer,$data) {
$r = q("select `item`.`id`, `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` $r = q("select `item`.`id`, `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", WHERE `contact`.`self` = 1 AND `item`.`wall` = 1 AND `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
AND `item`.`uid` = %d LIMIT 1",
dbesc($parent_uri),
dbesc($parent_uri), dbesc($parent_uri),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if($r && count($r)) { if($r && count($r)) {
logger('local_delivery: received remote comment'); logger('local_delivery: received remote comment');
$is_like = false; $is_like = false;
// remote reply to our post. Import and then notify everybody else. // remote reply to our post. Import and then notify everybody else.
@ -2388,6 +2381,9 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
$a = get_app(); $a = get_app();
if(! $item['parent'])
return;
if($item['deleted']) if($item['deleted'])
return '<at:deleted-entry ref="' . xmlify($item['uri']) . '" when="' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '" />' . "\r\n"; return '<at:deleted-entry ref="' . xmlify($item['uri']) . '" when="' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '" />' . "\r\n";

View file

@ -142,7 +142,7 @@ function notifier_run($argv, $argc){
$item['deleted'] = 1; $item['deleted'] = 1;
} }
if((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) { if((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
logger('notifier: top level post'); logger('notifier: top level post');
$top_level = true; $top_level = true;
} }
@ -205,13 +205,20 @@ function notifier_run($argv, $argc){
/** /**
* *
* Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes * Be VERY CAREFUL if you make any changes to the following lines. Seemingly innocuous changes
* have been known to cause runaway conditions which affected several servers, along with * have been known to cause runaway conditions which affected several servers, along with
* permissions issues. * permissions issues.
* *
*/ */
$relay_to_owner = false;
if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) { if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
$relay_to_owner = true;
}
if($relay_to_owner) {
logger('notifier: followup', LOGGER_DEBUG); logger('notifier: followup', LOGGER_DEBUG);
// local followup to remote post // local followup to remote post
$followup = true; $followup = true;

View file

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1096 ); define( 'UPDATE_VERSION' , 1097 );
/** /**
* *
@ -795,3 +795,9 @@ function update_1094() {
function update_1095() { function update_1095() {
q("ALTER TABLE `contact` ADD `bd` DATE NOT NULL AFTER `bdyear` "); q("ALTER TABLE `contact` ADD `bd` DATE NOT NULL AFTER `bdyear` ");
} }
function update_1096() {
q("ALTER TABLE `item` ADD `origin` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `deleted` , ADD INDEX ( `origin` ) ");
}