mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-12 08:58:11 +00:00
消息转发功能
This commit is contained in:
parent
a2dcd69efd
commit
c08240db42
@ -650,6 +650,35 @@ class DialogController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/forward 13. 转发消息给
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName msg__forward
|
||||
*
|
||||
* @apiParam {Number} msg_id 消息ID
|
||||
* @apiParam {Array} userids 转发给的成员
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function msg__forward()
|
||||
{
|
||||
$user = User::auth();
|
||||
//
|
||||
$msg_id = intval(Request::input("msg_id"));
|
||||
$userids = Request::input('userids');
|
||||
//
|
||||
$msg = WebSocketDialogMsg::whereId($msg_id)->whereUserid($user->userid)->first();
|
||||
if (empty($msg)) {
|
||||
return Base::retError("消息不存在或已被删除");
|
||||
}
|
||||
return $msg->forwardMsg($userids, $user->userid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/group/add 16. 新增群组
|
||||
*
|
||||
|
||||
@ -161,6 +161,34 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转发消息
|
||||
* @param $userids
|
||||
* @param int $sender 发送的会员ID
|
||||
* @return mixed
|
||||
*/
|
||||
public function forwardMsg($userids, $sender)
|
||||
{
|
||||
return AbstractModel::transaction(function() use ($sender, $userids) {
|
||||
$msgs = [];
|
||||
foreach ($userids as $userid) {
|
||||
if (!User::whereUserid($userid)->exists()) {
|
||||
continue;
|
||||
}
|
||||
$dialog = WebSocketDialog::checkUserDialog($sender, $userid);
|
||||
if ($dialog) {
|
||||
$res = self::sendMsg($dialog->id, $this->type, $this->getOriginal('msg'), $sender);
|
||||
if (Base::isSuccess($res)) {
|
||||
$msgs[] = $res['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return Base::retSuccess('转发成功', [
|
||||
'msgs' => $msgs
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除消息
|
||||
* @return void
|
||||
|
||||
@ -185,6 +185,22 @@
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<!-- 转发 -->
|
||||
<Modal
|
||||
v-model="forwardShow"
|
||||
:title="$L('转发')"
|
||||
:mask-closable="false">
|
||||
<Form ref="forwardForm" :model="forwardData" label-width="auto" @submit.native.prevent>
|
||||
<FormItem prop="userids" :label="$L('转发给')">
|
||||
<UserInput v-model="forwardData.userids" :multiple-max="20" :placeholder="$L('选择转发成员')"/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer" class="adaption">
|
||||
<Button type="default" @click="forwardShow=false">{{$L('取消')}}</Button>
|
||||
<Button type="primary" :loading="forwardLoad" @click="onForward('submit')">{{$L('转发')}}</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<!--群设置-->
|
||||
<DrawerOverlay
|
||||
v-model="groupInfoShow"
|
||||
@ -252,6 +268,12 @@ export default {
|
||||
createGroupData: {},
|
||||
createGroupLoad: 0,
|
||||
|
||||
forwardShow: false,
|
||||
forwardLoad: false,
|
||||
forwardData: {
|
||||
userids: [],
|
||||
},
|
||||
|
||||
dialogDrag: false,
|
||||
groupInfoShow: false,
|
||||
|
||||
@ -711,6 +733,31 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
onForward(type) {
|
||||
if (type === 'open') {
|
||||
this.forwardData = {
|
||||
userids: [],
|
||||
msg_id: this.operateItem.id
|
||||
};
|
||||
this.forwardShow = true;
|
||||
} else if (type === 'submit') {
|
||||
this.forwardLoad = true;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/msg/forward',
|
||||
data: this.forwardData
|
||||
}).then(({data, msg}) => {
|
||||
this.forwardShow = false;
|
||||
this.$store.dispatch("saveDialogMsg", data.msgs);
|
||||
this.$store.dispatch("updateDialogLastMsg", data.msgs);
|
||||
$A.messageSuccess(msg);
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
}).finally(_ => {
|
||||
this.forwardLoad = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
scrollInfo() {
|
||||
if (!this.isReady) {
|
||||
return {
|
||||
@ -769,7 +816,7 @@ export default {
|
||||
onOperate(name) {
|
||||
switch (name) {
|
||||
case "forward":
|
||||
// todo 转发功能
|
||||
this.onForward('open')
|
||||
break;
|
||||
|
||||
case "withdraw":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user