1
0
Fork 0

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)
{
return Cache::forget(self::CACHE_KEY . $id);

View File

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

View File

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