mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +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);
|
||||
}
|
||||
}
|
|
@ -3,22 +3,24 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use App\Observers\{
|
||||
AvatarObserver,
|
||||
NotificationObserver,
|
||||
ModLogObserver,
|
||||
ProfileObserver,
|
||||
StatusHashtagObserver,
|
||||
UserObserver,
|
||||
UserFilterObserver,
|
||||
AvatarObserver,
|
||||
LikeObserver,
|
||||
NotificationObserver,
|
||||
ModLogObserver,
|
||||
ProfileObserver,
|
||||
StatusHashtagObserver,
|
||||
UserObserver,
|
||||
UserFilterObserver,
|
||||
};
|
||||
use App\{
|
||||
Avatar,
|
||||
Notification,
|
||||
ModLog,
|
||||
Profile,
|
||||
StatusHashtag,
|
||||
User,
|
||||
UserFilter
|
||||
Avatar,
|
||||
Like,
|
||||
Notification,
|
||||
ModLog,
|
||||
Profile,
|
||||
StatusHashtag,
|
||||
User,
|
||||
UserFilter
|
||||
};
|
||||
use Auth, Horizon, URL;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
|
@ -28,54 +30,36 @@ use Illuminate\Pagination\Paginator;
|
|||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
URL::forceScheme('https');
|
||||
Schema::defaultStringLength(191);
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
Paginator::useBootstrap();
|
||||
|
||||
Avatar::observe(AvatarObserver::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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue