Merge pull request #10574 from annando/diaspora-signature
Create the Diaspora signature for the correct user
This commit is contained in:
commit
c31cb54e9f
|
@ -717,7 +717,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
|
||||||
$max_comments = DI::config()->get('system', 'max_display_comments', 1000);
|
$max_comments = DI::config()->get('system', 'max_display_comments', 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = ['order' => ['uri-id' => true]];
|
$params = ['order' => ['uri-id' => true, 'uid' => true]];
|
||||||
|
|
||||||
$activities = [];
|
$activities = [];
|
||||||
$uriids = [];
|
$uriids = [];
|
||||||
|
|
|
@ -1061,7 +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)) {
|
||||||
$signed = Diaspora::createCommentSignature($uid, $item);
|
$signed = Diaspora::createCommentSignature($item);
|
||||||
if (!empty($signed)) {
|
if (!empty($signed)) {
|
||||||
$item['diaspora_signed_text'] = json_encode($signed);
|
$item['diaspora_signed_text'] = json_encode($signed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,8 +157,8 @@ class User
|
||||||
$system['net-publish'] = false;
|
$system['net-publish'] = false;
|
||||||
|
|
||||||
// Ensure that the user contains data
|
// Ensure that the user contains data
|
||||||
$user = DBA::selectFirst('user', ['prvkey'], ['uid' => 0]);
|
$user = DBA::selectFirst('user', ['prvkey', 'guid'], ['uid' => 0]);
|
||||||
if (empty($user['prvkey'])) {
|
if (empty($user['prvkey']) || empty($user['guid'])) {
|
||||||
$fields = [
|
$fields = [
|
||||||
'username' => $system['name'],
|
'username' => $system['name'],
|
||||||
'nickname' => $system['nick'],
|
'nickname' => $system['nick'],
|
||||||
|
@ -167,12 +167,17 @@ class User
|
||||||
'prvkey' => $system['prvkey'],
|
'prvkey' => $system['prvkey'],
|
||||||
'spubkey' => $system['spubkey'],
|
'spubkey' => $system['spubkey'],
|
||||||
'sprvkey' => $system['sprvkey'],
|
'sprvkey' => $system['sprvkey'],
|
||||||
|
'guid' => System::createUUID(),
|
||||||
'verified' => true,
|
'verified' => true,
|
||||||
'page-flags' => User::PAGE_FLAGS_SOAPBOX,
|
'page-flags' => User::PAGE_FLAGS_SOAPBOX,
|
||||||
'account-type' => User::ACCOUNT_TYPE_RELAY,
|
'account-type' => User::ACCOUNT_TYPE_RELAY,
|
||||||
];
|
];
|
||||||
|
|
||||||
DBA::update('user', $fields, ['uid' => 0]);
|
DBA::update('user', $fields, ['uid' => 0]);
|
||||||
|
|
||||||
|
$system['guid'] = $fields['guid'];
|
||||||
|
} else {
|
||||||
|
$system['guid'] = $user['guid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $system;
|
return $system;
|
||||||
|
|
|
@ -130,6 +130,25 @@ class Xrd extends BaseModule
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
'template' => DI::baseUrl()->get() . '/follow?url={uri}',
|
'template' => DI::baseUrl()->get() . '/follow?url={uri}',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'rel' => ActivityNamespace::FEED,
|
||||||
|
'type' => 'application/atom+xml',
|
||||||
|
'href' => $owner['poll'] ?? DI::baseUrl()->get(),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'rel' => 'salmon',
|
||||||
|
'href' => DI::baseUrl()->get() . '/salmon/' . $owner['nickname'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'rel' => 'http://microformats.org/profile/hcard',
|
||||||
|
'type' => 'text/html',
|
||||||
|
'href' => DI::baseUrl()->get() . '/hcard/' . $owner['nickname'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'rel' => 'http://joindiaspora.com/seed_location',
|
||||||
|
'type' => 'text/html',
|
||||||
|
'href' => DI::baseUrl()->get(),
|
||||||
|
],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
header('Access-Control-Allow-Origin: *');
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
|
|
@ -1412,6 +1412,8 @@ class Probe
|
||||||
$data["guid"] = $link["href"];
|
$data["guid"] = $link["href"];
|
||||||
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (($link["type"] ?? "") == "text/html") && !empty($link["href"])) {
|
||||||
$data["url"] = $link["href"];
|
$data["url"] = $link["href"];
|
||||||
|
} elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && empty($link["type"]) && !empty($link["href"])) {
|
||||||
|
$profile_url = $link["href"];
|
||||||
} elseif (($link["rel"] == ActivityNamespace::FEED) && !empty($link["href"])) {
|
} elseif (($link["rel"] == ActivityNamespace::FEED) && !empty($link["href"])) {
|
||||||
$data["poll"] = $link["href"];
|
$data["poll"] = $link["href"];
|
||||||
} elseif (($link["rel"] == ActivityNamespace::POCO) && !empty($link["href"])) {
|
} elseif (($link["rel"] == ActivityNamespace::POCO) && !empty($link["href"])) {
|
||||||
|
@ -1428,6 +1430,10 @@ class Probe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($data["url"]) && !empty($profile_url)) {
|
||||||
|
$data["url"] = $profile_url;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($data["url"]) || empty($hcard_url)) {
|
if (empty($data["url"]) || empty($hcard_url)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4044,14 +4044,30 @@ 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)
|
||||||
{
|
{
|
||||||
|
if (!empty($item['author-link'])) {
|
||||||
|
$url = $item['author-link'];
|
||||||
|
} else {
|
||||||
|
$contact = Contact::getById($item['author-id'], ['url']);
|
||||||
|
if (empty($contact['url'])) {
|
||||||
|
Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$url = $contact['url'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$uid = User::getIdForURL($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