diff --git a/anonstream/config.py b/anonstream/config.py index 2ba8bbb..28ca288 100644 --- a/anonstream/config.py +++ b/anonstream/config.py @@ -33,7 +33,7 @@ def toml_to_flask_sections(config): toml_to_flask_section_names, toml_to_flask_section_memory, toml_to_flask_section_tasks, - toml_to_flask_section_thresholds, + toml_to_flask_section_presence, toml_to_flask_section_chat, toml_to_flask_section_flood, toml_to_flask_section_captcha, @@ -104,13 +104,13 @@ def toml_to_flask_section_tasks(config): 'TASK_BROADCAST_STREAM_INFO_UPDATE': cfg['broadcast_stream_info_update'], } -def toml_to_flask_section_thresholds(config): - cfg = config['thresholds'] - assert cfg['user_notwatching'] <= cfg['user_tentative'] <= cfg['user_absent'] +def toml_to_flask_section_presence(config): + cfg = config['presence'] + assert cfg['notwatching'] <= cfg['tentative'] <= cfg['absent'] return { - 'THRESHOLD_USER_NOTWATCHING': cfg['user_notwatching'], - 'THRESHOLD_USER_TENTATIVE': cfg['user_tentative'], - 'THRESHOLD_USER_ABSENT': cfg['user_absent'], + 'PRESENCE_NOTWATCHING': cfg['notwatching'], + 'PRESENCE_TENTATIVE': cfg['tentative'], + 'PRESENCE_ABSENT': cfg['absent'], } def toml_to_flask_section_chat(config): diff --git a/anonstream/helpers/user.py b/anonstream/helpers/user.py index f18561e..072230c 100644 --- a/anonstream/helpers/user.py +++ b/anonstream/helpers/user.py @@ -62,16 +62,16 @@ def get_default_name(user): def get_presence(timestamp, user): last_watching_ago = timestamp - user['last']['watching'] - if last_watching_ago < CONFIG['THRESHOLD_USER_NOTWATCHING']: + if last_watching_ago < CONFIG['PRESENCE_NOTWATCHING']: return Presence.WATCHING last_seen_ago = timestamp - user['last']['seen'] - if last_seen_ago < CONFIG['THRESHOLD_USER_TENTATIVE']: + if last_seen_ago < CONFIG['PRESENCE_TENTATIVE']: return Presence.NOTWATCHING if user['websockets']: return Presence.NOTWATCHING - if last_seen_ago < CONFIG['THRESHOLD_USER_ABSENT']: + if last_seen_ago < CONFIG['PRESENCE_ABSENT']: return Presence.TENTATIVE return Presence.ABSENT diff --git a/config.toml b/config.toml index 20ab35d..f9402dc 100644 --- a/config.toml +++ b/config.toml @@ -72,10 +72,10 @@ cooldown = 12.0 expire_after = 5.0 overwrite = true -[thresholds] -user_notwatching = 8.0 -user_tentative = 20.0 -user_absent = 360.0 +[presence] +notwatching = 8.0 +tentative = 20.0 +absent = 360.0 [nojs] refresh_messages = 4.0