Only track was watched if more than 10s is played #6

This commit is contained in:
2026-07-19 16:10:24 +02:00
parent 859a35847a
commit 4f81164b44
4 changed files with 65 additions and 14 deletions
-14
View File
@@ -8,10 +8,8 @@ use App\Models\Gallery;
use App\Models\Hentai;
use App\Models\Playlist;
use App\Models\PlaylistEpisode;
use App\Models\Watched;
use hisorange\BrowserDetect\Facade as Browser;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
@@ -52,18 +50,6 @@ class StreamController extends Controller
// Increment Popular Count
$episode->incrementPopularCount();
if (! Auth::guest()) {
$user = Auth::user();
// Add to user watched list
$time = Carbon::now()->subHour(1);
$alreadyWatched = Watched::where('user_id', $user->id)->where('episode_id', $episode->id)->where('created_at', '>=', $time)->exists();
if (! $alreadyWatched) {
Watched::create(['user_id' => $user->id, 'episode_id' => $episode->id]);
cache()->forget('user'.$user->id.'watched'.$episode->id);
}
}
// Mobile Detection
$isMobile = Browser::isMobile();