mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
fix admin change password
This commit is contained in:
parent
6e509dab73
commit
dab9afca53
@ -5,6 +5,8 @@ namespace App\Http\Controllers\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\User\TicketSave;
|
||||
use App\Http\Requests\User\TicketWithdraw;
|
||||
use App\Jobs\SendTelegramJob;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketMessage;
|
||||
@ -76,6 +78,7 @@ class TicketController extends Controller
|
||||
abort(500, '工单创建失败');
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendNotify($ticket, $ticketMessage);
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
@ -113,6 +116,7 @@ class TicketController extends Controller
|
||||
abort(500, '工单回复失败');
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendNotify($ticket, $ticketMessage);
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
@ -184,6 +188,12 @@ class TicketController extends Controller
|
||||
|
||||
private function sendNotify(Ticket $ticket, TicketMessage $ticketMessage)
|
||||
{
|
||||
|
||||
$users = User::where('is_admin', 1)
|
||||
->where('telegram_id', '!=', NULL)
|
||||
->get();
|
||||
foreach ($users as $user) {
|
||||
$text = "📮[工单]{$ticket->subject}\r\n\r\n$ticketMessage->message";
|
||||
SendTelegramJob::dispatch($user->telegram_id, $text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
app/Jobs/SendTelegramJob.php
Normal file
43
app/Jobs/SendTelegramJob.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\TelegramService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SendTelegramJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
protected $telegramId;
|
||||
protected $text;
|
||||
|
||||
public $tries = 3;
|
||||
public $timeout = 5;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(int $telegramId, string $text)
|
||||
{
|
||||
$this->onQueue('send_telegram');
|
||||
$this->telegramId = $telegramId;
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$telegramService = new TelegramService();
|
||||
$telegramService->sendMessage($this->telegramId, $this->text, 'markdown');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user