Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
c71264ab
N
nightingale
项目概览
DiDi
/
nightingale
10 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c71264ab
编写于
4月 19, 2021
作者:
7
710leo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix send message
上级
8f1fd17f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
6 deletion
+12
-6
src/modules/server/notify/notify.go
src/modules/server/notify/notify.go
+12
-6
未找到文件。
src/modules/server/notify/notify.go
浏览文件 @
c71264ab
...
...
@@ -54,6 +54,7 @@ func DoNotify(isUpgrade bool, events ...*models.Event) {
notifyTypes
:=
config
.
Config
.
Monapi
.
Notify
[
prio
]
for
i
:=
0
;
i
<
len
(
notifyTypes
);
i
++
{
var
err
error
switch
notifyTypes
[
i
]
{
case
"voice"
:
if
events
[
0
]
.
EventType
==
models
.
ALERT
{
...
...
@@ -62,34 +63,36 @@ func DoNotify(isUpgrade bool, events ...*models.Event) {
tos
=
append
(
tos
,
users
[
j
]
.
Phone
)
}
send
(
slice
.
Set
(
tos
),
events
[
0
]
.
Sname
,
""
,
"voice"
)
err
=
send
(
slice
.
Set
(
tos
),
events
[
0
]
.
Sname
,
""
,
"voice"
)
}
case
"sms"
:
tos
:=
[]
string
{}
for
j
:=
0
;
j
<
len
(
users
);
j
++
{
tos
=
append
(
tos
,
users
[
j
]
.
Phone
)
}
send
(
slice
.
Set
(
tos
),
content
,
""
,
"sms"
)
err
=
send
(
slice
.
Set
(
tos
),
content
,
""
,
"sms"
)
case
"mail"
:
tos
:=
[]
string
{}
for
j
:=
0
;
j
<
len
(
users
);
j
++
{
tos
=
append
(
tos
,
users
[
j
]
.
Email
)
}
if
err
:=
send
(
slice
.
Set
(
tos
),
mailContent
,
subject
,
"mail"
);
err
==
nil
{
logger
.
Infof
(
"sendMail: %+v"
,
events
[
0
])
}
err
=
send
(
slice
.
Set
(
tos
),
mailContent
,
subject
,
"mail"
)
case
"im"
:
tos
:=
[]
string
{}
for
j
:=
0
;
j
<
len
(
users
);
j
++
{
tos
=
append
(
tos
,
users
[
j
]
.
Im
)
}
send
(
slice
.
Set
(
tos
),
content
,
""
,
"im"
)
err
=
send
(
slice
.
Set
(
tos
),
content
,
""
,
"im"
)
default
:
logger
.
Errorf
(
"not support %s to send notify, events: %+v"
,
notifyTypes
[
i
],
events
)
}
if
err
!=
nil
{
logger
.
Errorf
(
"send %s users:%+v content:%s err:%v"
,
notifyTypes
[
i
],
users
,
content
,
err
)
}
}
}
...
...
@@ -411,6 +414,7 @@ func send(tos []string, content, subject, notifyType string) error {
return
fmt
.
Errorf
(
"tos is empty"
)
}
message
.
Tos
=
tos
message
.
Content
=
strings
.
TrimSpace
(
content
)
if
message
.
Content
==
""
{
return
fmt
.
Errorf
(
"content is blank"
)
...
...
@@ -434,6 +438,8 @@ func send(tos []string, content, subject, notifyType string) error {
redisc
.
Write
(
&
message
,
cron
.
IM_QUEUE_NAME
)
}
logger
.
Infof
(
"write %s message:%+v"
,
message
,
notifyType
)
return
nil
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录