撤回消息优化

This commit is contained in:
kuaifan
2022-01-28 15:02:58 +08:00
parent 35bd038802
commit 02eb386155
3 changed files with 86 additions and 48 deletions

View File

@@ -127,6 +127,35 @@ class WebSocketDialogMsg extends AbstractModel
return true;
}
/**
* 删除消息
* @return void
*/
public function deleteMsg()
{
$send_dt = Carbon::parse($this->created_at)->addMinutes(5);
if ($send_dt->lt(Carbon::now())) {
throw new ApiException('已超过5分钟此消息不能撤回');
}
$this->delete();
//
$dialog = WebSocketDialog::find($this->dialog_id);
if ($dialog) {
$userids = $dialog->dialogUser->pluck('userid')->toArray();
PushTask::push([
'userid' => $userids,
'msg' => [
'type' => 'dialog',
'mode' => 'delete',
'data' => [
'id' => $this->id,
'dialog_id' => $this->dialog_id
],
]
]);
}
}
/**
* 发送消息
* @param int $dialog_id 会话ID即 聊天室ID