# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

from dopplerr.notifications.pushover import NotificationPushOver
from dopplerr.config import DopplerrConfig

log = logging.getLogger(__name__)


async def emit_notifications(notification):
    log.debug("Emiting notification: [%s] %s - %s", notification.notification_type,
              notification.notification_title, notification.one_liner)
    if DopplerrConfig().get_cfg_value("notifications.pushover.enabled"):
        log.debug("Emiting pushover with user %s",
                  DopplerrConfig().get_cfg_value("notifications.pushover.user"))
        po = NotificationPushOver(
            DopplerrConfig().get_cfg_value("notifications.pushover.token"),
            DopplerrConfig().get_cfg_value("notifications.pushover.user"),
            DopplerrConfig().get_cfg_value("notifications.pushover.registered_notifications"),
        )
        await po.emit(notification.notification_type, notification.notification_title,
                      notification.one_liner)
