no message
This commit is contained in:
parent
e761820df1
commit
f9031aec57
@ -111,12 +111,14 @@ class DialogController extends AbstractController
|
||||
return $item;
|
||||
});
|
||||
//
|
||||
if ($dialog->type == 'group' && $dialog->group_type == 'task') {
|
||||
$user->task_dialog_id = $dialog->id;
|
||||
$user->save();
|
||||
}
|
||||
//
|
||||
$data = $list->toArray();
|
||||
if ($list->currentPage() === 1) {
|
||||
$data['dialog'] = WebSocketDialog::formatData($dialog, $user->userid);
|
||||
//
|
||||
$user->dialog_id = $dialog->id;
|
||||
$user->save();
|
||||
}
|
||||
return Base::retSuccess('success', $data);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use Carbon\Carbon;
|
||||
* @property string|null $last_at 最后登录时间
|
||||
* @property string|null $line_ip 最后在线IP(接口)
|
||||
* @property string|null $line_at 最后在线时间(接口)
|
||||
* @property int|null $dialog_id 最后打开的会话ID
|
||||
* @property int|null $task_dialog_id 最后打开的任务会话ID
|
||||
* @property string|null $created_ip 注册IP
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
@ -38,7 +38,6 @@ use Carbon\Carbon;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereChangepass($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedIp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereDialogId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereEncrypt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereIdentity($value)
|
||||
@ -50,6 +49,7 @@ use Carbon\Carbon;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereNickname($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereProfession($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereTaskDialogId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereUserid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User whereUserimg($value)
|
||||
|
@ -63,30 +63,32 @@ class WebSocketDialogMsgTask extends AbstractTask
|
||||
'ignoreFd' => $this->ignoreFd,
|
||||
'msg' => [
|
||||
'type' => 'dialog',
|
||||
'mode' => 'add1',
|
||||
'mode' => 'add',
|
||||
'data' => $msg->toArray(),
|
||||
]
|
||||
]);
|
||||
|
||||
// 推送目标②:正在打开这个会话的会员
|
||||
$list = User::whereDialogId($dialog->id)->pluck('userid')->toArray();
|
||||
if ($list) {
|
||||
$array = [];
|
||||
foreach ($list as $uid) {
|
||||
if (!in_array($uid, $userids)) {
|
||||
$array[] = $uid;
|
||||
// 推送目标②:正在打开这个任务会话的会员
|
||||
if ($dialog->type == 'group' && $dialog->group_type == 'task') {
|
||||
$list = User::whereTaskDialogId($dialog->id)->pluck('userid')->toArray();
|
||||
if ($list) {
|
||||
$array = [];
|
||||
foreach ($list as $uid) {
|
||||
if (!in_array($uid, $userids)) {
|
||||
$array[] = $uid;
|
||||
}
|
||||
}
|
||||
if ($array) {
|
||||
PushTask::push([
|
||||
'userid' => $array,
|
||||
'ignoreFd' => $this->ignoreFd,
|
||||
'msg' => [
|
||||
'type' => 'dialog',
|
||||
'mode' => 'chat',
|
||||
'data' => $msg->toArray(),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
if ($array) {
|
||||
PushTask::push([
|
||||
'userid' => $array,
|
||||
'ignoreFd' => $this->ignoreFd,
|
||||
'msg' => [
|
||||
'type' => 'dialog',
|
||||
'mode' => 'add2',
|
||||
'data' => $msg->toArray(),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -309,13 +309,9 @@ export default {
|
||||
},
|
||||
|
||||
sendSuccess(data) {
|
||||
this.$store.dispatch("saveDialog", {
|
||||
id: this.dialogId,
|
||||
last_msg: data,
|
||||
last_at: $A.formatDate("Y-m-d H:i:s")
|
||||
});
|
||||
this.$store.dispatch("saveDialogMsg", data);
|
||||
this.$store.dispatch("dialogMoveTop", this.dialogId);
|
||||
this.$store.dispatch("updateDialogLastMsg", data);
|
||||
this.$store.dispatch("moveDialogTop", this.dialogId);
|
||||
this.$store.dispatch("increaseTaskMsgNum", this.dialogId);
|
||||
},
|
||||
|
||||
|
@ -968,6 +968,25 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新会话最后消息
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param data
|
||||
*/
|
||||
updateDialogLastMsg({state, dispatch}, data) {
|
||||
let dialog = state.dialogs.find(({id}) => id == data.dialog_id);
|
||||
if (dialog) {
|
||||
dispatch("saveDialog", {
|
||||
id: data.dialog_id,
|
||||
last_msg: data,
|
||||
last_at: state.method.formatDate("Y-m-d H:i:s")
|
||||
});
|
||||
} else {
|
||||
dispatch("getDialogOne", data.dialog_id);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取会话列表
|
||||
* @param state
|
||||
@ -1036,7 +1055,7 @@ export default {
|
||||
* @param state
|
||||
* @param dialog_id
|
||||
*/
|
||||
dialogMoveTop({state}, dialog_id) {
|
||||
moveDialogTop({state}, dialog_id) {
|
||||
const index = state.dialogs.findIndex(({id}) => id == dialog_id);
|
||||
if (index > -1) {
|
||||
const tmp = state.method.cloneJSON(state.dialogs[index]);
|
||||
@ -1271,27 +1290,18 @@ export default {
|
||||
// 更新消息列表
|
||||
state.dialogMsgPush = data;
|
||||
dispatch("saveDialogMsg", data)
|
||||
if (mode === "add2") {
|
||||
if (mode === "chat") {
|
||||
return;
|
||||
}
|
||||
// 更新最后消息
|
||||
let dialog = state.dialogs.find(({id}) => id == dialog_id);
|
||||
if (dialog) {
|
||||
dispatch("saveDialog", {
|
||||
id: dialog_id,
|
||||
last_msg: data,
|
||||
last_at: state.method.formatDate("Y-m-d H:i:s")
|
||||
});
|
||||
} else {
|
||||
dispatch("getDialogOne", dialog_id);
|
||||
}
|
||||
if (mode === "add1") {
|
||||
dispatch("updateDialogLastMsg", data);
|
||||
if (mode === "add") {
|
||||
// 更新对话列表
|
||||
if (dialog) {
|
||||
// 新增未读数
|
||||
if (data.userid !== state.userId) dialog.unread++;
|
||||
// 移动到首位
|
||||
dispatch("dialogMoveTop", dialog_id);
|
||||
dispatch("moveDialogTop", dialog_id);
|
||||
}
|
||||
// 新增任务消息数量
|
||||
dispatch("increaseTaskMsgNum", dialog_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user