diff --git a/app/mailers/api_action_mailer.rb b/app/mailers/api_action_mailer.rb index 4e13fefac..613add626 100644 --- a/app/mailers/api_action_mailer.rb +++ b/app/mailers/api_action_mailer.rb @@ -4,13 +4,21 @@ def send_email(api_action) mail_to = api_action.email_evaluated from = "#{Subdomain.current.name}@#{ENV["APP_HOST"]}" return if mail_to.empty? - @api_action = api_action @api_resource = api_action.api_resource + + if !@api_resource && api_action.meta_data + @meta_data = api_action.meta_data["api_resource"] + @meta_data["namespace"] = ApiNamespace.find_by(id: ApiAction.find(api_action.id).meta_data["api_resource"]["api_namespace_id"]) + end + + custom_subject = api_action.email_subject_evaluated || if api_action.api_namespace_action then "#{api_action.type} #{api_action.api_namespace_action.api_namespace&.name.pluralize} v#{api_action.api_namespace_action.api_namespace&.version}" + else "#{api_action.type} #{@api_resource.api_namespace.name.pluralize} v#{@api_resource.api_namespace.version}" end + mail( from: from, to: mail_to, - subject: api_action.email_subject_evaluated || "#{api_action.type} #{@api_resource.api_namespace.name.pluralize} v#{@api_resource.api_namespace.version}" + subject: custom_subject ) end end diff --git a/app/views/api_action_mailer/send_email.html.erb b/app/views/api_action_mailer/send_email.html.erb index 5e8e2dbbf..2849c73b9 100644 --- a/app/views/api_action_mailer/send_email.html.erb +++ b/app/views/api_action_mailer/send_email.html.erb @@ -45,6 +45,31 @@ <% end %> + <% elsif @api_action.include_api_resource_data && !@api_resource && @meta_data %> +
+ Errors: + <%= @meta_data["errors"] %> +
++ Api namespace: + <%=@meta_data["namespace"]&.name %> +
++ Properties: + <%= @meta_data["properties"] %> +
+