mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-09 19:10:51 +00:00
优化:企业微信应用
发送通道允许自定义API地址【通过反向代理(proxy_pass)绕过IP白名单限制】 #352
This commit is contained in:
parent
87f7ee9c13
commit
8eeb2b1cc2
@ -18,6 +18,7 @@ data class WeworkAgentSetting(
|
||||
val proxyAuthenticator: Boolean? = false,
|
||||
val proxyUsername: String? = "",
|
||||
val proxyPassword: String? = "",
|
||||
val customizeAPI: String = "https://qyapi.weixin.qq.com/cgi-bin",
|
||||
) : Serializable {
|
||||
|
||||
fun getProxyTypeCheckId(): Int {
|
||||
|
@ -140,6 +140,7 @@ class WeworkAgentFragment : BaseFragment<FragmentSendersWeworkAgentBinding?>(),
|
||||
binding!!.sbProxyAuthenticator.isChecked = settingVo.proxyAuthenticator == true
|
||||
binding!!.etProxyUsername.setText(settingVo.proxyUsername)
|
||||
binding!!.etProxyPassword.setText(settingVo.proxyPassword)
|
||||
binding!!.etCustomizeAPI.setText(settingVo.customizeAPI)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -293,7 +294,12 @@ class WeworkAgentFragment : BaseFragment<FragmentSendersWeworkAgentBinding?>(),
|
||||
throw Exception(getString(R.string.invalid_username_or_password))
|
||||
}
|
||||
|
||||
return WeworkAgentSetting(corpID, agentID, secret, atAll, toUser, toParty, toTag, proxyType, proxyHost, proxyPort, proxyAuthenticator, proxyUsername, proxyPassword)
|
||||
val customizeAPI = binding!!.etCustomizeAPI.text.toString().trim()
|
||||
if (!CommonUtils.checkUrl(customizeAPI, true)) {
|
||||
throw Exception(getString(R.string.invalid_customize_api))
|
||||
}
|
||||
|
||||
return WeworkAgentSetting(corpID, agentID, secret, atAll, toUser, toParty, toTag, proxyType, proxyHost, proxyPort, proxyAuthenticator, proxyUsername, proxyPassword, customizeAPI)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -26,6 +26,7 @@ import java.net.InetSocketAddress
|
||||
import java.net.PasswordAuthentication
|
||||
import java.net.Proxy
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
class WeworkAgentUtils private constructor() {
|
||||
companion object {
|
||||
|
||||
@ -46,7 +47,8 @@ class WeworkAgentUtils private constructor() {
|
||||
return sendTextMsg(setting, msgInfo, rule, senderIndex, logId, msgId)
|
||||
}
|
||||
|
||||
var getTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?"
|
||||
val customApi = if (TextUtils.isEmpty(setting.customizeAPI)) "https://qyapi.weixin.qq.com/cgi-bin" else setting.customizeAPI
|
||||
var getTokenUrl = "$customApi/gettoken?"
|
||||
getTokenUrl += "corpid=" + setting.corpID
|
||||
getTokenUrl += "&corpsecret=" + setting.secret
|
||||
Log.d(TAG, "getTokenUrl:$getTokenUrl")
|
||||
@ -139,7 +141,8 @@ class WeworkAgentUtils private constructor() {
|
||||
textText["content"] = content
|
||||
textMsgMap["text"] = textText
|
||||
val accessToken: String by SharedPreference("access_token_" + setting.agentID, "")
|
||||
val requestUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$accessToken"
|
||||
val customApi = if (TextUtils.isEmpty(setting.customizeAPI)) "https://qyapi.weixin.qq.com/cgi-bin" else setting.customizeAPI
|
||||
val requestUrl = "$customApi/message/send?access_token=$accessToken"
|
||||
Log.i(TAG, "requestUrl:$requestUrl")
|
||||
val requestMsg: String = Gson().toJson(textMsgMap)
|
||||
Log.i(TAG, "requestMsg:$requestMsg")
|
||||
|
@ -224,7 +224,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_toTag"
|
||||
style="@style/senderBarStyle"
|
||||
@ -412,6 +411,45 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
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/Customize_API"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText
|
||||
android:id="@+id/et_customizeAPI"
|
||||
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/customize_api_tips"
|
||||
android:textSize="10sp"
|
||||
tools:ignore="SmallSp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
@ -283,8 +283,9 @@
|
||||
<string name="invalid_sendkey">SendKey cannot be empty</string>
|
||||
<string name="invalid_channel">Up to two channels, multiple channel values separated by a vertical bar |</string>
|
||||
<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_customize_api">Customize API is invalid</string>
|
||||
<string name="invalid_webserver">WebServer is empty or invalid</string>
|
||||
<string name="invalid_webhook">WebHook is empty or invalid</string>
|
||||
<string name="invalid_url_scheme">URL Scheme is empty or invalid</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>
|
||||
@ -310,6 +311,7 @@
|
||||
<string name="feishu_msg_type_text">Text</string>
|
||||
<string name="feishu_msg_type_interactive">Interactive</string>
|
||||
<string name="feishu_msg_type_interactive_title">Interactive Title</string>
|
||||
<string name="Customize_API">Customize API</string>
|
||||
<string name="Corp_ID">Corp ID</string>
|
||||
<string name="Agent_ID">Agent ID</string>
|
||||
<string name="App_Secret">App Secret</string>
|
||||
@ -323,6 +325,7 @@
|
||||
<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="customize_api_tips">Tip: Bypass IP whitelist restrictions using reverse proxy (proxy_pass).</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>
|
||||
|
@ -284,6 +284,7 @@
|
||||
<string name="invalid_sendkey">Server酱·Turbo版的 SendKey 不能为空</string>
|
||||
<string name="invalid_channel">最多两个通道,多个通道值用竖线|隔开</string>
|
||||
<string name="invalid_openid">多个 openid 用 , 隔开</string>
|
||||
<string name="invalid_customize_api">自定义API地址 不是有效URL</string>
|
||||
<string name="invalid_webserver">WebServer为空 或 不是有效URL</string>
|
||||
<string name="invalid_webhook">WebHook为空 或 不是有效URL</string>
|
||||
<string name="invalid_url_scheme">URL Scheme 为空 或 无效</string>
|
||||
@ -311,6 +312,7 @@
|
||||
<string name="feishu_msg_type_text">纯文本</string>
|
||||
<string name="feishu_msg_type_interactive">消息卡片</string>
|
||||
<string name="feishu_msg_type_interactive_title">标题模板</string>
|
||||
<string name="Customize_API">自定义API</string>
|
||||
<string name="Corp_ID">企业ID</string>
|
||||
<string name="Agent_ID">AgentId</string>
|
||||
<string name="App_Secret">Secret</string>
|
||||
@ -324,6 +326,7 @@
|
||||
<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="customize_api_tips">Tip:通过反向代理(proxy_pass)绕过IP白名单限制</string>
|
||||
<string name="specified_member_tips2">Tip:接收用户的userid,每次最多传20个(用‘|’分隔)</string>
|
||||
<string name="server_chan_send_key">SendKey</string>
|
||||
<string name="server_chan_channel">消息通道</string>
|
||||
|
Loading…
Reference in New Issue
Block a user