+ }
+ }
+
+ /**
+ * @brief Stores the signature for likes that are created on our system
+ *
+ * @param array $contact The contact array of the "like"
+ * @param int $post_id The post id of the "like"
+ *
+ * @return bool Success
+ */
+ public static function store_like_signature($contact, $post_id) {
+
+ // Is the contact the owner? Then fetch the private key
+ if (!$contact['self'] OR ($contact['uid'] == 0)) {
+ logger("No owner post, so not storing signature", LOGGER_DEBUG);
+ return false;
+ }
+
+ $r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
+ if(!$r)
+ return false;
+
+ $contact["uprvkey"] = $r[0]['prvkey'];
+
+ $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
+ if (!$r)
+ return false;
+
+ if (!in_array($r[0]["verb"], array(ACTIVITY_LIKE, ACTIVITY_DISLIKE)))
+ return false;
+
+ $message = self::construct_like($r[0], $contact);
+ $message["author_signature"] = self::signature($contact, $message);
+
+ // We now store the signature more flexible to dynamically support new fields.
+ // This will break Diaspora compatibility with Friendica versions prior to 3.5.
+ q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
+ intval($message_id),
+ dbesc(json_encode($message))
+ );
+
+ logger('Stored diaspora like signature');
+ return true;
+ }
+
+ /**
+ * @brief Stores the signature for comments that are created on our system
+ *
+ * @param array $item The item array of the comment
+ * @param array $contact The contact array of the item owner
+ * @param string $uprvkey The private key of the sender
+ * @param int $message_id The message id of the comment
+ *
+ * @return bool Success
+ */
+ public static function store_comment_signature($item, $contact, $uprvkey, $message_id) {
+
+ if ($uprvkey == "") {
+ logger('No private key, so not storing comment signature', LOGGER_DEBUG);
+ return false;
+ }
+
+ $contact["uprvkey"] = $uprvkey;
+
+ $message = self::construct_comment($item, $contact);
+ $message["author_signature"] = self::signature($contact, $message);
+
+ // We now store the signature more flexible to dynamically support new fields.
+ // This will break Diaspora compatibility with Friendica versions prior to 3.5.
+ q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
+ intval($message_id),
+ dbesc(json_encode($message))
+ );
+
+ logger('Stored diaspora comment signature');
+ return true;