Exemple #1
0
    def create_feed_from_feed_info(feed_info, hub=None, feed_format=None):

        if not hub:
            if feed_info.hub:
                hub = feed_info.hub
            else:
                hub = app.config.get("DEFAULT_HUB")

        feed = Feed.query.filter_by(topic=feed_info.url).first()
        if not feed:
            feed = Feed(topic=feed_info.url, hub=hub)

            feed.create_unique_url()
            feed.create_secret()

            feed.feed_format = feed_format if feed_format else feed.feed_format

            if not feed.callback_url:
                feed.callback_url = get_public_url(feed)

        feed.site_url = (feed_info.site_url,)
        feed.description = (feed_info.descripton,)
        feed.site_name = (feed_info.site_name,)
        feed.title = (feed_info.title,)
        feed.site_icon_link = feed_info.site_icon_link

        return feed
Exemple #2
0
    def update_feed_version(self, data: Dict, feed: Feed) -> None:
        """
        Sets the format of the Feed.

        :param data: parsed XML feed
        :type data: Dict
        :param feed: A Feed object
        :type feed: Feed
        :return: Feed object
        """
        feed.feed_format = data.get("version", "RSS/Atom")
Exemple #3
0
    def update_feed_version(self, data: Dict, feed: Feed) -> None:
        """
        Sets the format of the Feed.

        :param data: deserialized JSON
        :type data: Dict
        :param feed: A Feed object
        :type feed: Feed
        :return: Feed object
        """
        feed.feed_format = "json"
Exemple #4
0
    def update_feed_details(self, data: Dict, feed: Feed) -> None:
        """
        Updates the title and description of a feed if they have been sent
        with the notification.

        :param data: deserialized JSON
        :type data: Dict
        :param feed: The Feed to be updated
        :type feed: Feed
        :return: Feed object
        """
        if data.get("title"):
            feed.title = data.get("title")

        if data.get("description"):
            feed.description = data["description"]
        elif data.get("subtitle"):
            feed.description = data["subtitle"]

        feed.feed_format = "json"