Update StatusService

This commit is contained in:
Daniel Supernault 2021-12-21 21:40:10 -07:00
parent e12227aee1
commit 937cdfb7f9
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -41,6 +41,25 @@ class StatusService
});
}
public static function getState($id, $pid)
{
$status = self::get($id, false);
if(!$status) {
return [
'liked' => false,
'shared' => false,
'bookmarked' => false
];
}
return [
'liked' => LikeService::liked($pid, $id),
'shared' => self::isShared($id, $pid),
'bookmarked' => self::isBookmarked($id, $pid)
];
}
public static function getFull($id, $pid, $publicOnly = true)
{
$res = self::get($id, $publicOnly);
@ -89,4 +108,24 @@ class StatusService
self::get($id, false);
self::get($id, true);
}
public static function isShared($id, $pid = null)
{
return $pid ?
DB::table('statuses')
->where('reblog_of_id', $id)
->where('profile_id', $pid)
->exists() :
false;
}
public static function isBookmarked($id, $pid = null)
{
return $pid ?
DB::table('bookmarks')
->where('status_id', $id)
->where('profile_id', $pid)
->exists() :
false;
}
}