feat(notify): be compatible with mobile in event notify

This commit is contained in:
rainzm
2021-01-29 15:42:21 +08:00
parent 334a47e383
commit c7b8d88d75
2 changed files with 9 additions and 1 deletions

View File

@@ -707,7 +707,7 @@ func (nm *SNotificationManager) ReSend(ctx context.Context, userCred mcclient.To
}
func (n *SNotification) TemplateStore() notifyv2.ITemplateStore {
if len(n.Event) == 0 {
if len(n.Event) == 0 || n.ContactType == api.MOBILE {
return TemplateManager
}
return LocalTemplateManager

View File

@@ -109,6 +109,10 @@ func (self *SRpcService) StopAll() {
// Send call the corresponding rpc server to send messager.
func (self *SRpcService) Send(ctx context.Context, contactType string, args apis.SendParams) error {
// Stop sending that must fail early
if len(args.RemoteTemplate) == 0 && contactType == api.MOBILE {
return fmt.Errorf("empty remote template for mobile type notification")
}
var err error
f := func(service *apis.SendNotificationClient) (interface{}, error) {
log.Debugf("send one")
@@ -127,6 +131,10 @@ func (self *SRpcService) Send(ctx context.Context, contactType string, args apis
}
func (self *SRpcService) BatchSend(ctx context.Context, contactType string, args apis.BatchSendParams) ([]*apis.FailedRecord, error) {
// Stop sending that must fail early
if len(args.RemoteTemplate) == 0 && contactType == api.MOBILE {
return nil, fmt.Errorf("empty remote template for mobile type notification")
}
f := func(service *apis.SendNotificationClient) (interface{}, error) {
return service.BatchSend(ctx, &args)
}