Skip to content

Commit

Permalink
implement torrent statuses management #28
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Oct 26, 2023
1 parent 3cbc6ea commit 989f2f3
Show file tree
Hide file tree
Showing 64 changed files with 1,051 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
# YGGtracker

# Application version, used for API and media cache
APP_VERSION='2.2.0'
APP_VERSION='2.2.1'

# Application name
APP_NAME=YGGtracker
Expand Down
37 changes: 37 additions & 0 deletions migrations/Version20231026163131.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231026163131 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE torrent ADD COLUMN status BOOLEAN DEFAULT 1');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TEMPORARY TABLE __temp__torrent AS SELECT id, user_id, added, scraped, locales, sensitive, approved, md5file, keywords, seeders, peers, leechers FROM torrent');
$this->addSql('DROP TABLE torrent');
$this->addSql('CREATE TABLE torrent (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, user_id INTEGER NOT NULL, added INTEGER NOT NULL, scraped INTEGER DEFAULT NULL, locales CLOB NOT NULL --(DC2Type:simple_array)
, sensitive BOOLEAN NOT NULL, approved BOOLEAN NOT NULL, md5file VARCHAR(32) NOT NULL, keywords CLOB DEFAULT NULL --(DC2Type:simple_array)
, seeders INTEGER DEFAULT NULL, peers INTEGER DEFAULT NULL, leechers INTEGER DEFAULT NULL)');
$this->addSql('INSERT INTO torrent (id, user_id, added, scraped, locales, sensitive, approved, md5file, keywords, seeders, peers, leechers) SELECT id, user_id, added, scraped, locales, sensitive, approved, md5file, keywords, seeders, peers, leechers FROM __temp__torrent');
$this->addSql('DROP TABLE __temp__torrent');
}
}
12 changes: 12 additions & 0 deletions public/asset/default/css/framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ a.button-green:hover {
border-top: 1px #5d627d solid;
}

.border-bottom-dashed {
border-bottom: 1px #5d627d dashed;
}

.border-top-dashed {
border-top: 1px #5d627d dashed;
}

.border-width-2-px {
border-width: 2px;
}
Expand Down Expand Up @@ -367,6 +375,10 @@ a:visited.background-color-hover-night-light:hover {
padding-bottom: 24px;
}

.margin-t-4-px {
margin-top: 4px;
}

.margin-l-4-px {
margin-left: 4px;
}
Expand Down
111 changes: 111 additions & 0 deletions src/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -606,6 +607,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -652,6 +654,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -699,6 +702,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -745,6 +749,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -783,6 +788,102 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
],
'session' =>
[
'user' =>
[
'id' => $user->getId(),
'sensitive' => $user->isSensitive(),
'moderator' => $user->isModerator(),
'owner' => $user->getId() === $torrent->getUserId(),
]
]
]
);

break;

// Torrent Status
case $activity::EVENT_TORRENT_STATUS_ADD:

// Init torrent
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
{
throw $this->createNotFoundException();
}

return $this->render(
'default/activity/event/torrent/status/add' . $extension,
[
'id' => $activity->getId(),
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'torrent' =>
[
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
],
'session' =>
[
'user' =>
[
'id' => $user->getId(),
'sensitive' => $user->isSensitive(),
'moderator' => $user->isModerator(),
'owner' => $user->getId() === $torrent->getUserId(),
]
]
]
);

break;

case $activity::EVENT_TORRENT_STATUS_DELETE:

// Init torrent
if (!$torrent = $torrentService->getTorrent($activity->getTorrentId()))
{
throw $this->createNotFoundException();
}

return $this->render(
'default/activity/event/torrent/status/delete' . $extension,
[
'id' => $activity->getId(),
'added' => $activity->getAdded(),
'user' =>
[
'id' => $activity->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$activity->getUserId()
)->getAddress()
)
],
'torrent' =>
[
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -830,6 +931,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -882,6 +984,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -934,6 +1037,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -986,6 +1090,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -1039,6 +1144,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -1091,6 +1197,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -1143,6 +1250,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -1195,6 +1303,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName(),
Expand Down Expand Up @@ -1248,6 +1357,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down Expand Up @@ -1294,6 +1404,7 @@ public function event(
'id' => $torrent->getId(),
'sensitive' => $torrent->isSensitive(),
'approved' => $torrent->isApproved(),
'status' => $torrent->isStatus(),
'name' => $torrentService->readTorrentFileByTorrentId(
$torrent->getId()
)->getName()
Expand Down
Loading

0 comments on commit 989f2f3

Please sign in to comment.