from intranet.domenator.src.db.event.models import Event as EventModel
from intranet.domenator.src.settings import config


class Event:
    def __init__(self, name: str, data: dict):
        self.name = name
        self.data = data


async def save_event(event: Event):
    if config.events_saving_enabled:
        await EventModel.create(
            name=event.name,
            data=event.data,
        )
