diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index fed49f599..68b3d71b8 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -26,7 +26,7 @@ class Account(object): by the underlying deltachat core library. All public Account methods are meant to be memory-safe and return memory-safe objects. """ - def __init__(self, db_path, logid=None, eventlogging=True, debug=True): + def __init__(self, db_path, logid=None, eventlogging=True, os_name=None, debug=True): """ initialize account object. :param db_path: a path to the account database. The database @@ -34,10 +34,11 @@ class Account(object): :param logid: an optional logging prefix that should be used with the default internal logging. :param eventlogging: if False no eventlogging and no context callback will be configured + :param os_name: this will be put to the X-Mailer header in outgoing messages :param debug: turn on debug logging for events. """ self._dc_context = ffi.gc( - lib.dc_context_new(lib.py_dc_callback, ffi.NULL, ffi.NULL), + lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)), _destroy_dc_context, ) if eventlogging: diff --git a/python/tests/test_account.py b/python/tests/test_account.py index f582368e4..f6fbdd442 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -16,6 +16,14 @@ class TestOfflineAccountBasic: with pytest.raises(ValueError): Account(p.strpath) + def test_os_name(self, tmpdir): + p = tmpdir.join("hello.db") + # we can't easily test if os_name is used in X-Mailer + # outgoing messages without a full Online test + # but we at least check Account accepts the arg + ac1 = Account(p.strpath, os_name="solarpunk") + ac1.get_info() + def test_getinfo(self, acfactory): ac1 = acfactory.get_unconfigured_account() d = ac1.get_info()