mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Add LikeObserver
This commit is contained in:
parent
447e44e5ac
commit
d3157f2a2d
2 changed files with 111 additions and 63 deletions
64
app/Observers/LikeObserver.php
Normal file
64
app/Observers/LikeObserver.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Like;
|
||||
use App\Services\LikeService;
|
||||
|
||||
class LikeObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Like "created" event.
|
||||
*
|
||||
* @param \App\Models\Like $like
|
||||
* @return void
|
||||
*/
|
||||
public function created(Like $like)
|
||||
{
|
||||
LikeService::add($like->profile_id, $like->status_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Like "updated" event.
|
||||
*
|
||||
* @param \App\Models\Like $like
|
||||
* @return void
|
||||
*/
|
||||
public function updated(Like $like)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Like "deleted" event.
|
||||
*
|
||||
* @param \App\Models\Like $like
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(Like $like)
|
||||
{
|
||||
LikeService::remove($like->profile_id, $like->status_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Like "restored" event.
|
||||
*
|
||||
* @param \App\Models\Like $like
|
||||
* @return void
|
||||
*/
|
||||
public function restored(Like $like)
|
||||
{
|
||||
LikeService::add($like->profile_id, $like->status_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Like "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\Like $like
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(Like $like)
|
||||
{
|
||||
LikeService::remove($like->profile_id, $like->status_id);
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ namespace App\Providers;
|
|||
|
||||
use App\Observers\{
|
||||
AvatarObserver,
|
||||
LikeObserver,
|
||||
NotificationObserver,
|
||||
ModLogObserver,
|
||||
ProfileObserver,
|
||||
|
@ -13,6 +14,7 @@ use App\Observers\{
|
|||
};
|
||||
use App\{
|
||||
Avatar,
|
||||
Like,
|
||||
Notification,
|
||||
ModLog,
|
||||
Profile,
|
||||
|
@ -37,36 +39,18 @@ class AppServiceProvider extends ServiceProvider
|
|||
{
|
||||
URL::forceScheme('https');
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
Paginator::useBootstrap();
|
||||
|
||||
Avatar::observe(AvatarObserver::class);
|
||||
Like::observe(LikeObserver::class);
|
||||
Notification::observe(NotificationObserver::class);
|
||||
ModLog::observe(ModLogObserver::class);
|
||||
Profile::observe(ProfileObserver::class);
|
||||
StatusHashtag::observe(StatusHashtagObserver::class);
|
||||
User::observe(UserObserver::class);
|
||||
UserFilter::observe(UserFilterObserver::class);
|
||||
|
||||
Horizon::auth(function ($request) {
|
||||
return Auth::check() && $request->user()->is_admin;
|
||||
});
|
||||
|
||||
Blade::directive('prettyNumber', function ($expression) {
|
||||
$num = \App\Util\Lexer\PrettyNumber::convert($expression);
|
||||
return "<?php echo $num; ?>";
|
||||
});
|
||||
|
||||
Blade::directive('prettySize', function ($expression) {
|
||||
$size = \App\Util\Lexer\PrettyNumber::size($expression);
|
||||
return "<?php echo '$size'; ?>";
|
||||
});
|
||||
|
||||
Blade::directive('maxFileSize', function () {
|
||||
$value = config('pixelfed.max_photo_size');
|
||||
|
||||
return \App\Util\Lexer\PrettyNumber::size($value, true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue