mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 04:40:37 +00:00
feat: 新增全员群组
This commit is contained in:
parent
e5cbeb032e
commit
fb74ef4843
@ -28,7 +28,7 @@ class SystemController extends AbstractController
|
||||
* @apiParam {String} type
|
||||
* - get: 获取(默认)
|
||||
* - all: 获取所有(需要管理员权限)
|
||||
* - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'start_home', 'home_footer'])
|
||||
* - save: 保存设置(参数:['reg', 'reg_invite', 'login_code', 'password_policy', 'project_invite', 'chat_nickname', 'auto_archived', 'archived_day', 'all_group_mute', 'start_home', 'home_footer'])
|
||||
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
@ -53,6 +53,7 @@ class SystemController extends AbstractController
|
||||
'chat_nickname',
|
||||
'auto_archived',
|
||||
'archived_day',
|
||||
'all_group_mute',
|
||||
'start_home',
|
||||
'home_footer'
|
||||
])) {
|
||||
@ -86,6 +87,7 @@ class SystemController extends AbstractController
|
||||
$setting['chat_nickname'] = $setting['chat_nickname'] ?: 'optional';
|
||||
$setting['auto_archived'] = $setting['auto_archived'] ?: 'close';
|
||||
$setting['archived_day'] = floatval($setting['archived_day']) ?: 7;
|
||||
$setting['all_group_mute'] = $setting['all_group_mute'] ?: 'open';
|
||||
$setting['start_home'] = $setting['start_home'] ?: 'close';
|
||||
//
|
||||
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
||||
|
||||
@ -666,7 +666,7 @@ class UsersController extends AbstractController
|
||||
}
|
||||
}
|
||||
if ($upArray) {
|
||||
AbstractModel::transaction(function() use ($type, $upArray, $userInfo, $transferUser) {
|
||||
AbstractModel::transaction(function() use ($user, $type, $upArray, $userInfo, $transferUser) {
|
||||
$userInfo->updateInstance($upArray);
|
||||
$userInfo->save();
|
||||
if ($type === 'setdisable') {
|
||||
@ -676,6 +676,13 @@ class UsersController extends AbstractController
|
||||
]);
|
||||
$userTransfer->save();
|
||||
$userTransfer->start();
|
||||
// 离职移出全员群组
|
||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||
$dialog?->exitGroup($userInfo->userid, 'remove');
|
||||
} elseif ($type === 'cleardisable') {
|
||||
// 取消离职重新加入全员群组
|
||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||
$dialog?->joinGroup($userInfo->userid, $user->userid);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -230,7 +230,11 @@ class User extends AbstractModel
|
||||
$user = User::createInstance($inArray);
|
||||
$user->az = Base::getFirstCharter($user->nickname);
|
||||
$user->pinyin = Base::cn2pinyin($user->nickname);
|
||||
$user->save();
|
||||
if ($user->save()) {
|
||||
// 加入全员群组
|
||||
$dialog = WebSocketDialog::whereGroupType('all')->orderByDesc('id')->first();
|
||||
$dialog?->joinGroup($user->userid, 0);
|
||||
}
|
||||
return $user->find($user->userid);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Exceptions\ApiException;
|
||||
use App\Module\Base;
|
||||
use App\Tasks\PushTask;
|
||||
use Carbon\Carbon;
|
||||
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
||||
@ -116,6 +117,9 @@ class WebSocketDialog extends AbstractModel
|
||||
$this->name = '[Delete]';
|
||||
$this->dialog_delete = 1;
|
||||
}
|
||||
} elseif ($this->group_type === 'all') {
|
||||
$this->name = Base::Lang('全体成员');
|
||||
$this->all_group_mute = Base::settingFind('system', 'all_group_mute');
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -249,6 +253,26 @@ class WebSocketDialog extends AbstractModel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查禁言
|
||||
* @param $userid
|
||||
* @return void
|
||||
*/
|
||||
public function checkMute($userid)
|
||||
{
|
||||
if ($this->group_type === 'all') {
|
||||
$allGroupMute = Base::settingFind('system', 'all_group_mute');
|
||||
switch ($allGroupMute) {
|
||||
case 'all':
|
||||
throw new ApiException('当前会话全员禁言');
|
||||
case 'user':
|
||||
if (!User::find($userid)?->isAdmin()) {
|
||||
throw new ApiException('当前会话禁言');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群组名称
|
||||
* @return mixed|string|null
|
||||
@ -350,7 +374,7 @@ class WebSocketDialog extends AbstractModel
|
||||
'name' => $name ?: '',
|
||||
'group_type' => $group_type,
|
||||
'owner_id' => $owner_id,
|
||||
'last_at' => $group_type === 'user' ? Carbon::now() : null,
|
||||
'last_at' => in_array($group_type, ['user', 'all']) ? Carbon::now() : null,
|
||||
]);
|
||||
$dialog->save();
|
||||
foreach (is_array($userid) ? $userid : [$userid] as $value) {
|
||||
@ -358,7 +382,7 @@ class WebSocketDialog extends AbstractModel
|
||||
WebSocketDialogUser::createInstance([
|
||||
'dialog_id' => $dialog->id,
|
||||
'userid' => $value,
|
||||
'important' => $group_type != 'user'
|
||||
'important' => !in_array($group_type, ['user', 'all'])
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,6 +553,7 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
if (empty($dialog)) {
|
||||
throw new ApiException('获取会话失败');
|
||||
}
|
||||
$dialog->checkMute($sender);
|
||||
//
|
||||
if ($update_id) {
|
||||
// 修改
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\WebSocketDialog;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class GenerateWebSocketDialogsAllGroup extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!WebSocketDialog::whereGroupType('all')->exists()) {
|
||||
$userids = User::whereNull('disable_at')->pluck('userid')->toArray();
|
||||
WebSocketDialog::createGroup(null, $userids, 'all');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="group-info-button">
|
||||
<div v-if="dialogData.group_type !== 'all'" class="group-info-button">
|
||||
<Button v-if="dialogData.owner_id == userId || dialogData.owner_id == 0" @click="openAdd" type="primary">{{ $L("添加成员") }}</Button>
|
||||
<Button v-if="dialogData.owner_id == userId" @click="onDisband" type="error" ghost>{{ $L("解散群组") }}</Button>
|
||||
<Button v-else @click="onExit" type="error" ghost>{{ $L("退出群组") }}</Button>
|
||||
@ -94,6 +94,7 @@ export default {
|
||||
if (group_type === 'project') return '项目群组'
|
||||
if (group_type === 'task') return '任务群组'
|
||||
if (group_type === 'user') return '个人群组'
|
||||
if (group_type === 'all') return '全员群组'
|
||||
return '未知'
|
||||
},
|
||||
|
||||
|
||||
@ -121,7 +121,11 @@
|
||||
@on-progress="chatFile('progress', $event)"
|
||||
@on-success="chatFile('success', $event)"
|
||||
@on-error="chatFile('error', $event)"/>
|
||||
<div v-if="isMute" class="chat-mute">
|
||||
{{$L('禁言发言')}}
|
||||
</div>
|
||||
<ChatInput
|
||||
v-else
|
||||
ref="input"
|
||||
v-model="msgText"
|
||||
:dialog-id="dialogId"
|
||||
@ -401,6 +405,7 @@ export default {
|
||||
|
||||
computed: {
|
||||
...mapState([
|
||||
'userIsAdmin',
|
||||
'taskId',
|
||||
'dialogSearchMsgId',
|
||||
'dialogMsgs',
|
||||
@ -553,6 +558,19 @@ export default {
|
||||
return dialogData.dialog_user && dialogData.dialog_user.userid == userId
|
||||
},
|
||||
|
||||
isMute() {
|
||||
if (this.dialogData.group_type === 'all') {
|
||||
if (this.dialogData.all_group_mute === 'all') {
|
||||
return true
|
||||
} else if (this.dialogData.all_group_mute === 'user') {
|
||||
if (!this.userIsAdmin) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
|
||||
replyId() {
|
||||
return parseInt(this.msgId > 0 ? this.msgId : this.replyActiveId)
|
||||
},
|
||||
@ -914,7 +932,7 @@ export default {
|
||||
|
||||
inputFocus() {
|
||||
this.$nextTick(_ => {
|
||||
this.$refs.input.focus()
|
||||
this.$refs.input && this.$refs.input.focus()
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@ -61,6 +61,16 @@
|
||||
<div slot="content">{{$L('任务完成 % 天后自动归档。', formDatum.archived_day)}}</div>
|
||||
</ETooltip>
|
||||
</FormItem>
|
||||
<FormItem :label="$L('全员群组禁言')" prop="disabledAllGroup">
|
||||
<RadioGroup v-model="formDatum.all_group_mute">
|
||||
<Radio label="open">{{$L('开放')}}</Radio>
|
||||
<Radio label="user">{{$L('成员禁言')}}</Radio>
|
||||
<Radio label="all">{{$L('全部禁言')}}</Radio>
|
||||
</RadioGroup>
|
||||
<div v-if="formDatum.all_group_mute == 'open'" class="form-tip">{{$L('开放:所有人都可以发言。')}}</div>
|
||||
<div v-else-if="formDatum.all_group_mute == 'user'" class="form-tip">{{$L('成员禁言:仅管理员可以发言。')}}</div>
|
||||
<div v-else-if="formDatum.all_group_mute == 'all'" class="form-tip">{{$L('全部禁言:所有人都禁止发言。')}}</div>
|
||||
</FormItem>
|
||||
<FormItem :label="$L('是否启动首页')" prop="startHome">
|
||||
<RadioGroup v-model="formDatum.start_home">
|
||||
<Radio label="open">{{$L('开启')}}</Radio>
|
||||
|
||||
@ -982,6 +982,14 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-mute {
|
||||
color: $primary-desc-color;
|
||||
background-color: #F4F5F7;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.chat-input-box {
|
||||
.chat-input-wrapper {
|
||||
background-color: #F4F5F7;
|
||||
@ -1362,6 +1370,9 @@
|
||||
background-color: #f8f8f8;
|
||||
padding: 8px 10px;
|
||||
margin-bottom: 0;
|
||||
.chat-mute {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.chat-input-box {
|
||||
.chat-input-wrapper {
|
||||
background-color: #ffffff;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user