Update AccountService, add getMastodon method for mastoapi compatibility

This commit is contained in:
Daniel Supernault 2022-01-03 00:53:15 -07:00
parent 6667f4f1d7
commit 85e4be8172
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 33 additions and 4 deletions

View file

@ -33,6 +33,35 @@ class AccountService
}); });
} }
public static function getMastodon($id, $softFail = false)
{
$account = self::get($id, $softFail);
if(!$account) {
return null;
}
unset(
$account['header_bg'],
$account['is_admin'],
$account['last_fetched_at'],
$account['local'],
$account['location'],
$account['note_text'],
$account['pronouns'],
$account['website']
);
$account['avatar_static'] = $account['avatar'];
$account['bot'] = false;
$account['emojis'] = [];
$account['fields'] = [];
$account['header'] = url('/storage/headers/missing.png');
$account['header_static'] = url('/storage/headers/missing.png');
$account['last_status_at'] = null;
return $account;
}
public static function del($id) public static function del($id)
{ {
return Cache::forget(self::CACHE_KEY . $id); return Cache::forget(self::CACHE_KEY . $id);

View file

@ -25,8 +25,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
'acct' => $acct, 'acct' => $acct,
'display_name' => $profile->name, 'display_name' => $profile->name,
'locked' => (bool) $profile->is_private, 'locked' => (bool) $profile->is_private,
'followers_count' => $profile->followerCount(), 'followers_count' => (int) $profile->followerCount(),
'following_count' => $profile->followingCount(), 'following_count' => (int) $profile->followingCount(),
'statuses_count' => (int) $profile->statusCount(), 'statuses_count' => (int) $profile->statusCount(),
'note' => $profile->bio ?? '', 'note' => $profile->bio ?? '',
'note_text' => strip_tags($profile->bio), 'note_text' => strip_tags($profile->bio),

View file

@ -24,8 +24,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
'url' => $profile->url(), 'url' => $profile->url(),
'avatar' => $profile->avatarUrl(), 'avatar' => $profile->avatarUrl(),
'avatar_static' => $profile->avatarUrl(), 'avatar_static' => $profile->avatarUrl(),
'header' => '', 'header' => url('/storage/headers/missing.png'),
'header_static' => '', 'header_static' => url('/storage/headers/missing.png'),
'followers_count' => (int) $profile->followerCount(), 'followers_count' => (int) $profile->followerCount(),
'following_count' => (int) $profile->followingCount(), 'following_count' => (int) $profile->followingCount(),
'statuses_count' => (int) $profile->statusCount(), 'statuses_count' => (int) $profile->statusCount(),