def handle(self, *args, **options): for user in User.objects.all(): post_ids = user.redis.feed_source[:] for post_id in post_ids: comment_details = CommentDetails.from_id(post_id) if not visible_in_feed({'comment': comment_details, 'type': 'post'}): user.redis.feed_source.remove(post_id)
def __init__(self, comment_details): """ `comment_details` can be either the parent comment, or any comment within the thread. """ from canvas.details_models import CommentDetails if getattr(comment_details, 'parent_id', None): op = CommentDetails.from_id(comment_details.parent_id) else: op = comment_details if not isinstance(op, CommentDetails): op = CommentDetails(comment_details) self.op = op
def sticky_threads(user): from apps.sticky_threads.models import get_sticky_threads_from_cache hidden_comments = map(int, user.redis.hidden_comments.smembers()) items = [{'type': 'sticky_thread', 'comment': CommentDetails.from_id(id_), 'comment_id': id_, 'text': text} for id_, text in get_sticky_threads_from_cache() if id_ not in hidden_comments] for item in items: _add_viewer_sticker_to_item(item, user) return items
def _from_sticker(cls, comment_sticker): from canvas.details_models import CommentDetails comment_details = CommentDetails.from_id(comment_sticker.comment_id) data = { 'comment_sticker_type_id': comment_sticker.type_id, 'details_url': comment_details.linked_url, } if comment_details.reply_content: try: data['thumbnail_url'] = comment_details.reply_content.get_absolute_url_for_image_type('small_square') except KeyError: pass return data
def _from_sticker(cls, comment_sticker): from canvas.details_models import CommentDetails comment_details = CommentDetails.from_id(comment_sticker.comment_id) data = { 'comment_sticker_type_id': comment_sticker.type_id, 'details_url': comment_details.linked_url, } if comment_details.reply_content: try: data[ 'thumbnail_url'] = comment_details.reply_content.get_absolute_url_for_image_type( 'small_square') except KeyError: pass return data
def sticky_threads(user): from apps.sticky_threads.models import get_sticky_threads_from_cache hidden_comments = map(int, user.redis.hidden_comments.smembers()) items = [{ 'type': 'sticky_thread', 'comment': CommentDetails.from_id(id_), 'comment_id': id_, 'text': text } for id_, text in get_sticky_threads_from_cache() if id_ not in hidden_comments] for item in items: _add_viewer_sticker_to_item(item, user) return items