#!/bin/bash

# Handles trusted domains configuration for applications like OwnCloud
tagsProcessorTrustedDomains()
{
    local full_file_path="$1"
    local trusted_domains=""

    if [[ "$public" == "true" ]]; then
        local traefik_status=$(dockerCheckAppInstalled "traefik" "docker")
        if [[ "$traefik_status" == "installed" ]]; then
            if [[ "$public_ip_v4" == "localhost" ]]; then
                trusted_domains="localhost,127.0.0.1,$host_setup,$first_allocated_ip"
            else
                trusted_domains="127.0.0.1,$host_setup,$first_allocated_ip,$public_ip_v4"
            fi
        else
            if [[ "$public_ip_v4" == "localhost" ]]; then
                trusted_domains="localhost,127.0.0.1,$first_allocated_ip"
            else
                trusted_domains="127.0.0.1,$first_allocated_ip,$public_ip_v4"
            fi
        fi
    else
        trusted_domains="127.0.0.1,localhost,$first_allocated_ip"
    fi
    
    tagsManagerUpdateUniversalTag "$full_file_path" "TRUSTED_DOMAINS_TAG" "$trusted_domains"
}
