mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update StatusService
This commit is contained in:
parent
e12227aee1
commit
937cdfb7f9
1 changed files with 39 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue