mirror of
https://github.com/Tech-Workers-Coalition-Italia/mobilizon-reshare.git
synced 2025-02-11 17:20:46 +01:00
* fixed visualization * simplified tests * split into files * refactored test expected publications * split update tests * expanded specifications and tests * added event_status window tests * fixed 'all' command * renamed everything * fixed uppercase * refactored main and publisher to add notifications * tested report successful * added tests to publisher coordinator * added more coordinator tests * test coordinator success
36 lines
974 B
Python
36 lines
974 B
Python
from typing import Iterator
|
|
|
|
from dynaconf import Validator
|
|
|
|
telegram_validators = [
|
|
Validator("notifier.telegram.chat_id", must_exist=True),
|
|
Validator("notifier.telegram.token", must_exist=True),
|
|
Validator("notifier.telegram.username", must_exist=True),
|
|
]
|
|
zulip_validators = []
|
|
mastodon_validators = []
|
|
twitter_validators = []
|
|
|
|
notifier_name_to_validators = {
|
|
"telegram": telegram_validators,
|
|
"twitter": twitter_validators,
|
|
"mastodon": mastodon_validators,
|
|
"zulip": zulip_validators,
|
|
}
|
|
notifier_names = notifier_name_to_validators.keys()
|
|
|
|
|
|
def get_active_notifiers(settings) -> Iterator[str]:
|
|
return filter(
|
|
lambda notifier_name: settings["notifier"][notifier_name]["active"],
|
|
notifier_names,
|
|
)
|
|
|
|
|
|
def get_validators(settings):
|
|
active_notifiers = get_active_notifiers(settings)
|
|
validators = []
|
|
for notifier in active_notifiers:
|
|
validators += notifier_name_to_validators[notifier]
|
|
return validators
|