-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5240 from irwinsun/issue_notify_1.5
feat: 提供企业微信“蓝盾bot”,用于推送蓝盾相关信息 #3797 [1.5]
- Loading branch information
Showing
49 changed files
with
1,930 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,6 @@ enum class NotifyType { | |
RTX, | ||
EMAIL, | ||
WECHAT, | ||
SMS | ||
SMS, | ||
WEWORK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/backend/ci/core/notify/biz-notify-wework/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. | ||
* | ||
* A copy of the MIT License is included in this file. | ||
* | ||
* | ||
* Terms of the MIT License: | ||
* --------------------------------------------------- | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
* the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | ||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
dependencies { | ||
implementation(project(":core:notify:api-notify")) | ||
implementation(project(":core:notify:biz-notify")) | ||
implementation(project(":core:notify:model-notify")) | ||
implementation(project(":core:common:common-db")) | ||
implementation(project(":core:common:common-notify")) | ||
} |
47 changes: 47 additions & 0 deletions
47
...ify-wework/src/main/kotlin/com/tencent/devops/notify/wework/config/WeworkConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.tencent.devops.notify.wework.config | ||
|
||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class WeworkConfiguration { | ||
|
||
@Value("\${wework.corpId:}") | ||
lateinit var corpId: String | ||
|
||
@Value("\${wework.corpSecret:}") | ||
lateinit var corpSecret: String | ||
|
||
@Value("\${wework.apiUrl:https://qyapi.weixin.qq.com}") | ||
lateinit var apiUrl: String | ||
|
||
@Value("\${wework.agentId:}") | ||
lateinit var agentId: String | ||
|
||
@Value("\${wework.tempDirectory:}") | ||
lateinit var tempDirectory: String | ||
|
||
/** | ||
* 表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0 | ||
*/ | ||
@Value("\${wework.safe:#{null}}") | ||
val safe: String? = null | ||
|
||
/** | ||
* 表示是否开启重复消息检查,0表示否,1表示是,默认0 | ||
*/ | ||
@Value("\${wework.enableDuplicateCheck:#{null}}") | ||
val enableDuplicateCheck: String? = null | ||
|
||
/** | ||
* 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时 | ||
*/ | ||
@Value("\${wework.duplicateCheckInterval:#{null}}") | ||
val duplicateCheckInterval: String? = null | ||
|
||
/** | ||
* 表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。 | ||
*/ | ||
@Value("\${wework.enableIdTrans:#{null}}") | ||
val enableIdTrans: String? = null | ||
} |
75 changes: 75 additions & 0 deletions
75
...ework/src/main/kotlin/com/tencent/devops/notify/wework/pojo/AbstractSendMessageRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.tencent.devops.notify.wework.pojo | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
@Suppress("UnnecessaryAbstractClass") | ||
abstract class AbstractSendMessageRequest( | ||
/** | ||
* 企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值 | ||
*/ | ||
@JsonProperty("agentid") | ||
@get:JsonProperty("agentid") | ||
open val agentId: Int, | ||
@JsonProperty("duplicate_check_interval") | ||
/** | ||
* 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时 | ||
*/ | ||
open val duplicateCheckInterval: Int? = null, | ||
/** | ||
* 表示是否开启重复消息检查,0表示否,1表示是,默认0 | ||
*/ | ||
@JsonProperty("enable_duplicate_check") | ||
@get:JsonProperty("enable_duplicate_check") | ||
open val enableDuplicateCheck: Int? = null, | ||
@JsonProperty("msgtype") | ||
@get:JsonProperty("msgtype") | ||
open val msgType: String, | ||
/** | ||
* 表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0 | ||
*/ | ||
@JsonProperty("safe") | ||
@get:JsonProperty("safe") | ||
open val safe: Int? = null, | ||
/** | ||
* 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。 | ||
* 当touser为”@all”时忽略本参数 | ||
*/ | ||
@JsonProperty("toparty") | ||
@get:JsonProperty("toparty") | ||
open val toParty: String = "", | ||
/** | ||
* 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。 | ||
* 当touser为”@all”时忽略本参数 | ||
*/ | ||
@JsonProperty("totag") | ||
@get:JsonProperty("totag") | ||
open val toTag: String = "", | ||
/** | ||
* 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。 | ||
* 特殊情况:指定为”@all”,则向该企业应用的全部成员发送 | ||
*/ | ||
@JsonProperty("touser") | ||
@get:JsonProperty("touser") | ||
open val toUser: String = "" | ||
) { | ||
data class MediaMessageContent( | ||
/** | ||
* 媒体文件id,可以调用上传临时素材接口获取 | ||
*/ | ||
@JsonProperty("media_id") | ||
@get:JsonProperty("media_id") | ||
val mediaId: String, | ||
/** | ||
* 视频消息的标题,不超过128个字节,超过会自动截断,视频才有 | ||
*/ | ||
@JsonProperty("description") | ||
@get:JsonProperty("description") | ||
var description: String? = null, | ||
/** | ||
* 视频消息的描述,不超过512个字节,超过会自动截断,视频才有 | ||
*/ | ||
@JsonProperty("title") | ||
@get:JsonProperty("title") | ||
var title: String? = null | ||
) | ||
} |
18 changes: 18 additions & 0 deletions
18
...iz-notify-wework/src/main/kotlin/com/tencent/devops/notify/wework/pojo/AccessTokenResp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.tencent.devops.notify.wework.pojo | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
data class AccessTokenResp( | ||
@JsonProperty("access_token") | ||
val accessToken: String?, | ||
@JsonProperty("errcode") | ||
val errCode: Int?, | ||
@JsonProperty("errmsg") | ||
val errMsg: String?, | ||
@JsonProperty("expires_in") | ||
val expiresIn: Int? | ||
) { | ||
fun isOk(): Boolean { | ||
return errCode == 0 && accessToken != null | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...fy-wework/src/main/kotlin/com/tencent/devops/notify/wework/pojo/FileSendMessageRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.tencent.devops.notify.wework.pojo | ||
|
||
data class FileSendMessageRequest( | ||
override val agentId: Int, | ||
override val duplicateCheckInterval: Int?, | ||
override val enableDuplicateCheck: Int?, | ||
override val safe: Int?, | ||
override val toParty: String, | ||
override val toTag: String, | ||
override val toUser: String, | ||
val file: MediaMessageContent | ||
) : AbstractSendMessageRequest( | ||
agentId = agentId, | ||
duplicateCheckInterval = duplicateCheckInterval, | ||
enableDuplicateCheck = enableDuplicateCheck, | ||
msgType = "file", | ||
safe = safe, | ||
toParty = toParty, | ||
toTag = toTag, | ||
toUser = toUser | ||
) |
21 changes: 21 additions & 0 deletions
21
...y-wework/src/main/kotlin/com/tencent/devops/notify/wework/pojo/ImageSendMessageRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.tencent.devops.notify.wework.pojo | ||
|
||
data class ImageSendMessageRequest( | ||
override val agentId: Int, | ||
override val duplicateCheckInterval: Int?, | ||
override val enableDuplicateCheck: Int?, | ||
override val safe: Int?, | ||
override val toParty: String, | ||
override val toTag: String, | ||
override val toUser: String, | ||
val image: MediaMessageContent | ||
) : AbstractSendMessageRequest( | ||
agentId = agentId, | ||
duplicateCheckInterval = duplicateCheckInterval, | ||
enableDuplicateCheck = enableDuplicateCheck, | ||
msgType = "image", | ||
safe = safe, | ||
toParty = toParty, | ||
toTag = toTag, | ||
toUser = toUser | ||
) |
21 changes: 21 additions & 0 deletions
21
...ework/src/main/kotlin/com/tencent/devops/notify/wework/pojo/MarkdownSendMessageRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.tencent.devops.notify.wework.pojo | ||
|
||
data class MarkdownSendMessageRequest( | ||
override val agentId: Int, | ||
override val duplicateCheckInterval: Int?, | ||
override val enableDuplicateCheck: Int?, | ||
override val safe: Int?, | ||
override val toParty: String, | ||
override val toTag: String, | ||
override val toUser: String, | ||
val markdown: TextMessageContent | ||
) : AbstractSendMessageRequest( | ||
agentId = agentId, | ||
duplicateCheckInterval = duplicateCheckInterval, | ||
enableDuplicateCheck = enableDuplicateCheck, | ||
msgType = "markdown", | ||
safe = safe, | ||
toParty = toParty, | ||
toTag = toTag, | ||
toUser = toUser | ||
) |
16 changes: 16 additions & 0 deletions
16
...iz-notify-wework/src/main/kotlin/com/tencent/devops/notify/wework/pojo/SendMessageResp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tencent.devops.notify.wework.pojo | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
data class SendMessageResp( | ||
@JsonProperty("errcode") | ||
val errCode: Int?, | ||
@JsonProperty("errmsg") | ||
val errMsg: String?, | ||
@JsonProperty("invalidparty") | ||
val invalidParty: String?, | ||
@JsonProperty("invalidtag") | ||
val invalidTag: String?, | ||
@JsonProperty("invaliduser") | ||
val invalidUser: String? | ||
) |
Oops, something went wrong.