Skip to content

Commit

Permalink
add category edition events support #26
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Nov 4, 2023
1 parent 2e9b119 commit 31aad63
Show file tree
Hide file tree
Showing 28 changed files with 1,514 additions and 37 deletions.
213 changes: 213 additions & 0 deletions src/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,219 @@ public function event(

break;

/// Torrent Categories
case $activity::EVENT_TORRENT_CATEGORIES_ADD:

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

return $this->render(
'default/activity/event/torrent/categories/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(),
'categories' => [
'id' => $activity->getData()['torrentCategoriesId'],
'exist' => $torrentService->getTorrentCategories(
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
)
]
],
'session' =>
[
'user' =>
[
'id' => $user->getId(),
'sensitive' => $user->isSensitive(),
'moderator' => $user->isModerator(),
'owner' => $user->getId() === $torrent->getUserId(),
]
]
]
);

break;

case $activity::EVENT_TORRENT_CATEGORIES_DELETE:

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

return $this->render(
'default/activity/event/torrent/categories/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(),
'categories' => [
'id' => $activity->getData()['torrentCategoriesId'],
'exist' => $torrentService->getTorrentCategories(
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
)
]
],
'session' =>
[
'user' =>
[
'id' => $user->getId(),
'sensitive' => $user->isSensitive(),
'moderator' => $user->isModerator(),
'owner' => $user->getId() === $torrent->getUserId(),
]
]
]
);

break;

case $activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD:

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

return $this->render(
'default/activity/event/torrent/categories/approve/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(),
'categories' => [
'id' => $activity->getData()['torrentCategoriesId'],
'exist' => $torrentService->getTorrentCategories(
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
)
]
],
'session' =>
[
'user' =>
[
'id' => $user->getId(),
'sensitive' => $user->isSensitive(),
'moderator' => $user->isModerator(),
'owner' => $user->getId() === $torrent->getUserId(),
]
]
]
);

break;

case $activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE:

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

return $this->render(
'default/activity/event/torrent/categories/approve/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(),
'categories' => [
'id' => $activity->getData()['torrentCategoriesId'],
'exist' => $torrentService->getTorrentCategories(
$activity->getData()['torrentCategoriesId'] // could be deleted by moderator, remove links
)
]
],
'session' =>
[
'user' =>
[
'id' => $user->getId(),
'sensitive' => $user->isSensitive(),
'moderator' => $user->isModerator(),
'owner' => $user->getId() === $torrent->getUserId(),
]
]
]
);

break;

/// Torrent Sensitive
case $activity::EVENT_TORRENT_SENSITIVE_ADD:

Expand Down
6 changes: 0 additions & 6 deletions src/Controller/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1704,14 +1704,12 @@ public function editCategories(
);

// Register activity event
/* @TODO
$activityService->addEventTorrentCategoriesAdd(
$user->getId(),
$torrent->getId(),
time(),
$torrentCategories->getId()
);
*/

// Redirect to info page
return $this->redirectToRoute(
Expand Down Expand Up @@ -1792,7 +1790,6 @@ public function approveCategories(
}

// Register activity event
/* @TODO
if (!$torrentCategories->isApproved())
{
$activityService->addEventTorrentCategoriesApproveAdd(
Expand All @@ -1812,7 +1809,6 @@ public function approveCategories(
$torrentCategories->getId()
);
}
*/

// Update approved
$torrentService->toggleTorrentCategoriesApproved(
Expand Down Expand Up @@ -1881,14 +1877,12 @@ public function deleteCategories(
}

// Add activity event
/* @TODO
$activityService->addEventTorrentCategoriesDelete(
$user->getId(),
$torrent->getId(),
time(),
$torrentCategories->getId()
);
*/

// Update approved
$torrentService->deleteTorrentCategories(
Expand Down
67 changes: 36 additions & 31 deletions src/Entity/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,57 @@ class Activity
// Event codes

/// User
public const EVENT_USER_ADD = 1000;
public const EVENT_USER_ADD = 1000;

public const EVENT_USER_APPROVE_ADD = 1200;
public const EVENT_USER_APPROVE_DELETE = 1201;
public const EVENT_USER_APPROVE_ADD = 1200;
public const EVENT_USER_APPROVE_DELETE = 1201;

public const EVENT_USER_MODERATOR_ADD = 1300;
public const EVENT_USER_MODERATOR_DELETE = 1301;
public const EVENT_USER_MODERATOR_ADD = 1300;
public const EVENT_USER_MODERATOR_DELETE = 1301;

public const EVENT_USER_STATUS_ADD = 1400;
public const EVENT_USER_STATUS_DELETE = 1401;
public const EVENT_USER_STATUS_ADD = 1400;
public const EVENT_USER_STATUS_DELETE = 1401;

public const EVENT_USER_STAR_ADD = 1500;
public const EVENT_USER_STAR_DELETE = 1501;
public const EVENT_USER_STAR_ADD = 1500;
public const EVENT_USER_STAR_DELETE = 1501;

/// Torrent
public const EVENT_TORRENT_ADD = 2000;
public const EVENT_TORRENT_ADD = 2000;

public const EVENT_TORRENT_APPROVE_ADD = 1100;
public const EVENT_TORRENT_APPROVE_DELETE = 1101;
public const EVENT_TORRENT_APPROVE_ADD = 1100;
public const EVENT_TORRENT_APPROVE_DELETE = 1101;

public const EVENT_TORRENT_LOCALES_ADD = 2200;
public const EVENT_TORRENT_LOCALES_DELETE = 2201;
public const EVENT_TORRENT_LOCALES_APPROVE_ADD = 2210;
public const EVENT_TORRENT_LOCALES_APPROVE_DELETE = 2211;
public const EVENT_TORRENT_LOCALES_ADD = 2200;
public const EVENT_TORRENT_LOCALES_DELETE = 2201;
public const EVENT_TORRENT_LOCALES_APPROVE_ADD = 2210;
public const EVENT_TORRENT_LOCALES_APPROVE_DELETE = 2211;

public const EVENT_TORRENT_SENSITIVE_ADD = 2300;
public const EVENT_TORRENT_SENSITIVE_DELETE = 2301;
public const EVENT_TORRENT_SENSITIVE_APPROVE_ADD = 2310;
public const EVENT_TORRENT_SENSITIVE_APPROVE_DELETE = 2311;
public const EVENT_TORRENT_SENSITIVE_ADD = 2300;
public const EVENT_TORRENT_SENSITIVE_DELETE = 2301;
public const EVENT_TORRENT_SENSITIVE_APPROVE_ADD = 2310;
public const EVENT_TORRENT_SENSITIVE_APPROVE_DELETE = 2311;

public const EVENT_TORRENT_STAR_ADD = 2400;
public const EVENT_TORRENT_STAR_DELETE = 2401;
public const EVENT_TORRENT_STAR_ADD = 2400;
public const EVENT_TORRENT_STAR_DELETE = 2401;

public const EVENT_TORRENT_DOWNLOAD_FILE_ADD = 2500;
public const EVENT_TORRENT_DOWNLOAD_FILE_ADD = 2500;

public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 2600;
public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 2600;

public const EVENT_TORRENT_WANTED_ADD = 2700;
public const EVENT_TORRENT_WANTED_ADD = 2700;

public const EVENT_TORRENT_STATUS_ADD = 1800;
public const EVENT_TORRENT_STATUS_DELETE = 1801;
public const EVENT_TORRENT_STATUS_ADD = 1800;
public const EVENT_TORRENT_STATUS_DELETE = 1801;

public const EVENT_TORRENT_POSTER_ADD = 2800;
public const EVENT_TORRENT_POSTER_DELETE = 2801;
public const EVENT_TORRENT_POSTER_APPROVE_ADD = 2810;
public const EVENT_TORRENT_POSTER_APPROVE_DELETE = 2811;
public const EVENT_TORRENT_POSTER_ADD = 2800;
public const EVENT_TORRENT_POSTER_DELETE = 2801;
public const EVENT_TORRENT_POSTER_APPROVE_ADD = 2810;
public const EVENT_TORRENT_POSTER_APPROVE_DELETE = 2811;

public const EVENT_TORRENT_CATEGORIES_ADD = 2900;
public const EVENT_TORRENT_CATEGORIES_DELETE = 2901;
public const EVENT_TORRENT_CATEGORIES_APPROVE_ADD = 2910;
public const EVENT_TORRENT_CATEGORIES_APPROVE_DELETE = 2911;

// ...

Expand Down
Loading

0 comments on commit 31aad63

Please sign in to comment.