From 11cd568ee04d3947359368e4fa0ddf72a8642701 Mon Sep 17 00:00:00 2001
From: Arthur BOUDREAULT <boudreaultarthur@ik.me>
Date: Tue, 26 Oct 2021 15:23:15 +0200
Subject: [PATCH] refactor(yunohost): Apply suggestions to smtp relay feat code

---
 README-FR.md      | 10 +++++-----
 README.md         |  6 +++---
 defaults/main.yml | 11 ++++++++---
 tasks/main.yml    |  2 +-
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/README-FR.md b/README-FR.md
index 06fc046..f3dcbb5 100644
--- a/README-FR.md
+++ b/README-FR.md
@@ -49,18 +49,18 @@ ynh_ignore_dyndns_server: False
 - `ynh_extra_domains` sont des sous-domaines optionnels. Ils permettent d'installer une application par sous-domaine (plus d'infos [ici](https://yunohost.org/fr/dns_subdomains)).
 - `ynh_ignore_dyndns_server` permet d'enregistrer les domaines avec un service de DNS dynamique (plus d'infos [ici](https://yunohost.org/fr/dns_dynamicip)).
 
-### Configuration d'un relai SMTP
+### Configuration d'un relais SMTP
 
 ```yml
-# paramètres personnalisés du SMTP relai (A ne modifier qu'en cas de besoin)
-ynh_new_smtp_relay:
+# paramètres personnalisés du relais SMTP
+ynh_smtp_relay:
     host: smtp.domain.tld
     port: 25
     user: user1
     password: Pa$$w0rd
 ```
-Yunohost possède son propre serveur SMTP natif mais il est aussi possible de configurer Yunohost pour qu'il utilise un relai SMTP à la place. 
-Pour faire cela, Décommentez les variables par défaut et mettez vos propres valeurs. Vous pouvez en apprendre plus sur les relais SMTP [ici](https://yunohost.org/fr/administrate/specific_use_cases/email_relay).
+Yunohost possède son propre serveur SMTP natif mais il est aussi possible de configurer Yunohost pour qu'il utilise un relais SMTP à la place. 
+Pour faire cela, créez la variable `ynh_smtp_relay` et mettez vos propres valeurs. Vous pouvez en apprendre plus sur les relais SMTP [ici](https://yunohost.org/fr/administrate/specific_use_cases/email_relay).
 
 ### Gestion des utilisateurs
 
diff --git a/README.md b/README.md
index 7702ecb..4a82b8c 100644
--- a/README.md
+++ b/README.md
@@ -52,8 +52,8 @@ ynh_ignore_dyndns_server: False
 ### SMTP relay configuration
 
 ```yml
-# SMTP custom settings (Only override if you need a SMTP relay)
-ynh_new_smtp_relay:
+# SMTP custom settings
+ynh_smtp_relay:
     host: smtp.domain.tld
     port: 25
     user: user1
@@ -61,7 +61,7 @@ ynh_new_smtp_relay:
 ```
 
 There is a built-in SMTP server on Yunohost but you can also set up Yunohost to use a SMTP relay instead.
-Uncomment the default variables and provide your own values. You can learn more about SMTP relay [here](https://yunohost.org/en/administrate/specific_use_cases/email_relay).
+In order to do so, create the `ynh_smtp_relay` variable and provide your own values. You can learn more about SMTP relay [here](https://yunohost.org/en/administrate/specific_use_cases/email_relay).
 
 ### User management
 
diff --git a/defaults/main.yml b/defaults/main.yml
index 0492cbf..14b42ca 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -36,11 +36,16 @@ ynh_users: null
   #   lastname: Doe
   #   mail_domain: domain.tld
 
+# Do not touch this variable
+# Just to have dict default value
+ynh_smtp_relay:
+  value: null
+
 # SMTP custom settings (Only override if you need a SMTP relay)
-ynh_new_smtp_relay:
-    value: null # Do you touch this variable
+# Example:
+# ynh_smtp_relay:
     # host: smtp.domain.tld
-    # port: 25
+    # port: "25"
     # user: user1
     # password: Pa$$w0rd
 
diff --git a/tasks/main.yml b/tasks/main.yml
index a4c0678..0480221 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -62,7 +62,7 @@
 
 - name: Configure SMTP relay
   ansible.builtin.include_tasks: smtp_relay.yml
-  loop: "{{ ynh_new_smtp_relay | dict2items }}"
+  loop: "{{ ynh_smtp_relay | dict2items }}"
   when: item.value
 
 - name: Add Yunohost users
-- 
GitLab