YGGtracker/src/Service/ActivityService.php

1603 lines
37 KiB
PHP
Raw Normal View History

2023-10-06 01:12:14 +00:00
<?php
namespace App\Service;
use App\Entity\Activity;
use App\Repository\ActivityRepository;
use Doctrine\ORM\EntityManagerInterface;
2023-10-11 19:34:47 +00:00
use Symfony\Contracts\Translation\TranslatorInterface;
2023-10-06 01:12:14 +00:00
class ActivityService
{
2023-10-10 20:42:45 +00:00
private EntityManagerInterface $entityManagerInterface;
2023-10-11 19:34:47 +00:00
private TranslatorInterface $translatorInterface;
2023-10-06 01:12:14 +00:00
public function __construct(
2023-10-11 19:34:47 +00:00
EntityManagerInterface $entityManagerInterface,
TranslatorInterface $translatorInterface
2023-10-06 01:12:14 +00:00
)
{
2023-10-10 20:42:45 +00:00
$this->entityManagerInterface = $entityManagerInterface;
2023-10-11 19:34:47 +00:00
$this->translatorInterface = $translatorInterface;
}
public function getEventCodes(): array
{
return
[
// User
Activity::EVENT_USER_ADD,
Activity::EVENT_USER_APPROVE_ADD,
Activity::EVENT_USER_APPROVE_DELETE,
Activity::EVENT_USER_MODERATOR_ADD,
Activity::EVENT_USER_MODERATOR_DELETE,
Activity::EVENT_USER_STATUS_ADD,
Activity::EVENT_USER_STATUS_DELETE,
Activity::EVENT_USER_STAR_ADD,
Activity::EVENT_USER_STAR_DELETE,
// Torrents
Activity::EVENT_TORRENT_ADD,
2023-10-12 23:28:50 +00:00
Activity::EVENT_TORRENT_APPROVE_ADD,
Activity::EVENT_TORRENT_APPROVE_DELETE,
2023-10-11 19:34:47 +00:00
Activity::EVENT_TORRENT_LOCALES_ADD,
Activity::EVENT_TORRENT_LOCALES_DELETE,
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD,
Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE,
Activity::EVENT_TORRENT_SENSITIVE_ADD,
Activity::EVENT_TORRENT_SENSITIVE_DELETE,
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD,
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE,
2023-10-30 03:14:46 +00:00
Activity::EVENT_TORRENT_POSTER_ADD,
Activity::EVENT_TORRENT_POSTER_DELETE,
Activity::EVENT_TORRENT_POSTER_APPROVE_ADD,
Activity::EVENT_TORRENT_POSTER_APPROVE_DELETE,
2023-10-11 19:34:47 +00:00
Activity::EVENT_TORRENT_STAR_ADD,
Activity::EVENT_TORRENT_STAR_DELETE,
Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD,
Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD,
2023-10-23 21:12:13 +00:00
Activity::EVENT_TORRENT_STATUS_ADD,
Activity::EVENT_TORRENT_STATUS_DELETE,
2023-10-23 21:12:13 +00:00
Activity::EVENT_TORRENT_WANTED_ADD,
2023-10-11 19:34:47 +00:00
];
}
public function getEventsTree(): array
{
$events = [];
foreach ($this->getEventCodes() as $code)
{
switch ($code)
{
// User
case Activity::EVENT_USER_ADD:
$events
[
$this->translatorInterface->trans('Users')
]
[
$this->translatorInterface->trans('Joined')
] = $code;
break;
/// User approve
case Activity::EVENT_USER_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Users')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_USER_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Users')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// User status
case Activity::EVENT_USER_STATUS_ADD:
$events
[
$this->translatorInterface->trans('User statuses')
]
[
$this->translatorInterface->trans('Enabled')
] = $code;
break;
case Activity::EVENT_USER_STATUS_DELETE:
$events
[
$this->translatorInterface->trans('User statuses')
]
[
$this->translatorInterface->trans('Disabled')
] = $code;
break;
/// User moderator
case Activity::EVENT_USER_MODERATOR_ADD:
$events
[
$this->translatorInterface->trans('User moderators')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_USER_MODERATOR_DELETE:
$events
[
$this->translatorInterface->trans('User moderators')
]
[
$this->translatorInterface->trans('Removed')
] = $code;
break;
/// User star
case Activity::EVENT_USER_STAR_ADD:
$events
[
$this->translatorInterface->trans('User stars')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_USER_STAR_DELETE:
$events
[
$this->translatorInterface->trans('User stars')
]
[
$this->translatorInterface->trans('Removed')
] = $code;
break;
// Torrent
case Activity::EVENT_TORRENT_ADD:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
2023-10-12 23:28:50 +00:00
case Activity::EVENT_TORRENT_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
2023-10-11 19:34:47 +00:00
/// Torrent locales
case Activity::EVENT_TORRENT_LOCALES_ADD:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_LOCALES_DELETE:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Deleted')
] = $code;
break;
case Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// Torrent sensitive
case Activity::EVENT_TORRENT_SENSITIVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_SENSITIVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Deleted')
] = $code;
break;
case Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
2023-10-30 03:14:46 +00:00
/// Torrent poster
case Activity::EVENT_TORRENT_POSTER_ADD:
$events
[
2023-10-30 19:04:11 +00:00
$this->translatorInterface->trans('Torrent posters')
2023-10-30 03:14:46 +00:00
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_POSTER_DELETE:
$events
[
2023-10-30 19:04:11 +00:00
$this->translatorInterface->trans('Torrent posters')
2023-10-30 03:14:46 +00:00
]
[
$this->translatorInterface->trans('Deleted')
] = $code;
break;
case Activity::EVENT_TORRENT_POSTER_APPROVE_ADD:
$events
[
2023-10-30 19:04:11 +00:00
$this->translatorInterface->trans('Torrent posters')
2023-10-30 03:14:46 +00:00
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_POSTER_APPROVE_DELETE:
$events
[
2023-10-30 19:04:11 +00:00
$this->translatorInterface->trans('Torrent posters')
2023-10-30 03:14:46 +00:00
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
2023-10-11 19:34:47 +00:00
/// Torrent stars
case Activity::EVENT_TORRENT_STAR_ADD:
$events
[
$this->translatorInterface->trans('Torrent stars')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_STAR_DELETE:
$events
[
$this->translatorInterface->trans('Torrent stars')
]
[
$this->translatorInterface->trans('Removed')
] = $code;
break;
/// Torrent downloads
case Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD:
$events
[
$this->translatorInterface->trans('Torrent downloads')
]
[
$this->translatorInterface->trans('Files')
] = $code;
break;
case Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD:
$events
[
$this->translatorInterface->trans('Torrent downloads')
]
[
$this->translatorInterface->trans('Magnet links')
] = $code;
break;
2023-10-23 21:12:13 +00:00
case Activity::EVENT_TORRENT_WANTED_ADD:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Wanted')
] = $code;
break;
case Activity::EVENT_TORRENT_STATUS_ADD:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Enabled')
] = $code;
break;
case Activity::EVENT_TORRENT_STATUS_DELETE:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Disabled')
] = $code;
break;
2023-10-11 19:34:47 +00:00
}
}
return $events;
2023-10-10 20:42:45 +00:00
}
2023-10-11 20:03:45 +00:00
public function findLastActivities(
2023-10-11 23:19:57 +00:00
array $whitelist,
int $limit = 10,
int $offset = 0
): array
2023-10-10 20:42:45 +00:00
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findBy(
[
'event' => $whitelist
],
2023-10-10 20:42:45 +00:00
[
'id' => 'DESC'
2023-10-11 23:19:57 +00:00
],
$limit,
$offset
2023-10-10 20:42:45 +00:00
);
2023-10-06 01:12:14 +00:00
}
2023-10-11 20:03:45 +00:00
public function findLastActivitiesByUserId(
int $userId,
2023-10-11 23:19:57 +00:00
array $whitelist,
int $limit = 10,
int $offset = 0
2023-10-11 20:03:45 +00:00
): array
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findBy(
[
'userId' => $userId,
2023-10-11 23:19:57 +00:00
'event' => $whitelist,
],
[
'id' => 'DESC'
],
$limit,
$offset
);
}
public function findLastActivitiesByTorrentId(
int $torrentId,
array $whitelist,
int $limit = 10,
int $offset = 0
): array
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findBy(
[
'torrentId' => $torrentId,
'event' => $whitelist,
],
[
'id' => 'DESC'
],
$limit,
$offset
);
}
public function findActivitiesTotal(
array $whitelist
): int
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findActivitiesTotal($whitelist);
}
public function findActivitiesTotalByUserId(
int $userId,
array $whitelist
): int
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findActivitiesTotalByUserId(
$userId,
$whitelist
);
}
public function findActivitiesTotalByTorrentId(
int $torrentId,
array $whitelist
): int
{
return $this->entityManagerInterface
->getRepository(Activity::class)
->findActivitiesTotalByTorrentId(
$torrentId,
$whitelist
);
}
2023-10-10 20:42:45 +00:00
// User
2023-10-10 22:34:04 +00:00
public function addEventUserAdd(
2023-10-10 20:42:45 +00:00
int $userId,
int $added
): ?Activity
2023-10-06 01:12:14 +00:00
{
$activity = new Activity();
2023-10-10 20:42:45 +00:00
$activity->setEvent(
Activity::EVENT_USER_ADD
);
2023-10-06 01:12:14 +00:00
2023-10-10 20:42:45 +00:00
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
2023-10-06 01:12:14 +00:00
return $activity;
}
2023-10-11 01:04:02 +00:00
/// User approved
public function addEventUserApproveAdd(
int $userId,
int $added,
int $userIdTarget,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventUserApproveDelete(
int $userId,
int $added,
int $userIdTarget,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
/// User status
public function addEventUserStatusAdd(
int $userId,
int $added,
int $userIdTarget,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_STATUS_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventUserStatusDelete(
int $userId,
int $added,
int $userIdTarget,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_STATUS_DELETE
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
/// User moderator
public function addEventUserModeratorAdd(
int $userId,
int $added,
int $userIdTarget,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_MODERATOR_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventUserModeratorDelete(
int $userId,
int $added,
int $userIdTarget,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_MODERATOR_DELETE
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-10 22:09:34 +00:00
/// User star
2023-10-10 20:42:45 +00:00
public function addEventUserStarAdd(
int $userId,
int $added,
int $userIdTarget
): ?Activity
2023-10-06 01:12:14 +00:00
{
2023-10-10 20:42:45 +00:00
$activity = new Activity();
$activity->setEvent(
2023-10-10 22:09:34 +00:00
Activity::EVENT_USER_STAR_ADD
2023-10-10 20:42:45 +00:00
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventUserStarDelete(
int $userId,
int $added,
int $userIdTarget
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_USER_STAR_DELETE
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'userId' => $userIdTarget
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
// Torrent
2023-10-10 22:34:04 +00:00
public function addEventTorrentAdd(
int $userId,
int $added,
int $torrentId
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setTorrentId(
$torrentId
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-10 20:42:45 +00:00
2023-10-12 23:28:50 +00:00
public function addEventTorrentApproveAdd(
int $userId,
int $torrentId,
int $added
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentApproveDelete(
int $userId,
int $torrentId,
int $added
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentStatusAdd(
int $userId,
int $torrentId,
int $added
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_STATUS_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentStatusDelete(
int $userId,
int $torrentId,
int $added
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_STATUS_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-23 21:12:13 +00:00
public function addEventTorrentWantedAdd(
int $userId,
int $added,
int $torrentId
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_WANTED_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setTorrentId(
$torrentId
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-10 22:42:19 +00:00
/// Torrent Download
public function addEventTorrentDownloadFileAdd(
int $userId,
int $added,
int $torrentId
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setTorrentId(
$torrentId
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentDownloadMagnetAdd(
int $userId,
int $added,
int $torrentId
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD
);
$activity->setUserId(
$userId
);
$activity->setAdded(
$added
);
$activity->setTorrentId(
$torrentId
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-10 22:09:34 +00:00
/// Torrent star
public function addEventTorrentStarAdd(
int $userId,
int $added,
int $torrentId
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_STAR_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentStarDelete(
int $userId,
int $added,
int $torrentId
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_STAR_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-10 20:42:45 +00:00
/// Torrent locales
public function addEventTorrentLocalesAdd(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_ADD
);
2023-10-06 01:12:14 +00:00
2023-10-10 20:42:45 +00:00
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentLocalesDelete(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentLocalesApproveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentLocalesApproveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentLocalesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentLocalesId' => $torrentLocalesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
/// Torrent sensitive
public function addEventTorrentSensitiveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentSensitiveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentSensitiveApproveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentSensitiveApproveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentSensitiveId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentSensitiveId' => $torrentSensitiveId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
2023-10-06 01:12:14 +00:00
}
2023-10-30 03:14:46 +00:00
/// Torrent poster
public function addEventTorrentPosterAdd(
int $userId,
int $torrentId,
int $added,
int $torrentPosterId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_POSTER_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentPosterId' => $torrentPosterId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentPosterDelete(
int $userId,
int $torrentId,
int $added,
int $torrentPosterId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_POSTER_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentPosterId' => $torrentPosterId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentPosterApproveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentPosterId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_POSTER_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentPosterId' => $torrentPosterId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentPosterApproveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentPosterId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_POSTER_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentPosterId' => $torrentPosterId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
2023-10-06 01:12:14 +00:00
}