删除会话之后要将未读消息给清零
This commit is contained in:
parent
72ca5579fb
commit
3eb22784d5
@ -318,6 +318,10 @@ class Project extends AbstractModel
|
|||||||
public function deleteProject()
|
public function deleteProject()
|
||||||
{
|
{
|
||||||
AbstractModel::transaction(function () {
|
AbstractModel::transaction(function () {
|
||||||
|
$dialog = WebSocketDialog::find($this->dialog_id);
|
||||||
|
if ($dialog) {
|
||||||
|
$dialog->deleteDialog();
|
||||||
|
}
|
||||||
$columns = ProjectColumn::whereProjectId($this->id)->get();
|
$columns = ProjectColumn::whereProjectId($this->id)->get();
|
||||||
foreach ($columns as $column) {
|
foreach ($columns as $column) {
|
||||||
$column->deleteColumn(false);
|
$column->deleteColumn(false);
|
||||||
|
@ -626,6 +626,12 @@ class ProjectTask extends AbstractModel
|
|||||||
public function deleteTask($pushMsg = true)
|
public function deleteTask($pushMsg = true)
|
||||||
{
|
{
|
||||||
AbstractModel::transaction(function () {
|
AbstractModel::transaction(function () {
|
||||||
|
if ($this->dialog_id) {
|
||||||
|
$dialog = WebSocketDialog::find($this->dialog_id);
|
||||||
|
if ($dialog) {
|
||||||
|
$dialog->deleteDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->delete();
|
$this->delete();
|
||||||
$this->addLog("删除{任务}:" . $this->name);
|
$this->addLog("删除{任务}:" . $this->name);
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Exceptions\ApiException;
|
use App\Exceptions\ApiException;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,6 +48,21 @@ class WebSocketDialog extends AbstractModel
|
|||||||
return $this->hasMany(WebSocketDialogUser::class, 'dialog_id', 'id');
|
return $this->hasMany(WebSocketDialogUser::class, 'dialog_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除会话
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function deleteDialog()
|
||||||
|
{
|
||||||
|
AbstractModel::transaction(function () {
|
||||||
|
WebSocketDialogMsgRead::whereDialogId($this->id)->whereNull('read_at')->update([
|
||||||
|
'read_at' => Carbon::now()
|
||||||
|
]);
|
||||||
|
$this->delete();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取对话(同时检验对话身份)
|
* 获取对话(同时检验对话身份)
|
||||||
* @param $id
|
* @param $id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user