Skip to content
Snippets Groups Projects
Commit 0dc2c4c0 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

check for news expiration in cronjob

parent 63aa7084
No related branches found
No related tags found
No related merge requests found
...@@ -77,6 +77,7 @@ class MatrixPostNewsCronjob extends CronJob ...@@ -77,6 +77,7 @@ class MatrixPostNewsCronjob extends CronJob
print_r($news); print_r($news);
} }
foreach (StudipNews::findMany($news) as $one) { foreach (StudipNews::findMany($news) as $one) {
if ($one->date + $one->expire >= time()) {
foreach ($one->news_ranges as $range) { foreach ($one->news_ranges as $range) {
$success = false; $success = false;
if ($range->course && MatrixRoom::hasRoom($range->course->id)) { if ($range->course && MatrixRoom::hasRoom($range->course->id)) {
...@@ -95,7 +96,7 @@ class MatrixPostNewsCronjob extends CronJob ...@@ -95,7 +96,7 @@ class MatrixPostNewsCronjob extends CronJob
if ($parameters['verbose']) { if ($parameters['verbose']) {
echo sprintf( echo sprintf(
"Posted news entry $1%s to Matrix room $2%s in course $3%s.\n", "Posted news entry $1%s to Matrix room $2%s in course $3%s.\n",
$news->id, $room->matrix_room_id, $room->range_id $one->id, $room->matrix_room_id, $room->range_id
); );
} }
...@@ -106,6 +107,12 @@ class MatrixPostNewsCronjob extends CronJob ...@@ -106,6 +107,12 @@ class MatrixPostNewsCronjob extends CronJob
} }
} }
} }
} else {
DBManager::get()->execute(
"DELETE FROM `matrix_upcoming_news` WHERE `news_id` = :id",
['id' => $one->id]
);
}
} }
// Finally: cleanup news entries that are already expired and need not be considered anymore. // Finally: cleanup news entries that are already expired and need not be considered anymore.
......
pluginname=Matrix-Chat pluginname=Matrix-Chat
pluginclassname=MatrixPlugin pluginclassname=MatrixPlugin
origin=data-quest origin=data-quest
version=1.4.3 version=1.4.4
screenshot=assets/images/matrix_logo.png screenshot=assets/images/matrix_logo.png
description=Matrix chat for Stud.IP courses description=Matrix chat for Stud.IP courses
studipMinVersion=4.5 studipMinVersion=4.5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment