diff --git a/app/Console/Commands/FireEvent.php b/app/Console/Commands/FireEvent.php index 4d58284a..bc5103b3 100644 --- a/app/Console/Commands/FireEvent.php +++ b/app/Console/Commands/FireEvent.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Events\NewsCreated; use App\Events\TorrentCreated; use App\Events\UserDestroyed; use App\Events\UserDisabled; @@ -29,6 +30,7 @@ class FireEvent extends Command "user_destroyed" => UserDestroyed::class, "user_disabled" => UserDisabled::class, "user_enabled" => UserEnabled::class, + "news_created" => NewsCreated::class, ]; /** diff --git a/app/Events/NewsCreated.php b/app/Events/NewsCreated.php new file mode 100644 index 00000000..1528f749 --- /dev/null +++ b/app/Events/NewsCreated.php @@ -0,0 +1,38 @@ +id = $id; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new PrivateChannel('channel-name'); + } +} diff --git a/app/Repositories/TorrentRepository.php b/app/Repositories/TorrentRepository.php index 0370e0ad..52cdca90 100644 --- a/app/Repositories/TorrentRepository.php +++ b/app/Repositories/TorrentRepository.php @@ -799,7 +799,7 @@ HTML; if (is_array($arr) && isset($arr['torrent_id'], $arr['pieces_hash'])) { $out[$arr['pieces_hash']] = $arr['torrent_id']; } else { - do_log(sprintf("%s, invalid item: %s(%s)", $logPrefix, var_export($item, true), gettype($item)), 'error'); + do_log(sprintf("%s, invalid item: %s(%s)", $logPrefix, var_export($item, true), gettype($item))); } } return $out; diff --git a/include/constants.php b/include/constants.php index fde4393a..fa62b6d0 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ delete_value('recent_news',true); - if (mysql_affected_rows() != 1) - stderr($lang_news['std_error'], $lang_news['std_something_weird_happened']); + if (mysql_affected_rows() != 1) { + stderr($lang_news['std_error'], $lang_news['std_something_weird_happened']); + } + fire_event("news_created", mysql_insert_id()); header("Location: " . get_protocol_prefix() . "$BASEURL/index.php"); }