diff --git a/daikoku/app/domain/json.scala b/daikoku/app/domain/json.scala index 2dc21ad8b..34890e929 100644 --- a/daikoku/app/domain/json.scala +++ b/daikoku/app/domain/json.scala @@ -2470,6 +2470,7 @@ object json { case "canceled" => JsSuccess(SubscriptionDemandState.Canceled) case "accepted" => JsSuccess(SubscriptionDemandState.Accepted) case "refused" => JsSuccess(SubscriptionDemandState.Refused) + case "blocked" => JsSuccess(SubscriptionDemandState.Blocked) case str => JsError(s"Bad SubscriptionDemandState value: $str") } diff --git a/daikoku/app/utils/ApiService.scala b/daikoku/app/utils/ApiService.scala index f2432c211..4aaa0d183 100644 --- a/daikoku/app/utils/ApiService.scala +++ b/daikoku/app/utils/ApiService.scala @@ -18,7 +18,7 @@ import fr.maif.otoroshi.daikoku.domain.UsagePlan._ import fr.maif.otoroshi.daikoku.domain.{DatastoreId, _} import fr.maif.otoroshi.daikoku.env.Env import fr.maif.otoroshi.daikoku.logger.AppLogger -import fr.maif.otoroshi.daikoku.utils.Cypher.encrypt +import fr.maif.otoroshi.daikoku.utils.Cypher.{decrypt, encrypt} import fr.maif.otoroshi.daikoku.utils.StringImplicits._ import jobs.{ApiKeyStatsJob, OtoroshiVerifierJob} import org.joda.time.DateTime @@ -892,6 +892,8 @@ class ApiService(env: Env, val value: EitherT[Future, AppError, Result] = for { title <- EitherT.liftF(translator.translate("mail.subscription.validation.title", tenant)) + user <- EitherT.fromOptionF(env.dataStore.userRepo.findByIdNotDeleted(demand.from), AppError.UserNotFound) + team <- EitherT.fromOptionF(env.dataStore.teamRepo.forTenant(tenant).findByIdNotDeleted(demand.team), AppError.TeamNotFound) _ <- EitherT.liftF(Future.sequence(emails.map(email => { val stepValidator = StepValidator( id = DatastoreId(BSONObjectID.generate().stringify), @@ -906,9 +908,14 @@ class ApiService(env: Env, val pathAccept = s"/api/subscription/_validate?token=$cipheredValidationToken" val pathDecline = s"/api/subscription/_decline?token=$cipheredValidationToken" - //FIXME: use template translator.translate("mail.subscription.validation.body", tenant, - Map("urlAccept" -> env.getDaikokuUrl(tenant, pathAccept), "urlDecline" -> env.getDaikokuUrl(tenant, pathDecline))) + Map( + "urlAccept" -> env.getDaikokuUrl(tenant, pathAccept), + "urlDecline" -> env.getDaikokuUrl(tenant, pathDecline), + "user" -> user.name, + "team" -> team.name, + "body" -> template.getOrElse("") + )) .flatMap(body => env.dataStore.stepValidatorRepo.forTenant(tenant).save(stepValidator).map(_ => body)) .flatMap(body => tenant.mailer.send(title, Seq(email), body, tenant)) }))) diff --git a/daikoku/conf/messages.en b/daikoku/conf/messages.en index 0e55a5ac5..d5344a66b 100644 --- a/daikoku/conf/messages.en +++ b/daikoku/conf/messages.en @@ -85,11 +85,9 @@ You need to verify your mail for the team [team].\ mail.subscription.validation.title = Validate a subscription mail.subscription.validation.body = Hello,\
\ - Somebody want to subscribe your API,\ + [user] for the team [team] wants to subscribe your API,\
\
\ - [user] :\ -
\ [body]\
\ Accept or Reject diff --git a/daikoku/conf/messages.fr b/daikoku/conf/messages.fr index 2bd11c1ba..215dba3bb 100644 --- a/daikoku/conf/messages.fr +++ b/daikoku/conf/messages.fr @@ -85,11 +85,9 @@ Vous devez vérifier votre mail pour l'équipe [team].\ mail.subscription.validation.title = Validation de souscription mail.subscription.validation.body = Bonjour,\
\ - Quelqu'un voudrait souscrire a l'API [apiName],\ + [user] pour l'équipe [team] voudrait souscrire a l'API [apiName],\
\
\ - [user] :\ -
\ [body]\
\ Accept or Reject