no message

This commit is contained in:
kuaifan
2021-06-05 00:23:22 +08:00
parent b78e30c2f0
commit 3670e2ce2c
4 changed files with 41 additions and 11 deletions
@@ -44,9 +44,6 @@ class DialogController extends AbstractController
}
//
$list = WebSocketDialogMsg::whereDialogId($dialog_id)->orderByDesc('id')->paginate(Base::getPaginate(100, 50));
$list->transform(function (WebSocketDialogMsg $item) {
return $item->sendSuccess();
});
//
return Base::retSuccess('success', $list);
}
+5 -5
View File
@@ -15,7 +15,7 @@ use Carbon\Carbon;
* @property int|null $userid 发送会员ID
* @property string|null $type 消息类型
* @property array|mixed $msg 详细消息
* @property int|null $send 是否已送达
* @property int|null $read 是否已读
* @property int|null $extra_int 额外数字参数
* @property string|null $extra_str 额外字符参数
* @property \Illuminate\Support\Carbon|null $created_at
@@ -29,7 +29,7 @@ use Carbon\Carbon;
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereExtraStr($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereMsg($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereSend($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereRead($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|WebSocketDialogMsg whereUserid($value)
@@ -58,10 +58,10 @@ class WebSocketDialogMsg extends AbstractModel
* 标记已送达 同时 告诉发送人已送达
* @return $this
*/
public function sendSuccess()
public function readSuccess()
{
if (empty($this->send)) {
$this->send = 1;
if (empty($this->read)) {
$this->read = 1;
$this->save();
PushTask::push([
'userid' => $this->userid,
+8 -2
View File
@@ -114,8 +114,14 @@ class WebSocketService implements WebSocketHandlerInterface
* 收到回执
*/
case 'receipt':
$dialogMsg = WebSocketDialogMsg::whereId(intval($msgId))->first();
$dialogMsg && $dialogMsg->sendSuccess();
return;
/**
* 已阅消息
*/
case 'readMsg':
$dialogMsg = WebSocketDialogMsg::whereId(intval($data['id']))->first();
$dialogMsg && $dialogMsg->readSuccess();
return;
}
//