Example #1
0
def follow(user_id, other_id):
    if is_following(user_id, other_id):
        return False
    follow_relation = FollowRelation(follower_id=user_id, user_id=other_id)
    db.session.add(follow_relation)
    db.session.commit()
    pubsub.publish(Event.FOLLOWING_UPDATED, user_id)
    pubsub.publish(Event.FOLLOWER_UPDATED, other_id)
    return True
Example #2
0
 def follow(self, user_id, other_id):
     if self.is_following(user_id, other_id):
         return False
     follow_relation = FollowRelation(follower_id = user_id, user_id = other_id)
     db.session.add(follow_relation)
     db.session.commit()
     pubsub.publish(Event.FOLLOWING_UPDATED, user_id)
     pubsub.publish(Event.FOLLOWER_UPDATED, other_id)
     return True
Example #3
0
def post_feed(user_id, content, time_created=None):
    if not time_created:
        time_created = int(time.time())
    feed = Feed(user_id=user_id, content=content, time_created=time_created)
    db.session.add(feed)
    db.session.commit()
    pubsub.publish(Event.USER_FEEDS_UPDATED, user_id)
    for u in get_followers(user_id):
        pubsub.publish(Event.FRIEND_FEEDS_UPDATED, u['id'])
    return feed.to_dict()
Example #4
0
 def post_feed(self, user_id, content, time_created=None):
     if not time_created:
         time_created = int(time.time())
     feed = Feed(user_id=user_id, content=content, time_created=time_created)
     db.session.add(feed)
     db.session.commit()
     pubsub.publish(Event.USER_FEEDS_UPDATED, user_id)
     for u in self.get_followers(user_id):
         pubsub.publish(Event.FRIEND_FEEDS_UPDATED, u['id'])
     return feed.to_dict()
Example #5
0
 def unfollow(self, user_id, other_id):
     follow_relation = FollowRelation.query.filter_by(follower_id=user_id, user_id=other_id).one()
     if follow_relation:
         db.session.delete(follow_relation)
         db.session.commit()
         pubsub.publish(Event.FOLLOWING_UPDATED, user_id)
         pubsub.publish(Event.FOLLOWER_UPDATED, other_id)
         return True
     else:
         return False
Example #6
0
def unfollow(user_id, other_id):
    follow_relation = FollowRelation.query.filter_by(follower_id=user_id,
                                                     user_id=other_id).one()
    if follow_relation:
        db.session.delete(follow_relation)
        db.session.commit()
        pubsub.publish(Event.FOLLOWING_UPDATED, user_id)
        pubsub.publish(Event.FOLLOWER_UPDATED, other_id)
        return True
    else:
        return False