define('FRIENDICA_CODENAME', 'The Tazmans Flax-lily');
define('FRIENDICA_VERSION', '2018.12-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
-define('DB_UPDATE_VERSION', 1286);
+define('DB_UPDATE_VERSION', 1287);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/**
"received": ["received"]
}
},
+ "diaspora-interaction": {
+ "comment": "Signed Diaspora Interaction",
+ "fields": {
+ "uri-id": {"type": "int unsigned", "not null": "1", "primary": "1", "relation": {"item-uri": "id"}, "comment": "Id of the item-uri table entry that contains the item uri"},
+ "interaction": {"type": "mediumtext", "comment": "The Diaspora interaction"}
+ },
+ "indexes": {
+ "PRIMARY": ["uri-id"]
+ }
+ },
"event": {
"comment": "Events",
"fields": {
-- ------------------------------------------
-- Friendica 2018.12-dev (The Tazmans Flax-lily)
--- DB_UPDATE_VERSION 1285
+-- DB_UPDATE_VERSION 1287
-- ------------------------------------------
INDEX `received` (`received`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Raw data and structure information for messages';
+--
+-- TABLE diaspora-interaction
+--
+CREATE TABLE IF NOT EXISTS `diaspora-interaction` (
+ `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
+ `interaction` mediumtext COMMENT 'The Diaspora interaction',
+ PRIMARY KEY(`uri-id`)
+) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Signed Diaspora Interaction';
+
--
-- TABLE event
--
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
`pid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
`executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Execution date',
+ `next_try` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Next retrial date',
+ `retrial` tinyint NOT NULL DEFAULT 0 COMMENT 'Retrial counter',
`done` boolean NOT NULL DEFAULT '0' COMMENT 'Marked 1 when the task was done - will be deleted later',
PRIMARY KEY(`id`),
INDEX `pid` (`pid`),
INDEX `parameter` (`parameter`(64)),
- INDEX `priority_created` (`priority`,`created`),
- INDEX `done_executed` (`done`,`executed`)
+ INDEX `priority_created_next_try` (`priority`,`created`,`next_try`),
+ INDEX `done_executed_next_try` (`done`,`executed`,`next_try`)
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Background tasks queue entries';
}
}
+ if (array_key_exists('signed_text', $row) && array_key_exists('interaction', $row) && !is_null($row['interaction'])) {
+ $row['signed_text'] = $row['interaction'];
+ }
+
if (array_key_exists('ignored', $row) && array_key_exists('internal-user-ignored', $row) && !is_null($row['internal-user-ignored'])) {
$row['ignored'] = $row['internal-user-ignored'];
}
unset($row['internal-iaid']);
unset($row['internal-icid']);
unset($row['internal-user-ignored']);
+ unset($row['interaction']);
return $row;
}
$fields['sign'] = ['signed_text', 'signature', 'signer'];
+ $fields['diaspora-interaction'] = ['interaction'];
+
return $fields;
}
$joins .= " LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`";
}
+ if (strpos($sql_commands, "`diaspora-interaction`.") !== false) {
+ $joins .= " LEFT JOIN `diaspora-interaction` ON `diaspora-interaction`.`uri-id` = `item`.`uri-id`";
+ }
+
if (strpos($sql_commands, "`item-activity`.") !== false) {
$joins .= " LEFT JOIN `item-activity` ON `item-activity`.`id` = `item`.`iaid`";
}
$selected[] = 'internal-user-ignored';
}
+ if (in_array('signed_text', $selected)) {
+ $selected[] = 'interaction';
+ }
+
$selection = [];
foreach ($fields as $table => $table_fields) {
foreach ($table_fields as $field => $select) {
$deny_gid = '';
if ($item['parent-uri'] === $item['uri']) {
- $diaspora_signed_text = '';
$parent_id = 0;
$parent_deleted = 0;
$allow_cid = $item['allow_cid'];
$item['wall'] = $parent['wall'];
$notify_type = 'comment-new';
- if (!$parent['origin']) {
- $diaspora_signed_text = '';
- }
-
/*
* If the parent is private, force privacy for the entire conversation
* This differs from the above settings as it subtly allows comments from
$parent_id = 0;
$item['parent-uri'] = $item['uri'];
$item['gravity'] = GRAVITY_PARENT;
- $diaspora_signed_text = '';
} else {
logger('item parent '.$item['parent-uri'].' for '.$item['uid'].' was not found - ignoring item');
return 0;
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
}
- DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
- 'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer]);
+ if (!empty($dsprsig->signed_text) && empty($dsprsig->signature) && empty($dsprsig->signer)) {
+ DBA::insert('diaspora-interaction', ['uri-id' => $item['uri-id'], 'interaction' => $dsprsig->signed_text], true);
+ } else {
+ // The other fields are used by very old Friendica servers, so we currently store them differently
+ DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
+ 'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer]);
+ }
}
if (!empty($diaspora_signed_text)) {
- // Formerly we stored the signed text, the signature and the author in different fields.
- // We now store the raw data so that we are more flexible.
- DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $diaspora_signed_text]);
+ DBA::insert('diaspora-interaction', ['uri-id' => $item['uri-id'], 'interaction' => $diaspora_signed_text], true);
}
$deleted = self::tagDeliver($item['uid'], $current_post);
*
* @return string The message
*/
- private static function messageFromSignature(array $item, array $signature)
+ private static function messageFromSignature(array $item)
{
// Split the signed text
- $signed_parts = explode(";", $signature['signed_text']);
+ $signed_parts = explode(";", $item['signed_text']);
if ($item["deleted"]) {
- $message = ["author" => $signature['signer'],
+ $message = ["author" => $item['signer'],
"target_guid" => $signed_parts[0],
"target_type" => $signed_parts[1]];
} elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
"parent_guid" => $signed_parts[3],
"parent_type" => $signed_parts[2],
"positive" => $signed_parts[0],
- "author_signature" => $signature['signature'],
+ "author_signature" => $item['signature'],
"parent_author_signature" => ""];
} else {
// Remove the comment guid
"guid" => $guid,
"parent_guid" => $parent_guid,
"text" => implode(";", $signed_parts),
- "author_signature" => $signature['signature'],
+ "author_signature" => $item['signature'],
"parent_author_signature" => ""];
}
return $message;
logger("Got relayable data ".$type." for item ".$item["guid"]." (".$item["id"].")", LOGGER_DEBUG);
- // fetch the original signature
- $fields = ['signed_text', 'signature', 'signer'];
- $signature = DBA::selectFirst('sign', $fields, ['iid' => $item["id"]]);
- if (!DBA::isResult($signature)) {
- logger("Couldn't fetch signatur for item ".$item["guid"]." (".$item["id"].")", LOGGER_DEBUG);
- return false;
- }
-
// Old way - is used by the internal Friendica functions
/// @todo Change all signatur storing functions to the new format
- if ($signature['signed_text'] && $signature['signature'] && $signature['signer']) {
- $message = self::messageFromSignature($item, $signature);
+ if ($item['signed_text'] && $item['signature'] && $item['signer']) {
+ $message = self::messageFromSignature($item);
} else {// New way
- $msg = json_decode($signature['signed_text'], true);
+ $msg = json_decode($item['signed_text'], true);
$message = [];
if (is_array($msg)) {
$message[$field] = $data;
}
} else {
- logger("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$signature['signed_text'], LOGGER_DEBUG);
+ logger("Signature text for item ".$item["guid"]." (".$item["id"].") couldn't be extracted: ".$item['signed_text'], LOGGER_DEBUG);
}
}