mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-10 09:04:26 +02:00
Correct value of Mastodon API Account acct field for local users
This commit is contained in:
parent
bef16702c7
commit
c286772fb5
3 changed files with 26 additions and 11 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Friendica\Api\Mastodon;
|
||||
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -62,17 +63,21 @@ class Account
|
|||
/**
|
||||
* Creates an account record from a public contact record. Expects all contact table fields to be set.
|
||||
*
|
||||
* @param array $publicContact Full contact table record with uid = 0
|
||||
* @param array $apcontact Optional full apcontact table record
|
||||
* @param BaseURL $baseUrl
|
||||
* @param array $publicContact Full contact table record with uid = 0
|
||||
* @param array $apcontact Optional full apcontact table record
|
||||
* @return Account
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function create(array $publicContact, array $apcontact = [])
|
||||
public static function create(BaseURL $baseUrl, array $publicContact, array $apcontact = [])
|
||||
{
|
||||
$account = new Account();
|
||||
$account->id = $publicContact['id'];
|
||||
$account->username = $publicContact['nick'];
|
||||
$account->acct = $publicContact['addr'];
|
||||
$account->acct =
|
||||
strpos($publicContact['url'], $baseUrl->get() . '/') === 0 ?
|
||||
$publicContact['nick'] :
|
||||
$publicContact['addr'];
|
||||
$account->display_name = $publicContact['name'];
|
||||
$account->locked = !empty($apcontact['manually-approve']);
|
||||
$account->created_at = DateTimeFormat::utc($publicContact['created'], DateTimeFormat::ATOM);
|
||||
|
|
|
@ -79,7 +79,7 @@ class Instance
|
|||
if (!empty($administrator)) {
|
||||
$adminContact = DBA::selectFirst('contact', [], ['nick' => $administrator['nickname'], 'self' => true]);
|
||||
$apcontact = APContact::getByURL($adminContact['url'], false);
|
||||
$instance->contact_account = Account::create($adminContact, $apcontact);
|
||||
$instance->contact_account = Account::create($baseUrl, $adminContact, $apcontact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue