Exemplo n.º 1
0
    def get_posts(self):
        if self.wallet_mode:
            self.posts = []
            return

        my_bulletin_secret = self.config.bulletin_secret
        posts = []
        blocked = [
            x['username'] for x in self.mongo.db.blocked_users.find(
                {'bulletin_secret': self.bulletin_secret})
        ]
        flagged = [
            x['id'] for x in self.mongo.db.flagged_content.find(
                {'bulletin_secret': self.bulletin_secret})
        ]
        for x in BU.get_posts(self.config, self.mongo, self.rid):
            rids = sorted(
                [str(my_bulletin_secret),
                 str(x.get('bulletin_secret'))],
                key=str.lower)
            rid = hashlib.sha256(str(rids[0]) +
                                 str(rids[1])).digest().encode('hex')
            if rid in self.rid_usernames:
                x['username'] = self.rid_usernames[rid]
                if x['username'] not in blocked and x['id'] not in flagged:
                    posts.append(x)
        self.posts = posts
Exemplo n.º 2
0
    def get_posts(self):
        if self.wallet_mode:
            self.posts = []
            return

        my_bulletin_secret = Config.get_bulletin_secret()
        posts = []
        blocked = [
            x['username'] for x in Mongo.db.blocked_users.find(
                {'bulletin_secret': self.bulletin_secret})
        ]
        flagged = [
            x['id'] for x in Mongo.db.flagged_content.find(
                {'bulletin_secret': self.bulletin_secret})
        ]
        for x in BU.get_posts(self.rid):
            rids = sorted(
                [str(my_bulletin_secret),
                 str(x.get('bulletin_secret'))],
                key=str.lower)
            rid = hashlib.sha256(str(rids[0]) +
                                 str(rids[1])).digest().encode('hex')
            res = Mongo.site_db.usernames.find({'rid': rid}, {'_id': 0})
            if res.count():
                x['username'] = res[0]['username']
                if x['username'] not in blocked and x['id'] not in flagged:
                    posts.append(x)
        self.posts = posts