diff --git a/pkg/notify/models/notification.go b/pkg/notify/models/notification.go index 5be0f7b7bb..5a27b65c56 100644 --- a/pkg/notify/models/notification.go +++ b/pkg/notify/models/notification.go @@ -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 diff --git a/pkg/notify/rpc/send.go b/pkg/notify/rpc/send.go index eacd1ccff5..3bae183f22 100644 --- a/pkg/notify/rpc/send.go +++ b/pkg/notify/rpc/send.go @@ -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) }