新增:企微应用消息允许指定部门指定标签

This commit is contained in:
pppscn 2022-08-08 11:49:55 +08:00
parent dd966fd4b7
commit 432bbeaa16
6 changed files with 118 additions and 6 deletions

View File

@ -10,6 +10,8 @@ data class WeworkAgentSetting(
val secret: String = "",
val atAll: Boolean? = false,
val toUser: String? = "@all",
val toParty: String? = "",
val toTag: String? = "",
val proxyType: Proxy.Type = Proxy.Type.DIRECT,
val proxyHost: String? = "",
val proxyPort: String? = "",

View File

@ -129,6 +129,11 @@ class WeworkAgentFragment : BaseFragment<FragmentSendersWeworkAgentBinding?>(),
binding!!.etSecret.setText(settingVo.secret)
binding!!.sbAtAll.isChecked = settingVo.atAll == true
binding!!.etToUser.setText(settingVo.toUser)
binding!!.etToParty.setText(settingVo.toParty)
binding!!.etToTag.setText(settingVo.toTag)
binding!!.layoutToUser.visibility = if (settingVo.atAll == true) View.GONE else View.VISIBLE
binding!!.layoutToParty.visibility = if (settingVo.atAll == true) View.GONE else View.VISIBLE
binding!!.layoutToTag.visibility = if (settingVo.atAll == true) View.GONE else View.VISIBLE
binding!!.rgProxyType.check(settingVo.getProxyTypeCheckId())
binding!!.etProxyHost.setText(settingVo.proxyHost)
binding!!.etProxyPort.setText(settingVo.proxyPort)
@ -166,10 +171,18 @@ class WeworkAgentFragment : BaseFragment<FragmentSendersWeworkAgentBinding?>(),
R.id.sb_at_all -> {
if (isChecked) {
binding!!.etToUser.setText("@all")
binding!!.etToParty.setText("")
binding!!.etToTag.setText("")
binding!!.layoutToUser.visibility = View.GONE
binding!!.layoutToParty.visibility = View.GONE
binding!!.layoutToTag.visibility = View.GONE
} else {
binding!!.etToUser.setText("")
binding!!.etToParty.setText("")
binding!!.etToTag.setText("")
binding!!.layoutToUser.visibility = View.VISIBLE
binding!!.layoutToParty.visibility = View.VISIBLE
binding!!.layoutToTag.visibility = View.VISIBLE
}
}
R.id.sb_proxyAuthenticator -> {
@ -254,7 +267,9 @@ class WeworkAgentFragment : BaseFragment<FragmentSendersWeworkAgentBinding?>(),
val atAll = binding!!.sbAtAll.isChecked
val toUser = binding!!.etToUser.text.toString().trim()
if (!atAll && TextUtils.isEmpty(toUser)) {
val toParty = binding!!.etToParty.text.toString().trim()
val toTag = binding!!.etToTag.text.toString().trim()
if (!atAll && TextUtils.isEmpty(toUser) && TextUtils.isEmpty(toParty) && TextUtils.isEmpty(toTag)) {
throw Exception(getString(R.string.invalid_at_mobiles))
}
@ -277,7 +292,7 @@ class WeworkAgentFragment : BaseFragment<FragmentSendersWeworkAgentBinding?>(),
throw Exception(getString(R.string.invalid_username_or_password))
}
return WeworkAgentSetting(corpID, agentID, secret, atAll, toUser, proxyType, proxyHost, proxyPort, proxyAuthenticator, proxyUsername, proxyPassword)
return WeworkAgentSetting(corpID, agentID, secret, atAll, toUser, toParty, toTag, proxyType, proxyHost, proxyPort, proxyAuthenticator, proxyUsername, proxyPassword)
}
override fun onDestroyView() {

View File

@ -135,6 +135,8 @@ class WeworkAgentUtils private constructor() {
val textMsgMap: MutableMap<String, Any> = mutableMapOf()
textMsgMap["touser"] = setting.toUser.toString()
textMsgMap["toparty"] = setting.toParty.toString()
textMsgMap["totag"] = setting.toTag.toString()
textMsgMap["msgtype"] = "text"
textMsgMap["agentid"] = setting.agentID
val textText: MutableMap<String, Any> = mutableMapOf()

View File

@ -160,7 +160,7 @@
android:layout_width="70dp"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/specified_member"
android:text="@string/touser"
android:textStyle="bold" />
<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
@ -178,7 +178,88 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/specified_member_tips"
android:text="@string/touser_tips"
android:textSize="10sp"
tools:ignore="SmallSp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_toParty"
style="@style/senderBarStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="70dp"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/toparty"
android:textStyle="bold" />
<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
android:id="@+id/et_toParty"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:singleLine="true"
app:met_clearButton="true" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/toparty_tips"
android:textSize="10sp"
tools:ignore="SmallSp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_toTag"
style="@style/senderBarStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="70dp"
android:layout_height="wrap_content"
android:gravity="end"
android:text="@string/totag"
android:textStyle="bold" />
<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
android:id="@+id/et_toTag"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:singleLine="true"
app:met_clearButton="true" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/totag_tips"
android:textSize="10sp"
tools:ignore="SmallSp" />

View File

@ -284,7 +284,7 @@
<string name="invalid_openid">Multiple openids are separated by ,</string>
<string name="invalid_webserver">WebServer is empty or not a valid URL</string>
<string name="invalid_webhook">WebHook is empty or not a valid URL</string>
<string name="invalid_at_mobiles">Specified member cannot be empty or select @all</string>
<string name="invalid_at_mobiles">toUser/toParty/toTag cannot be empty or select @all</string>
<string name="invalid_wework_agent">CoreID, AgentID, and Secret cannot be empty</string>
<string name="invalid_dingtalk_inner_robot">AgentId, AppKey, AppSecret, and UserIds cannot be empty</string>
<string name="invalid_phone_num">The receiving phone number cannot be empty</string>
@ -315,6 +315,12 @@
<string name="specified_member">Specified Member</string>
<string name="at_all">\@all</string>
<string name="specified_member_tips">Tip: List of member IDs that receive messages (multiple recipients are separated by \'|\', up to 1000)</string>
<string name="touser">To User</string>
<string name="toparty">To Party</string>
<string name="totag">To Tag</string>
<string name="touser_tips">Tip: List of member IDs that receive messages (multiple recipients are separated by \'|\', up to 1000)</string>
<string name="toparty_tips">Tip: List of party IDs that receive messages (multiple recipients are separated by \'|\', up to 1000)</string>
<string name="totag_tips">Tip: List of tag IDs that receive messages (multiple recipients are separated by \'|\', up to 1000)</string>
<string name="specified_member_tips2">Tip: The userid of the user who receives the message, up to 20 at a time (separated by \'|\')</string>
<string name="server_chan_send_key">SendKey</string>
<string name="server_chan_channel">Message Channel</string>

View File

@ -285,7 +285,7 @@
<string name="invalid_openid">多个 openid 用 , 隔开</string>
<string name="invalid_webserver">WebServer为空 或 不是有效URL</string>
<string name="invalid_webhook">WebHook为空 或 不是有效URL</string>
<string name="invalid_at_mobiles">指定成员 不能为空 或者 选择@all</string>
<string name="invalid_at_mobiles">指定成员/指定部门/指定标签 不能为空 或者 选择@all</string>
<string name="invalid_wework_agent">企业ID、AgentID、Secret都不能为空</string>
<string name="invalid_dingtalk_inner_robot">AgentId、AppKey、AppSecret、UserIds都不能为空</string>
<string name="invalid_phone_num">接收手机号不能为空</string>
@ -316,6 +316,12 @@
<string name="specified_member">指定成员</string>
<string name="at_all">\@all</string>
<string name="specified_member_tips">Tip接收消息的成员ID列表多个接收者用|分隔最多支持1000个</string>
<string name="touser">指定成员</string>
<string name="toparty">指定部门</string>
<string name="totag">指定标签</string>
<string name="touser_tips">Tip接收消息的成员ID列表多个接收者用|分隔最多支持1000个</string>
<string name="toparty_tips">Tip接收消息的部门ID列表多个接收者用|分隔最多支持1000个</string>
<string name="totag_tips">Tip接收消息的标签ID列表多个接收者用|分隔最多支持1000个</string>
<string name="specified_member_tips2">Tip接收用户的userid每次最多传20个|’分隔)</string>
<string name="server_chan_send_key">SendKey</string>
<string name="server_chan_channel">消息通道</string>