from ploneintranet.notifications.adapters.category_provider import BaseCategory
from ploneintranet.notifications.adapters.category_provider import BaseCategoryProvider


class LegacyCategory(BaseCategory):
    name = "legacy"
    default_channels = {}

    @property
    def recipient_ids(self):
        return {self.context.logged_event.data["recipient_id"]}

    def get_message_for(self, notification, with_text=True, highlight=False):
        return notification.logged_event.data["text"]

    def get_absolute_url_for(self, notification):
        return notification.logged_event.data["url"]


class LegacyCategoryProvider(BaseCategoryProvider):

    category_factories = [LegacyCategory]
