Skip to content

Commit 3323939

Browse files
committed
Add field descriptions && Remove unnecessary logic && Update README
1 parent 25a4b12 commit 3323939

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ in at least 2 of Qiniu's internal systems.
177177
* [x] 图文消息
178178
* [x] 图文消息(mpnews)
179179
* [x] markdown消息
180+
* [x] 任务卡片消息
180181

181182
</details>
182183

message.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package workwx
22

33
import (
4-
"encoding/json"
54
"errors"
65
)
76

@@ -198,15 +197,6 @@ func (c *WorkwxApp) SendTaskCardMessage(
198197
btn []TaskCardBtn,
199198
isSafe bool,
200199
) error {
201-
btnByte, err := json.Marshal(btn)
202-
if err != nil {
203-
return errors.New("btn convert to json fail: " + err.Error())
204-
}
205-
var btnSlice []map[string]interface{}
206-
err = json.Unmarshal(btnByte, &btnSlice)
207-
if err != nil {
208-
return errors.New("btn convert to []map fail: " + err.Error())
209-
}
210200
return c.sendMessage(
211201
recipient,
212202
"taskcard",
@@ -215,7 +205,7 @@ func (c *WorkwxApp) SendTaskCardMessage(
215205
"description": description,
216206
"url": url,
217207
"task_id": taskid,
218-
"btn": btnSlice,
208+
"btn": btn,
219209
}, isSafe,
220210
)
221211
}

models.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,14 @@ type respOAGetApprovalDetail struct {
941941

942942
// TaskCardBtn 任务卡片消息按钮
943943
type TaskCardBtn struct {
944-
Key string `json:"key"`
945-
Name string `json:"name"`
944+
// Key 按钮key值,用户点击后,会产生任务卡片回调事件,回调事件会带上该key值,只能由数字、字母和“_-@”组成,最长支持128字节
945+
Key string `json:"key"`
946+
// Name 按钮名称
947+
Name string `json:"name"`
948+
// ReplaceName 点击按钮后显示的名称,默认为“已处理”
946949
ReplaceName string `json:"replace_name"`
947-
Color string `json:"color"`
948-
IsBold bool `json:"is_bold"`
950+
// Color 按钮字体颜色,可选“red”或者“blue”,默认为“blue”
951+
Color string `json:"color"`
952+
// IsBold 按钮字体是否加粗,默认false
953+
IsBold bool `json:"is_bold"`
949954
}

0 commit comments

Comments
 (0)