Simplified signature creation
This commit is contained in:
parent
a26a2a0228
commit
835152d418
|
@ -1061,13 +1061,7 @@ class Item
|
||||||
|
|
||||||
// Create Diaspora signature
|
// Create Diaspora signature
|
||||||
if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) {
|
if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != GRAVITY_PARENT)) {
|
||||||
if ($uid == 0) {
|
$signed = Diaspora::createCommentSignature($item);
|
||||||
$sender_contact = Contact::getById($item['contact-id'], ['uid']);
|
|
||||||
$sender_uid = $sender_contact['uid'];
|
|
||||||
} else {
|
|
||||||
$sender_uid = $uid;
|
|
||||||
}
|
|
||||||
$signed = Diaspora::createCommentSignature($sender_uid, $item);
|
|
||||||
if (!empty($signed)) {
|
if (!empty($signed)) {
|
||||||
$item['diaspora_signed_text'] = json_encode($signed);
|
$item['diaspora_signed_text'] = json_encode($signed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4044,14 +4044,25 @@ class Diaspora
|
||||||
/**
|
/**
|
||||||
* Creates the signature for Comments that are created on our system
|
* Creates the signature for Comments that are created on our system
|
||||||
*
|
*
|
||||||
* @param integer $uid The user of that comment
|
|
||||||
* @param array $item Item array
|
* @param array $item Item array
|
||||||
*
|
*
|
||||||
* @return array Signed content
|
* @return array Signed content
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function createCommentSignature($uid, array $item)
|
public static function createCommentSignature(array $item)
|
||||||
{
|
{
|
||||||
|
$contact = Contact::getById($item['author-id'], ['url']);
|
||||||
|
if (empty($contact['url'])) {
|
||||||
|
Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$uid = User::getIdForURL($contact['url']);
|
||||||
|
if (empty($uid)) {
|
||||||
|
Logger::info('No owner post, so not storing signature', ['url' => $contact['url']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
if (empty($owner)) {
|
if (empty($owner)) {
|
||||||
Logger::info('No owner post, so not storing signature');
|
Logger::info('No owner post, so not storing signature');
|
||||||
|
|
Loading…
Reference in a new issue