From 1ff3c1cd0799bed749b48d97eb010af3c8224960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sun, 21 Jun 2020 14:15:46 +0200 Subject: [PATCH 1/4] Add default domain to API response --- src/yunohost/domain.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index e1d2b1649..f76ab2bb0 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -61,7 +61,11 @@ def domain_list(exclude_subdomains=False): continue result_list.append(domain) - return {'domains': result_list} + result_list.sort() + return { + 'domains': result_list, + 'default': result_list.index(_get_maindomain()) + } @is_unit_operation() @@ -89,7 +93,7 @@ def domain_add(operation_logger, domain, dyndns=False): raise YunohostError('domain_exists') operation_logger.start() - + # Lower domain to avoid some edge cases issues # See: https://forum.yunohost.org/t/invalid-domain-causes-diagnosis-web-to-fail-fr-on-demand/11765 domain = domain.lower() From 6bd56558303378d5c11db910773c141b456ee376 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 23 Sep 2020 22:11:04 +0200 Subject: [PATCH 2/4] Return main domain directly, not its index Co-authored-by: ljf (zamentur) --- src/yunohost/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index f76ab2bb0..2e46e7ab8 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -64,7 +64,7 @@ def domain_list(exclude_subdomains=False): result_list.sort() return { 'domains': result_list, - 'default': result_list.index(_get_maindomain()) + 'default': _get_maindomain() } From 5a905769dce406839c04120b85a932fede839a26 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 23 Sep 2020 22:12:47 +0200 Subject: [PATCH 3/4] (Do no sort domain, to be done in other PR) --- src/yunohost/domain.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index 2e46e7ab8..b3143e053 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -61,7 +61,6 @@ def domain_list(exclude_subdomains=False): continue result_list.append(domain) - result_list.sort() return { 'domains': result_list, 'default': _get_maindomain() From 8f776d23fc6020bc6fab21ca4c6bffb9a7f09960 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 23 Sep 2020 22:14:42 +0200 Subject: [PATCH 4/4] default -> main --- src/yunohost/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index b3143e053..2906bcf04 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -63,7 +63,7 @@ def domain_list(exclude_subdomains=False): return { 'domains': result_list, - 'default': _get_maindomain() + 'main': _get_maindomain() }