Skip to content
Snippets Groups Projects
dynamic_preferences_registry.py 2.28 KiB
Newer Older
from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

from funkwhale_api.common import preferences
Eliot Berriot's avatar
Eliot Berriot committed

federation = types.Section("federation")


@global_preferences_registry.register
class MusicCacheDuration(types.IntPreference):
    show_in_api = True
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
    name = "music_cache_duration"
    default = 60 * 24 * 2
Eliot Berriot's avatar
Eliot Berriot committed
    verbose_name = "Music cache duration"
        "How many minutes do you want to keep a copy of federated tracks "
Eliot Berriot's avatar
Eliot Berriot committed
        "locally? Federated files that were not listened in this interval "
        "will be erased and refetched from the remote on the next listening."
Eliot Berriot's avatar
Eliot Berriot committed
    field_kwargs = {"required": False}


@global_preferences_registry.register
class Enabled(preferences.DefaultFromSettingMixin, types.BooleanPreference):
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
    name = "enabled"
    setting = "FEDERATION_ENABLED"
    verbose_name = "Federation enabled"
Eliot Berriot's avatar
Eliot Berriot committed
        "Use this setting to enable or disable federation logic and API" " globally."
    )


@global_preferences_registry.register
Eliot Berriot's avatar
Eliot Berriot committed
class CollectionPageSize(preferences.DefaultFromSettingMixin, types.IntPreference):
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
    name = "collection_page_size"
    setting = "FEDERATION_COLLECTION_PAGE_SIZE"
    verbose_name = "Federation collection page size"
    help_text = "How many items to display in ActivityPub collections."
Eliot Berriot's avatar
Eliot Berriot committed
    field_kwargs = {"required": False}


@global_preferences_registry.register
Eliot Berriot's avatar
Eliot Berriot committed
class ActorFetchDelay(preferences.DefaultFromSettingMixin, types.IntPreference):
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
    name = "actor_fetch_delay"
    setting = "FEDERATION_ACTOR_FETCH_DELAY"
    verbose_name = "Federation actor fetch delay"
        "How many minutes to wait before refetching actors on "
Eliot Berriot's avatar
Eliot Berriot committed
        "request authentication."
Eliot Berriot's avatar
Eliot Berriot committed
    field_kwargs = {"required": False}


@global_preferences_registry.register
Eliot Berriot's avatar
Eliot Berriot committed
class MusicNeedsApproval(preferences.DefaultFromSettingMixin, types.BooleanPreference):
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
    name = "music_needs_approval"
    setting = "FEDERATION_MUSIC_NEEDS_APPROVAL"
    verbose_name = "Federation music needs approval"
Eliot Berriot's avatar
Eliot Berriot committed
        "When true, other federation actors will need your approval"
        " before being able to browse your library."