Bugfix Diaspora: We exited with the wrong return values and the guid for messages was too short

This commit is contained in:
Michael 2017-05-17 19:25:30 +00:00
parent 48e3f4f47f
commit 696404739b
5 changed files with 29 additions and 18 deletions

View file

@ -40,7 +40,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.2-rc' ); define ( 'FRIENDICA_VERSION', '3.5.2-rc' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1224 ); define ( 'DB_UPDATE_VERSION', 1225 );
/** /**
* @brief Constant with a HTML line break. * @brief Constant with a HTML line break.

View file

@ -808,7 +808,7 @@ function db_definition() {
$database["conv"] = array( $database["conv"] = array(
"fields" => array( "fields" => array(
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"recips" => array("type" => "text"), "recips" => array("type" => "text"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
"creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
@ -1205,7 +1205,7 @@ function db_definition() {
"fields" => array( "fields" => array(
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")), "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")),
"guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
"from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),

View file

@ -1395,7 +1395,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid); $message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) { if ($message_id) {
return $message_id; return true;
} }
$parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact); $parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact);
@ -1454,6 +1454,10 @@ class Diaspora {
$message_id = item_store($datarray); $message_id = item_store($datarray);
if ($message_id <= 0) {
return false;
}
if ($message_id) { if ($message_id) {
logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
} }
@ -1472,7 +1476,7 @@ class Diaspora {
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id); proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
} }
return $message_id; return true;
} }
/** /**
@ -1623,7 +1627,7 @@ class Diaspora {
} }
if (!$conversation) { if (!$conversation) {
logger("unable to create conversation."); logger("unable to create conversation.");
return; return false;
} }
foreach ($messages as $mesg) foreach ($messages as $mesg)
@ -1701,7 +1705,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid); $message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) if ($message_id)
return $message_id; return true;
$parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact); $parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact);
if (!$parent_item) if (!$parent_item)
@ -1754,8 +1758,13 @@ class Diaspora {
$message_id = item_store($datarray); $message_id = item_store($datarray);
if ($message_id) if ($message_id <= 0) {
return false;
}
if ($message_id) {
logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
}
// If we are the origin of the parent we store the original data and notify our followers // If we are the origin of the parent we store the original data and notify our followers
if ($message_id AND $parent_item["origin"]) { if ($message_id AND $parent_item["origin"]) {
@ -1771,7 +1780,7 @@ class Diaspora {
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id); proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
} }
return $message_id; return true;
} }
/** /**
@ -2348,7 +2357,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid); $message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) { if ($message_id) {
return $message_id; return true;
} }
$original_item = self::original_item($root_guid, $root_author, $author); $original_item = self::original_item($root_guid, $root_author, $author);
@ -2399,9 +2408,10 @@ class Diaspora {
if ($message_id) { if ($message_id) {
logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
return true;
} else {
return false;
} }
return $message_id;
} }
/** /**
@ -2532,7 +2542,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid); $message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) { if ($message_id) {
return $message_id; return true;
} }
$address = array(); $address = array();
@ -2616,9 +2626,10 @@ class Diaspora {
if ($message_id) { if ($message_id) {
logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
return true;
} else {
return false;
} }
return $message_id;
} }
/* ************************************************************************************** * /* ************************************************************************************** *

View file

@ -63,14 +63,14 @@ function receive_post(App $a) {
logger('mod-diaspora: dispatching', LOGGER_DEBUG); logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0; $ret = true;
if ($public) { if ($public) {
Diaspora::dispatch_public($msg); Diaspora::dispatch_public($msg);
} else { } else {
$ret = Diaspora::dispatch($importer, $msg); $ret = Diaspora::dispatch($importer, $msg);
} }
http_status_exit(($ret) ? $ret : 200); http_status_exit(($ret) ? 200 : 500);
// NOTREACHED // NOTREACHED
} }

View file

@ -1,6 +1,6 @@
<?php <?php
define('UPDATE_VERSION' , 1224); define('UPDATE_VERSION' , 1225);
/** /**
* *