Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Http/Controllers/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public function destroy(Request $request, int $id): \Illuminate\Http\RedirectRes
'message' => [
'required',
'min:1',
'max:255',
],
]);

Expand Down Expand Up @@ -384,6 +385,9 @@ public function destroy(Request $request, int $id): \Illuminate\Http\RedirectRes

Unit3dAnnounce::removeTorrent($torrent);

$torrent->update([
'deletion_message' => $request->message,
]);
$torrent->delete();

return to_route('torrents.index')
Expand Down
20 changes: 20 additions & 0 deletions app/Http/Livewire/SimilarTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use App\Traits\CastLivewireProperties;
use App\Traits\LivewireSort;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Validator;
use Livewire\Attributes\Url;
use Livewire\Component;

Expand Down Expand Up @@ -449,6 +450,22 @@ final public function deleteRecords(): void
return;
}

$validator = Validator::make([
'reason' => $this->reason,
], [
'reason' => [
'required',
'min:1',
'max:255',
],
]);

if ($validator->fails()) {
$this->dispatch('error', type: 'error', message: $validator->messages()->get('reason'));

return;
}

$torrents = Torrent::whereKey($this->checked)->get();
$users = [];
$title = match (true) {
Expand Down Expand Up @@ -495,6 +512,9 @@ final public function deleteRecords(): void

Unit3dAnnounce::removeTorrent($torrent);

$torrent->update([
'deletion_message' => $this->reason,
]);
$torrent->delete();
}

Expand Down
1 change: 1 addition & 0 deletions app/Models/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $bumped_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property string|null $deletion_reason
* @property \Illuminate\Support\Carbon|null $fl_until
* @property \Illuminate\Support\Carbon|null $du_until
* @property int $type_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author Roardom <[email protected]>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('torrents', function (Blueprint $table): void {
$table->string('deletion_reason')->nullable()->after('deleted_at');
});
}
};
2 changes: 2 additions & 0 deletions database/schema/mysql-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,7 @@ CREATE TABLE `torrents` (
`updated_at` timestamp NULL DEFAULT NULL,
`bumped_at` datetime DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
`deletion_reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`fl_until` datetime DEFAULT NULL,
`du_until` datetime DEFAULT NULL,
`type_id` smallint unsigned DEFAULT NULL,
Expand Down Expand Up @@ -3039,3 +3040,4 @@ INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (361,'2025_09_02_14
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (362,'2025_09_07_235939_add_adult_content_setting_to_user_settings',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (363,'2025_09_07_235945_add_adult_column_to_tmdb_tv',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (364,'2025_09_08_000029_make_audits_morphable',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (365,'2025_09_27_070714_add_deletion_reason_to_torrents_table',1);