Пример #1
0
    def __next__(self):
        while not self.history:
            self.refresh()

        while self.history:
            # consume an item from history
            next_item = first(self.history)
            self.history = list(rest(self.history))

            # stay in while loop until we find a post that exists
            with suppress(PostDoesNotExist):
                p = Post(next_item)
                p.refresh()
                return p
Пример #2
0
def processComment(op):
    comment_body = op['body']
    if not comment_body or comment_body.startswith('@@ '):
        return
    post = None
    try:
        post = Post(op)
        post.refresh()
    except PostDoesNotExist:
        print('Warning! Post not found: ', op)
        return
    pkey = getPostKey(post)
    # print('post: ', pkey)
    if not pkey or pkey in processed_posts:
        return
    processed_posts[pkey] = True
    author_account = Account(op['author'])
    if author_account.rep < MIN_NOTIFY_REPUTATION:
        # no notifications for low-rep accounts
        return
    processMentions(author_account, comment_body, op)
    if op['parent_author']:
        if op['parent_author'] != op['author']:
            # no need to notify self of own comments
            title = 'Steemit'
            body = '@%s replied to your post or comment' % (op['author'])
            url = 'https://steemit.com/@%s/recent-replies' % (
                op['parent_author']
            )
            profile = author_account.profile
            pic = img_proxy_prefix + profile['profile_image'] \
                if profile and 'profile_image' in profile else ''
            tnt_server.call(
                'notification_add',
                op['parent_author'],
                NTYPES['comment_reply'],
                title,
                body,
                url,
                pic
            )
    else:
        followers = getFollowers(author_account)
        for follower in followers:
            tnt_server.call('notification_add', follower, NTYPES['feed'])