Skip to content

Commit c3b0467

Browse files
authored
Introducing audit logging table for playlist videos and its cleanup cronjob (elan-ev#1381)
* Add audit logging for playlist videos and cleanup cronjob - Implemented PlaylistVideosAuditLog for tracking add, delete, and restore actions. - Enhanced PlaylistVideos model to log actions during delete and store operations. - Created a cronjob (OpencastPlaylistVideosAuditCleanup) to periodically clean up old audit log entries. (every 28 days) - Added migration to create the oc_playlist_videos_audit_log table and schedule the cleanup task. * make sure the deleton check is against all course playlist to avoid default playlist video re-adding * changes according to discussion: - reverting audit log mechanism - taking addToCoursePlaylist out of OpencastVideoSync observer - only call addToCoursePlaylist when the video is fresh, this should happen only when scheduling occurs!
1 parent 0d16102 commit c3b0467

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

bootstrap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
StudipAutoloader::addAutoloadPath(__DIR__ . '/lib', 'Opencast');
44

55
// adding observer
6-
NotificationCenter::addObserver('Opencast\Models\Videos', 'addToCoursePlaylist', 'OpencastCourseSync');
76
NotificationCenter::addObserver('Opencast\Models\Videos', 'parseEvent', 'OpencastVideoSync');
87
NotificationCenter::addObserver('Opencast\Models\Videos', 'checkEventACL', 'OpencastVideoSync');
98
NotificationCenter::addObserver('Opencast\Models\VideosUserPerms', 'setPermissions', 'OpencastVideoSync');

bootstrap_migrations.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
StudipAutoloader::addAutoloadPath(__DIR__ . '/lib', 'Opencast');
44

55
// adding observer
6-
NotificationCenter::addObserver('Opencast\Models\Videos', 'addToCoursePlaylist', 'OpencastCourseSync');
76
NotificationCenter::addObserver('Opencast\Models\Videos', 'parseEvent', 'OpencastVideoSync');
87
NotificationCenter::addObserver('Opencast\Models\Videos', 'checkEventACL', 'OpencastVideoSync');
98
NotificationCenter::addObserver('Opencast\Models\VideosUserPerms', 'setPermissions', 'OpencastVideoSync');

cronjobs/opencast_discover_videos.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ public function execute($last_result, $parameters = array())
142142
$video = Videos::findOneBySql("episode = ?", [$current_event->identifier]);
143143
$is_livestream = (bool) $video->is_livestream ?? false;
144144

145+
// Set a flag to determine a new state of the video!
146+
$is_new = false;
145147
if (!$video) {
148+
$is_new = true;
146149
$video = new Videos;
147150
}
148151

@@ -160,6 +163,11 @@ public function execute($last_result, $parameters = array())
160163

161164
self::parseEvent($current_event, $video);
162165

166+
// Make sure the new videos are only get processed by the add to course playlist.
167+
if ($is_new) {
168+
Videos::addToCoursePlaylist($current_event, $video);
169+
}
170+
163171
// remove video from checklist for playlist videos (if even present)
164172
unset($playlist_videos[$current_event->identifier]);
165173
}

lib/Models/Videos.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,18 +1190,15 @@ public function reportVideo($description)
11901190
}
11911191

11921192

1193-
/**
1193+
/**
11941194
* Assigns a video to the seminar if the video belongs to the seminar' series
11951195
*
1196-
* @Notification OpencastVideoSync
1197-
*
1198-
* @param string $eventType
1199-
* @param object $episode
1200-
* @param Opencast\Models\Video $video
1196+
* @param object $episode the opencast episode object
1197+
* @param Opencast\Models\Video $video the Stud.IP video record
12011198
*
12021199
* @return void
12031200
*/
1204-
public static function addToCoursePlaylist($eventType, $episode, $video)
1201+
public static function addToCoursePlaylist($episode, $video)
12051202
{
12061203
// check if a series is assigned to this event
12071204
if (!isset($episode->is_part_of) || empty($episode)) {

lib/Routes/Playlist/PlaylistAddVideos.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __invoke(Request $request, Response $response, $args)
2525

2626
$data = $this->getRequestData($request);
2727
$video_tokens = $data['videos'];
28-
$course_id = $data['course_id'];
28+
$course_id = $data['course_id'] ?? null;
2929

3030
$videos = array_map(function ($token) {
3131
return Videos::findOneByToken($token);
@@ -64,4 +64,4 @@ public function __invoke(Request $request, Response $response, $args)
6464

6565
return $response->withStatus(204);
6666
}
67-
}
67+
}

0 commit comments

Comments
 (0)