mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 03:24:29 +08:00
feat(notify): be compatible with mobile in event notify
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user