Пример #1
0
def _get_related_link_ids(event_id):
    # imported here to avoid circular import
    from reddit_liveupdate.pages import make_event_url

    url = make_event_url(event_id)

    try:
        links = Link._by_url(url, sr=None)
    except NotFound:
        links = []

    links = itertools.islice(links, MAX_LINK_IDS_TO_CACHE)
    return [link._fullname for link in links]
def _get_related_link_ids(event_id):
    # imported here to avoid circular import
    from reddit_liveupdate.pages import make_event_url

    url = make_event_url(event_id)

    try:
        links = Link._by_url(url, sr=None)
    except NotFound:
        links = []

    links = itertools.islice(links, MAX_LINK_IDS_TO_CACHE)
    return [link._fullname for link in links]
Пример #3
0
    def POST_unhide_discussion(self, form, jquery, link):
        """Unhide a linked comment thread from the discussions sidebar and listing..

        Requires the `discussions` permission for this thread.

        See also: [/api/live/*thread*/hide_discussion](#POST_api_live_{thread}_hide_discussion).

        """
        # this prevents a potential information leak where you use the
        # following link.url check to determine if links in a private subreddit
        # point at a given live thread.
        if link.subreddit_slow.type in Subreddit.private_types:
            self.abort403()

        url = pages.make_event_url(c.liveupdate_event._id)
        if link.url != url:
            c.errors.add(errors.LIVEUPDATE_LINK_IS_NOT_DISCUSSION)
            form.set_error(errors.LIVEUPDATE_LINK_IS_NOT_DISCUSSION, None)
            return

        c.liveupdate_event.unhide_discussion(link)