Improve SendEmail() and SendSms() APIs.

This commit is contained in:
Yang Luo
2021-09-05 10:30:51 +08:00
parent 1c5ce46bd5
commit 88aa444ad1
3 changed files with 40 additions and 57 deletions

View File

@ -87,10 +87,16 @@ func (c *ApiController) GetProviderFromContext(category string) (*object.Provide
}
application, user := object.GetApplicationByUserId(userId)
if application == nil {
c.ResponseError(fmt.Sprintf("No application is found for userId: \"%s\"", userId))
return nil, nil, false
}
provider := application.GetProviderByCategory(category)
if provider == nil {
c.ResponseError(fmt.Sprintf("No provider for category: \"%s\" is found for application: %s", category, application.Name))
return nil, nil, false
}
return provider, user, true
}