Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaowei
dlink
Commits
19a0ae6a
Commit
19a0ae6a
authored
Apr 06, 2022
by
zhu-mingye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixbug feishu alert when choose
@all
sendMsg failed
parent
2f47610f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
25 deletions
+16
-25
FeiShuSender.java
...hu/src/main/java/com.dlink.alert.feishu/FeiShuSender.java
+16
-25
No files found.
dlink-alert/dlink-alert-feishu/src/main/java/com.dlink.alert.feishu/FeiShuSender.java
View file @
19a0ae6a
...
...
@@ -72,7 +72,7 @@ public final class FeiShuSender {
String
jsonResult
=
""
;
byte
[]
byt
=
StringUtils
.
getBytesUtf8
(
formatContent
(
alertMsg
));
String
contentResult
=
StringUtils
.
newStringUtf8
(
byt
);
String
userIdsToText
=
mkUserIds
ToText
(
atUserIds
);
String
userIdsToText
=
mkUserIds
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isBlank
(
atUserIds
)?
"all"
:
atUserIds
);
if
(
StringUtils
.
equals
(
ShowType
.
TEXT
.
getValue
(),
msgType
))
{
jsonResult
=
FeiShuConstants
.
FEI_SHU_TEXT_TEMPLATE
.
replace
(
MSG_TYPE_REGX
,
msgType
)
.
replace
(
MSG_RESULT_REGX
,
contentResult
).
replace
(
FEI_SHU_USER_REGX
,
userIdsToText
).
replaceAll
(
"/n"
,
"\\\\n"
);
...
...
@@ -84,33 +84,24 @@ public final class FeiShuSender {
return
jsonResult
;
}
private
String
mkUserIds
ToText
(
String
users
){
private
String
mkUserIds
(
String
users
){
String
userIdsToText
=
""
;
String
[]
userList
=
users
.
split
(
","
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isEmpty
(
users
)
&&
Boolean
.
TRUE
.
equals
(
atAll
))
{
if
(
msgType
.
equals
(
ShowType
.
TEXT
.
getValue
()))
{
userIdsToText
=
"<at user_id=\\\"all\\\">所有人</at>"
;
}
else
{
userIdsToText
=
"{\"tag\":\"at\",\"user_id\":\"all\",\"user_name\":\"所有人\"}"
;
}
}
else
{
if
(
msgType
.
equals
(
ShowType
.
TEXT
.
getValue
()))
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
user
:
userList
)
{
sb
.
append
(
"<at user_id=\\\""
).
append
(
user
).
append
(
"\\\"></at>"
);
}
userIdsToText
=
sb
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
user
:
userList
)
{
sb
.
append
(
"{\"tag\":\"at\",\"user_id\":\""
).
append
(
user
).
append
(
"\"},"
);
}
sb
.
deleteCharAt
(
sb
.
length
()-
1
);
userIdsToText
=
sb
.
toString
();
}
if
(
msgType
.
equals
(
ShowType
.
TEXT
.
getValue
()))
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
user
:
userList
)
{
sb
.
append
(
"<at user_id=\\\""
).
append
(
user
).
append
(
"\\\"></at>"
);
}
return
userIdsToText
;
userIdsToText
=
sb
.
toString
();
}
else
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
user
:
userList
)
{
sb
.
append
(
"{\"tag\":\"at\",\"user_id\":\""
).
append
(
user
).
append
(
"\"},"
);
}
sb
.
deleteCharAt
(
sb
.
length
()-
1
);
userIdsToText
=
sb
.
toString
();
}
return
userIdsToText
;
}
public
static
AlertResult
checkSendFeiShuSendMsgResult
(
String
result
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment