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