}
if (!Crypto::rsaVerify($signed_data, $parent_author_signature, $key, 'sha256')) {
- Logger::info('No valid parent author signature for parent author ' . $msg['author'] . ' in type ' . $type . ' - signed data: ' . $signed_data . ' - Message: ' . $msg['message'] . ' - Signature ' . $parent_author_signature);
+ Logger::info('No valid parent author signature', ['author' => $msg['author'], 'type' => $type, 'signed data' => $signed_data, 'message' => $msg['message'], 'signature' => $parent_author_signature]);
return false;
}
}
}
if (!Crypto::rsaVerify($signed_data, $author_signature, $key, 'sha256')) {
- Logger::info('No valid author signature for author ' . $fields->author . ' in type ' . $type . ' - signed data: ' . $signed_data . ' - Message: ' . $msg['message'] . ' - Signature ' . $author_signature);
+ Logger::info('No valid author signature for author', ['author' => $fields->author, 'type' => $type, 'signed data' => $signed_data, 'message' => $msg['message'], 'signature' => $author_signature]);
return false;
} else {
return $fields;
Logger::info('Participation stored', ['id' => $message_id, 'guid' => $guid, 'parent_guid' => $parent_guid, 'author' => $author]);
// Send all existing comments and likes to the requesting server
- $comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb'],
+ $comments = Post::select(['id', 'uri-id', 'parent-author-network', 'author-network', 'verb', 'gravity'],
['parent' => $toplevel_parent_item['id'], 'gravity' => [GRAVITY_COMMENT, GRAVITY_ACTIVITY]]);
while ($comment = Post::fetch($comments)) {
- if (in_array($comment['verb'], [Activity::FOLLOW, Activity::TAG])) {
- Logger::info('participation messages are not relayed', ['item' => $comment['id']]);
+ if (($comment['gravity'] == GRAVITY_ACTIVITY) && !in_array($comment['verb'], [Activity::LIKE, Activity::DISLIKE])) {
+ Logger::info('Unsupported activities are not relayed', ['item' => $comment['id'], 'verb' => $comment['verb']]);
continue;
}
}
Logger::info('Deliver participation', ['item' => $comment['id'], 'contact' => $author_contact['cid']]);
- if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['id'], $author_contact['cid'])) {
+ if (Worker::add(PRIORITY_HIGH, 'Delivery', Delivery::POST, $comment['uri-id'], $author_contact['cid'], $datarray['uid'])) {
Post\DeliveryData::incrementQueueCount($comment['uri-id'], 1);
}
}
return false;
}
+ if (!self::parentSupportDiaspora($item['thr-parent-id'])) {
+ Logger::info('One of the parents does not support Diaspora. A signature will not be created.', ['uri-id' => $item['uri-id'], 'guid' => $item['guid']]);
+ return false;
+ }
+
$message = self::constructComment($item, $owner);
if ($message === false) {
return false;
return $message;
}
+ /**
+ * Check if the parent and their parents support Diaspora
+ *
+ * @param integer $parent_id
+ * @return boolean
+ */
+ private static function parentSupportDiaspora(int $parent_id): bool
+ {
+ $parent_post = Post::selectFirstPost(['gravity', 'signed_text', 'author-link', 'thr-parent-id'], ['uri-id' => $parent_id]);
+ if (empty($parent_post['thr-parent-id'])) {
+ Logger::warning('Parent post does not exist.', ['parent-id' => $parent_id]);
+ return false;
+ }
+
+ if (empty(FContact::getByURL($parent_post['author-link'], false))) {
+ Logger::info('Parent author is no Diaspora contact.', ['parent-id' => $parent_id]);
+ return false;
+ }
+
+ if (($parent_post['gravity'] == GRAVITY_COMMENT) && empty($parent_post['signed_text'])) {
+ Logger::info('Parent comment has got no Diaspora signature.', ['parent-id' => $parent_id]);
+ return false;
+ }
+
+ if ($parent_post['gravity'] == GRAVITY_COMMENT) {
+ return self::parentSupportDiaspora($parent_post['thr-parent-id']);
+ }
+
+ return true;
+ }
+
public static function performReshare(int $UriId, int $uid): int
{
$fields = ['uri-id', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];