Update StatusService, add getMastodon method for mastoapi compatibility

This commit is contained in:
Daniel Supernault 2022-01-02 23:47:08 -07:00
parent 772352903b
commit 36a129fe89
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -6,7 +6,6 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use DB; use DB;
use App\Status; use App\Status;
//use App\Transformer\Api\v3\StatusTransformer;
use App\Transformer\Api\StatusStatelessTransformer; use App\Transformer\Api\StatusStatelessTransformer;
use App\Transformer\Api\StatusTransformer; use App\Transformer\Api\StatusTransformer;
use League\Fractal; use League\Fractal;
@ -41,6 +40,49 @@ class StatusService
}); });
} }
public static function getMastodon($id, $publicOnly = true)
{
$status = self::get($id, $publicOnly);
if(!$status) {
return null;
}
$status['replies_count'] = $status['reply_count'];
unset(
$status['_v'],
$status['comments_disabled'],
$status['content_text'],
$status['gid'],
$status['label'],
$status['liked_by'],
$status['local'],
$status['parent'],
$status['pf_type'],
$status['place'],
$status['replies'],
$status['reply_count'],
$status['shortcode'],
$status['taggedPeople'],
$status['thread'],
$status['account']['header_bg'],
$status['account']['is_admin'],
$status['account']['last_fetched_at'],
$status['account']['local'],
$status['account']['location'],
$status['account']['note_text'],
$status['account']['pronouns'],
$status['account']['website'],
);
$status['account']['avatar_static'] = $status['account']['avatar'];
$status['account']['bot'] = false;
$status['account']['emojis'] = [];
$status['account']['fields'] = [];
$status['account']['header'] = url('/storage/headers/missing.png');
$status['account']['header_static'] = url('/storage/headers/missing.png');
$status['account']['last_status_at'] = null;
return $status;
}
public static function getState($id, $pid) public static function getState($id, $pid)
{ {
$status = self::get($id, false); $status = self::get($id, false);