dynamic_preferences_registry.py 2.28 KB
Newer Older
1
2
3
4

from dynamic_preferences import types
from dynamic_preferences.registries import global_preferences_registry

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

federation = types.Section("federation")
8
9
10
11
12
13


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


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


@global_preferences_registry.register
Eliot Berriot's avatar
Eliot Berriot committed
37
class CollectionPageSize(preferences.DefaultFromSettingMixin, types.IntPreference):
38
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
39
40
41
42
43
    name = "collection_page_size"
    setting = "FEDERATION_COLLECTION_PAGE_SIZE"
    verbose_name = "Federation collection page size"
    help_text = "How much items to display in ActivityPub collections."
    field_kwargs = {"required": False}
44
45
46


@global_preferences_registry.register
Eliot Berriot's avatar
Eliot Berriot committed
47
class ActorFetchDelay(preferences.DefaultFromSettingMixin, types.IntPreference):
48
    section = federation
Eliot Berriot's avatar
Eliot Berriot committed
49
50
51
    name = "actor_fetch_delay"
    setting = "FEDERATION_ACTOR_FETCH_DELAY"
    verbose_name = "Federation actor fetch delay"
52
    help_text = (
Eliot Berriot's avatar
Eliot Berriot committed
53
54
        "How much minutes to wait before refetching actors on "
        "request authentication."
55
    )
Eliot Berriot's avatar
Eliot Berriot committed
56
    field_kwargs = {"required": False}
57
58
59


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