add category edition events support #26

This commit is contained in:
ghost 2023-11-04 07:45:58 +02:00
parent 2e9b119733
commit 31aad63399
28 changed files with 1514 additions and 37 deletions

View file

@ -51,6 +51,11 @@ class ActivityService
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD,
Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE,
Activity::EVENT_TORRENT_CATEGORIES_ADD,
Activity::EVENT_TORRENT_CATEGORIES_DELETE,
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD,
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE,
Activity::EVENT_TORRENT_SENSITIVE_ADD,
Activity::EVENT_TORRENT_SENSITIVE_DELETE,
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD,
@ -277,6 +282,55 @@ class ActivityService
break;
/// Torrent categories
case Activity::EVENT_TORRENT_CATEGORIES_ADD:
$events
[
$this->translatorInterface->trans('Torrent categories')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_CATEGORIES_DELETE:
$events
[
$this->translatorInterface->trans('Torrent categories')
]
[
$this->translatorInterface->trans('Deleted')
] = $code;
break;
case Activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent categories')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent categories')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// Torrent sensitive
case Activity::EVENT_TORRENT_SENSITIVE_ADD:
@ -1303,6 +1357,155 @@ class ActivityService
return $activity;
}
/// Torrent categories
public function addEventTorrentCategoriesAdd(
int $userId,
int $torrentId,
int $added,
int $torrentCategoriesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_CATEGORIES_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentCategoriesId' => $torrentCategoriesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentCategoriesDelete(
int $userId,
int $torrentId,
int $added,
int $torrentCategoriesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_CATEGORIES_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentCategoriesId' => $torrentCategoriesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentCategoriesApproveAdd(
int $userId,
int $torrentId,
int $added,
int $torrentCategoriesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentCategoriesId' => $torrentCategoriesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentCategoriesApproveDelete(
int $userId,
int $torrentId,
int $added,
int $torrentCategoriesId,
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_CATEGORIES_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$activity->setData(
[
'torrentCategoriesId' => $torrentCategoriesId
]
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
/// Torrent sensitive
public function addEventTorrentSensitiveAdd(
int $userId,