From a26a2a0228e13acc0d227f94b352028a2c6b24a7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 5 Aug 2021 08:30:44 +0000 Subject: [PATCH] Make the system owner ready for Diaspora --- src/Model/User.php | 9 +++++++-- src/Module/Xrd.php | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Model/User.php b/src/Model/User.php index 94e41387b..55bbb8b84 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -157,8 +157,8 @@ class User $system['net-publish'] = false; // Ensure that the user contains data - $user = DBA::selectFirst('user', ['prvkey'], ['uid' => 0]); - if (empty($user['prvkey'])) { + $user = DBA::selectFirst('user', ['prvkey', 'guid'], ['uid' => 0]); + if (empty($user['prvkey']) || empty($user['guid'])) { $fields = [ 'username' => $system['name'], 'nickname' => $system['nick'], @@ -167,12 +167,17 @@ class User 'prvkey' => $system['prvkey'], 'spubkey' => $system['spubkey'], 'sprvkey' => $system['sprvkey'], + 'guid' => System::createUUID(), 'verified' => true, 'page-flags' => User::PAGE_FLAGS_SOAPBOX, 'account-type' => User::ACCOUNT_TYPE_RELAY, ]; DBA::update('user', $fields, ['uid' => 0]); + + $system['guid'] = $fields['guid']; + } else { + $system['guid'] = $user['guid']; } return $system; diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 7e380946f..d2813cc27 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -130,6 +130,25 @@ class Xrd extends BaseModule 'rel' => 'http://ostatus.org/schema/1.0/subscribe', '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: *');