def unsubscribe_user(thread, user): cursor = connection.cursor() code = Code try: query = Query() query.add_delete("subscribe") query.add_where_condition(" user = \"{}\" and thread = {} ".format(user, thread)) cursor.execute(query.get()) except Exception as e: print str(e) cursor.close() return {'code': code.NOT_FOUND, "response": "insert failed, user or thread not found"} cursor.close() response = { "thread": thread, "user": user } return {'code': code.OK, "response": response}
def unfollow_user(follower, followee): cursor = connection.cursor() code = Code try: query = Query() query.add_delete("follow") query.add_where_condition( " follower = \"{}\" and following = \"{}\" ".format( follower, followee)) cursor.execute(query.get()) except Exception as e: print str(e) cursor.close() return { 'code': code.NOT_FOUND, "response": "delete failed, user not found" } cursor.close() response = get_detail_user(follower) return {'code': code.OK, "response": response}