#!/bin/bash

# Speedtest password LibrePortal tag replacements
# Now uses universal tag manager instead of sed operations

tagsProcessorSpeedtestPass()
{
    local full_file_path="$1"
    local password_enabled="$2"
    local password_value="$3"

    # adolfintel/speedtest treats an empty PASSWORD env as "no password
    # protection on the results page". So instead of commenting the env
    # line out (which used to be done with a sed regex that didn't even
    # match indented YAML), we just write the right value: the actual
    # password when enabled, empty when disabled.
    if [[ "$password_enabled" == "true" ]]; then
        tagsManagerUpdateUniversalTag "$full_file_path" "SPEEDTEST_PASSWORD_TAG" "$password_value"
    else
        tagsManagerUpdateUniversalTag "$full_file_path" "SPEEDTEST_PASSWORD_TAG" ""
    fi
}
