From 82f5dc20f3e0bea60d765f173ef7c28c3965d09a Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sun, 6 May 2018 16:23:23 +0200
Subject: [PATCH] Documentation for missing DEFAULT_FROM_EMAIL setting

---
 api/config/settings/common.py     | 12 ++++++++++++
 api/config/settings/production.py | 10 ----------
 deploy/env.prod.sample            |  5 ++++-
 docs/configuration.rst            | 14 ++++++++++++++
 4 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/api/config/settings/common.py b/api/config/settings/common.py
index 1372f59e3c..f88aa5dd54 100644
--- a/api/config/settings/common.py
+++ b/api/config/settings/common.py
@@ -172,6 +172,18 @@ FIXTURE_DIRS = (
 
 # EMAIL CONFIGURATION
 # ------------------------------------------------------------------------------
+
+# EMAIL
+# ------------------------------------------------------------------------------
+DEFAULT_FROM_EMAIL = env(
+    'DEFAULT_FROM_EMAIL',
+    default='Funkwhale <noreply@{}>'.format(FUNKWHALE_HOSTNAME))
+
+EMAIL_SUBJECT_PREFIX = env(
+    "EMAIL_SUBJECT_PREFIX", default='[Funkwhale] ')
+SERVER_EMAIL = env('SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
+
+
 EMAIL_CONFIG = env.email_url(
     'EMAIL_CONFIG', default='consolemail://')
 
diff --git a/api/config/settings/production.py b/api/config/settings/production.py
index f238c2d20b..2866e91039 100644
--- a/api/config/settings/production.py
+++ b/api/config/settings/production.py
@@ -68,16 +68,6 @@ DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
 # ------------------------
 STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
 
-
-# EMAIL
-# ------------------------------------------------------------------------------
-DEFAULT_FROM_EMAIL = env('DJANGO_DEFAULT_FROM_EMAIL',
-                         default='funkwhale_api <noreply@funkwhale.io>')
-
-EMAIL_SUBJECT_PREFIX = env("DJANGO_EMAIL_SUBJECT_PREFIX", default='[funkwhale_api] ')
-SERVER_EMAIL = env('DJANGO_SERVER_EMAIL', default=DEFAULT_FROM_EMAIL)
-
-
 # TEMPLATE CONFIGURATION
 # ------------------------------------------------------------------------------
 # See:
diff --git a/deploy/env.prod.sample b/deploy/env.prod.sample
index dfd17ff4d6..4b27595af6 100644
--- a/deploy/env.prod.sample
+++ b/deploy/env.prod.sample
@@ -6,7 +6,7 @@
 # - DJANGO_SECRET_KEY
 # - DJANGO_ALLOWED_HOSTS
 # - FUNKWHALE_URL
-# - EMAIL_CONFIG (if you plan to send emails)
+# - EMAIL_CONFIG and DEFAULT_FROM_EMAIL if you plan to send emails)
 # On non-docker setup **only**, you'll also have to tweak/uncomment those variables:
 # - DATABASE_URL
 # - CACHE_URL
@@ -52,6 +52,9 @@ FUNKWHALE_URL=https://yourdomain.funwhale
 # EMAIL_CONFIG=smtp+ssl://user@:password@youremail.host:465'
 # EMAIL_CONFIG=smtp+tls://user@:password@youremail.host:587'
 
+# The email address to use to send systme emails. By default, we will
+# DEFAULT_FROM_EMAIL=noreply@yourdomain
+
 # Depending on the reverse proxy used in front of your funkwhale instance,
 # the API will use different kind of headers to serve audio files
 # Allowed values: nginx, apache2
diff --git a/docs/configuration.rst b/docs/configuration.rst
index f498b9c87d..bbc658e087 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -56,6 +56,20 @@ Possible values:
 - ``smtp+ssl://user:password@youremail.host:465``: Send emails via SMTP via youremail.host on port 465, using SSL encryption, authenticating as user "user" with password "password"
 - ``smtp+tls://user:password@youremail.host:587``: Send emails via SMTP via youremail.host on port 587, using TLS encryption, authenticating as user "user" with password "password"
 
+.. _setting-DEFAULT_FROM_EMAIL:
+
+``DEFAULT_FROM_EMAIL``
+^^^^^^^^^^^^^^^^^^^^^^
+
+The email address to use to send email.
+
+Default: ``Funkwhale <noreply@yourdomain>``
+
+.. note::
+
+    Both the forms ``Funkwhale <noreply@yourdomain>`` and
+    ``noreply@yourdomain`` work.
+
 
 .. _setting-MUSIC_DIRECTORY_PATH:
 
-- 
GitLab