mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Enable XMPP features only on "parent domains".
This commit is contained in:
parent
cf3b98b523
commit
22c88dc47e
3 changed files with 13 additions and 4 deletions
|
@ -399,6 +399,10 @@ domain:
|
||||||
list:
|
list:
|
||||||
action_help: List domains
|
action_help: List domains
|
||||||
api: GET /domains
|
api: GET /domains
|
||||||
|
arguments:
|
||||||
|
--exclude-subdomains:
|
||||||
|
help: Filter out domains that are obviously subdomains of other declared domains
|
||||||
|
action: store_true
|
||||||
|
|
||||||
### domain_add()
|
### domain_add()
|
||||||
add:
|
add:
|
||||||
|
|
|
@ -43,7 +43,7 @@ do_post_regen() {
|
||||||
|
|
||||||
# retrieve variables
|
# retrieve variables
|
||||||
main_domain=$(cat /etc/yunohost/current_host)
|
main_domain=$(cat /etc/yunohost/current_host)
|
||||||
domain_list=$(yunohost domain list --output-as plain --quiet)
|
domain_list=$(yunohost domain list --exclude-subdomains --output-as plain --quiet)
|
||||||
|
|
||||||
# create metronome directories for domains
|
# create metronome directories for domains
|
||||||
for domain in $domain_list; do
|
for domain in $domain_list; do
|
||||||
|
|
|
@ -41,7 +41,7 @@ from yunohost.hook import hook_callback
|
||||||
logger = getActionLogger('yunohost.domain')
|
logger = getActionLogger('yunohost.domain')
|
||||||
|
|
||||||
|
|
||||||
def domain_list():
|
def domain_list(exclude_subdomains=False):
|
||||||
"""
|
"""
|
||||||
List domains
|
List domains
|
||||||
|
|
||||||
|
@ -49,16 +49,21 @@ def domain_list():
|
||||||
filter -- LDAP filter used to search
|
filter -- LDAP filter used to search
|
||||||
offset -- Starting number for domain fetching
|
offset -- Starting number for domain fetching
|
||||||
limit -- Maximum number of domain fetched
|
limit -- Maximum number of domain fetched
|
||||||
|
exclude_subdomains -- Filter out domains that are subdomains of other declared domains
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.utils.ldap import _get_ldap_interface
|
from yunohost.utils.ldap import _get_ldap_interface
|
||||||
|
|
||||||
ldap = _get_ldap_interface()
|
ldap = _get_ldap_interface()
|
||||||
result = ldap.search('ou=domains,dc=yunohost,dc=org', 'virtualdomain=*', ['virtualdomain'])
|
result = [entry['virtualdomain'][0] for entry in ldap.search('ou=domains,dc=yunohost,dc=org', 'virtualdomain=*', ['virtualdomain'])]
|
||||||
|
|
||||||
result_list = []
|
result_list = []
|
||||||
for domain in result:
|
for domain in result:
|
||||||
result_list.append(domain['virtualdomain'][0])
|
if exclude_subdomains:
|
||||||
|
parent_domain = domain.split(".", 1)[1]
|
||||||
|
if parent_domain in result:
|
||||||
|
continue
|
||||||
|
result_list.append(domain)
|
||||||
|
|
||||||
return {'domains': result_list}
|
return {'domains': result_list}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue