OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
51
app/Domain/Notifications/Hxcontrollers/News.php
Normal file
51
app/Domain/Notifications/Hxcontrollers/News.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Notifications\Hxcontrollers;
|
||||
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Leantime\Core\Controller\HtmxController;
|
||||
|
||||
class News extends HtmxController
|
||||
{
|
||||
protected static string $view = 'notifications::partials.latestNews';
|
||||
|
||||
private \Leantime\Domain\Notifications\Services\News $newsService;
|
||||
|
||||
/**
|
||||
* Controller constructor
|
||||
*/
|
||||
public function init(\Leantime\Domain\Notifications\Services\News $newsService): void
|
||||
{
|
||||
$this->newsService = $newsService;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws BindingResolutionException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
if (! env('LEAN_NEWS_ENABLED', true)) {
|
||||
$this->tpl->assign('rss', 'News service is disabled');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$news = false;
|
||||
try {
|
||||
$news = $this->newsService->getLatest(session('userdata.id'));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::warning('Could not connect to news server');
|
||||
}
|
||||
|
||||
if ($news === false) {
|
||||
$news = 'Could not connect to news server';
|
||||
}
|
||||
|
||||
$this->tpl->assign('rss', $news);
|
||||
}
|
||||
}
|
||||
45
app/Domain/Notifications/Hxcontrollers/NewsBadge.php
Normal file
45
app/Domain/Notifications/Hxcontrollers/NewsBadge.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Notifications\Hxcontrollers;
|
||||
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Leantime\Core\Controller\HtmxController;
|
||||
|
||||
class NewsBadge extends HtmxController
|
||||
{
|
||||
protected static string $view = 'notifications::partials.newsBadge';
|
||||
|
||||
private \Leantime\Domain\Notifications\Services\News $newsService;
|
||||
|
||||
/**
|
||||
* Controller constructor
|
||||
*/
|
||||
public function init(\Leantime\Domain\Notifications\Services\News $newsService): void
|
||||
{
|
||||
$this->newsService = $newsService;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*
|
||||
* @throws BindingResolutionException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
if (! env('LEAN_NEWS_ENABLED', true)) {
|
||||
$this->tpl->assign('hasNews', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$hasNews = $this->newsService->hasNews(session('userdata.id'));
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
$hasNews = false;
|
||||
}
|
||||
|
||||
$this->tpl->assign('hasNews', $hasNews);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user