mirror of
https://github.com/v2board/v2board.git
synced 2025-02-10 23:49:12 +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\Controllers\Controller;
|
||||||
use App\Http\Requests\User\TicketSave;
|
use App\Http\Requests\User\TicketSave;
|
||||||
use App\Http\Requests\User\TicketWithdraw;
|
use App\Http\Requests\User\TicketWithdraw;
|
||||||
|
use App\Jobs\SendTelegramJob;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
use App\Models\TicketMessage;
|
use App\Models\TicketMessage;
|
||||||
@ -76,6 +78,7 @@ class TicketController extends Controller
|
|||||||
abort(500, '工单创建失败');
|
abort(500, '工单创建失败');
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
$this->sendNotify($ticket, $ticketMessage);
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
@ -113,6 +116,7 @@ class TicketController extends Controller
|
|||||||
abort(500, '工单回复失败');
|
abort(500, '工单回复失败');
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
$this->sendNotify($ticket, $ticketMessage);
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
@ -184,6 +188,12 @@ class TicketController extends Controller
|
|||||||
|
|
||||||
private function sendNotify(Ticket $ticket, TicketMessage $ticketMessage)
|
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');
|
||||||
|
}
|
||||||
|
}
|
2
pm2.yaml
2
pm2.yaml
@ -1,5 +1,5 @@
|
|||||||
apps:
|
apps:
|
||||||
- name : 'V2Board'
|
- name : 'V2Board'
|
||||||
script : 'php artisan queue:work --queue=send_email'
|
script : 'php artisan queue:work --queue=send_email,send_telegram'
|
||||||
instances: 4
|
instances: 4
|
||||||
out_file : './storage/logs/queue/queue.log'
|
out_file : './storage/logs/queue/queue.log'
|
||||||
|
Loading…
Reference in New Issue
Block a user