Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
a16d9282
Unverified
Commit
a16d9282
authored
Apr 06, 2022
by
aiwenmo
Committed by
GitHub
Apr 06, 2022
Browse files
Options
Browse Files
Download
Plain Diff
[fix-350][alert] feishu alert when choose
@all
sendMsg failed bug
[fix-350][alert] feishu alert when choose
@all
sendMsg failed bug
parents
2f47610f
19a0ae6a
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 @
a16d9282
...
@@ -72,7 +72,7 @@ public final class FeiShuSender {
...
@@ -72,7 +72,7 @@ public final class FeiShuSender {
String
jsonResult
=
""
;
String
jsonResult
=
""
;
byte
[]
byt
=
StringUtils
.
getBytesUtf8
(
formatContent
(
alertMsg
));
byte
[]
byt
=
StringUtils
.
getBytesUtf8
(
formatContent
(
alertMsg
));
String
contentResult
=
StringUtils
.
newStringUtf8
(
byt
);
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
))
{
if
(
StringUtils
.
equals
(
ShowType
.
TEXT
.
getValue
(),
msgType
))
{
jsonResult
=
FeiShuConstants
.
FEI_SHU_TEXT_TEMPLATE
.
replace
(
MSG_TYPE_REGX
,
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"
);
.
replace
(
MSG_RESULT_REGX
,
contentResult
).
replace
(
FEI_SHU_USER_REGX
,
userIdsToText
).
replaceAll
(
"/n"
,
"\\\\n"
);
...
@@ -84,33 +84,24 @@ public final class FeiShuSender {
...
@@ -84,33 +84,24 @@ public final class FeiShuSender {
return
jsonResult
;
return
jsonResult
;
}
}
private
String
mkUserIds
ToText
(
String
users
){
private
String
mkUserIds
(
String
users
){
String
userIdsToText
=
""
;
String
userIdsToText
=
""
;
String
[]
userList
=
users
.
split
(
","
);
String
[]
userList
=
users
.
split
(
","
);
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isEmpty
(
users
)
&&
Boolean
.
TRUE
.
equals
(
atAll
))
{
if
(
msgType
.
equals
(
ShowType
.
TEXT
.
getValue
()))
{
if
(
msgType
.
equals
(
ShowType
.
TEXT
.
getValue
()))
{
StringBuilder
sb
=
new
StringBuilder
();
userIdsToText
=
"<at user_id=\\\"all\\\">所有人</at>"
;
for
(
String
user
:
userList
)
{
}
else
{
sb
.
append
(
"<at user_id=\\\""
).
append
(
user
).
append
(
"\\\"></at>"
);
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
();
}
}
}
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
)
{
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