Projet

Général

Profil

0001-emails-compute-default-from-using-local-user-hostnam.patch

Frédéric Péters, 01 juin 2020 09:24

Télécharger (1,92 ko)

Voir les différences:

Subject: [PATCH] emails: compute default from using local user/hostname
 (#43496)

 tests/test_misc.py   | 4 +++-
 wcs/qommon/emails.py | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
tests/test_misc.py
4 4
import pytest
5 5
import os
6 6
import pickle
7
import pwd
8
import socket
7 9
import re
8 10
import time
9 11
import datetime
......
309 311
    pub = create_temporary_pub()
310 312
    send_email('test', mail_body='Hello', email_rcpt='test@localhost', want_html=False)
311 313
    assert emails.count() == 1
312
    assert emails.emails['test']['from'] == 'noreply@entrouvert.com'
314
    assert emails.emails['test']['from'] == '%s@%s' % (pwd.getpwuid(os.getuid())[0], socket.getfqdn())
313 315

  
314 316
    pub.cfg['emails'] = {'from': 'foo@localhost'}
315 317
    send_email('test', mail_body='Hello', email_rcpt='test@localhost', want_html=False)
wcs/qommon/emails.py
15 15
# along with this program; if not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import os
18
import pwd
18 19
import re
19 20

  
20 21
from email import encoders
......
287 288
            msg['To'] = email_rcpt
288 289

  
289 290
    if not email_from:
290
        email_from = emails_cfg.get('from', 'noreply@entrouvert.com')
291
        email_from = emails_cfg.get('from')
292
        if not email_from:
293
            email_from = '%s@%s' % (pwd.getpwuid(os.getuid())[0], socket.getfqdn())
291 294

  
292 295
    sitename = get_publisher().get_site_option('global_title', 'variables')
293 296
    if sitename:
294
-