Ejemplo n.º 1
0
    def _create(self):
        _redis = self.application.redis
        _request = json.loads(self.request.body)
        _user_uuid = _request.get("user_uuid")
        _app_name = _request.get("app_name")

        if _user_uuid == None or _app_name == None:
            self.setErrorCode(API_ERR.NO_PARA)
            return

        _app_key = str(uuid.uuid1())
        _app_secret = str(uuid.uuid1())
        _app_uuid = str(uuid.uuid1())
        _user_email = _redis.hget(
            DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_email")
        _company_name = _redis.hget(
            DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_company")

        _app_values = {
            "uuid": _app_uuid,
            "user_uuid": _user_uuid,
            "app_name": _app_name,
            "app_key": _app_key,
            "app_secret": _app_secret,
            "app_billing_email": _user_email,
            "offline_message": PPCOM_OFFLINE["zh_cn"],
            "welcome_message": PPCOM_WELCOME["zh_cn"],
            "app_route_policy": APP_POLICY.BROADCAST,
            "show_ppcom_hover": SHOW_PPCOM_HOVER.NEVER,
            "ppcom_launcher_style": PPCOM_LAUNCHER_STYLE.DEFAULT,
        }

        if _company_name != None and len(_company_name) > 0:
            _app_values["company_name"] = _company_name

        _row = AppInfo(**_app_values)
        _row.async_add()
        _row.create_redis_keys(_redis)

        _data_uuid = str(uuid.uuid1())
        _data = {
            "uuid": _data_uuid,
            "user_uuid": _user_uuid,
            "app_uuid": _app_uuid,
            "is_owner_user": True,
            "is_service_user": True,
            "is_distributor_user": True,
            "is_portal_user": False
        }
        _row = AppUserData(**_data)
        _row.async_add()
        _row.create_redis_keys(_redis)

        # create api_info
        self._create_kefu_client_apiinfo(_user_uuid, _app_uuid)
        self._create_console_client_apiinfo(_user_uuid, _app_uuid)

        _r = self.getReturnData()
        _r.update(_app_values)
        return
Ejemplo n.º 2
0
    def _create(self):
        _redis = self.application.redis
        _request = json.loads(self.request.body)
        _user_uuid = _request.get("user_uuid")
        _app_name = _request.get("app_name")
                
        if _user_uuid == None or _app_name == None:
            self.setErrorCode(API_ERR.NO_PARA)
            return
                               
        _app_key = str(uuid.uuid1())
        _app_secret = str(uuid.uuid1())
        _app_uuid = str(uuid.uuid1())
        _user_email = _redis.hget(DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_email")
        _company_name = _redis.hget(DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_company")
        
        _app_values = {
            "uuid": _app_uuid,
            "user_uuid": _user_uuid,
            "app_name": _app_name,
            "app_key": _app_key,
            "app_secret": _app_secret,
            "app_billing_email": _user_email,
            "offline_message": PPCOM_OFFLINE["zh_cn"],
            "welcome_message": PPCOM_WELCOME["zh_cn"],
            "app_route_policy": APP_POLICY.BROADCAST,
            "show_ppcom_hover": SHOW_PPCOM_HOVER.NEVER,
            "ppcom_launcher_style": PPCOM_LAUNCHER_STYLE.DEFAULT,
        }

        if _company_name != None and len(_company_name) > 0:
            _app_values["company_name"] = _company_name

        _row = AppInfo(**_app_values)
        _row.async_add()
        _row.create_redis_keys(_redis)
                
        _data_uuid = str(uuid.uuid1())
        _data = {
            "uuid": _data_uuid,
            "user_uuid": _user_uuid,
            "app_uuid": _app_uuid,
            "is_owner_user": True,
            "is_service_user": True,
            "is_distributor_user": True,
            "is_portal_user": False
        }
        _row = AppUserData(**_data)
        _row.async_add()
        _row.create_redis_keys(_redis)

        # create api_info
        self._create_kefu_client_apiinfo(_user_uuid, _app_uuid)
        self._create_console_client_apiinfo(_user_uuid, _app_uuid)

        _r = self.getReturnData()
        _r.update(_app_values)
        return
Ejemplo n.º 3
0
def create_app(_handler, _app_name, _user_uuid):
    _redis = _handler.application.redis

    _app_key = str(uuid.uuid1())
    _app_secret = str(uuid.uuid1())
    _app_uuid = str(uuid.uuid1())
    _user_email = _redis.hget(DeviceUser.__tablename__ + ".uuid." + _user_uuid,
                              "user_email")
    _company_name = _redis.hget(
        DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_company")

    _app_values = {
        "uuid": _app_uuid,
        "user_uuid": _user_uuid,
        "app_name": _app_name,
        "app_key": _app_key,
        "app_secret": _app_secret,
        "app_billing_email": _user_email,
        "app_route_policy": APP_POLICY.BROADCAST,
    }

    if _company_name != None and len(_company_name) > 0:
        _app_values["company_name"] = _company_name

    _row = AppInfo(**_app_values)
    _row.async_add()
    _row.create_redis_keys(_redis)

    _data_uuid = str(uuid.uuid1())
    _data = {
        "uuid": _data_uuid,
        "user_uuid": _user_uuid,
        "app_uuid": _app_uuid,
        "is_owner_user": True,
        "is_service_user": True,
        "is_distributor_user": True,
        "is_portal_user": False
    }
    _row = AppUserData(**_data)
    _row.async_add()
    _row.create_redis_keys(_redis)

    # create api_info
    _create_kefu_client_apiinfo(_handler, _user_uuid, _app_uuid)
    _create_console_client_apiinfo(_handler, _user_uuid, _app_uuid)
    return _app_values
Ejemplo n.º 4
0
    def _create_team(self, _request):
        from ppmessage.db.models import AppInfo
        
        _app_name = _request.get("team_name")
        _app_uuid = str(uuid.uuid1())
        _user_uuid = self._user_uuid
        _app_key = str(uuid.uuid1())
        _app_secret = str(uuid.uuid1())

        _row = AppInfo(uuid=_app_uuid, 
                       app_name=_app_name,
                       user_uuid=_user_uuid,
                       app_key=_app_key,
                       app_secret=_app_secret)
        _row.create_redis_keys(self.application.redis)
        _row.async_add(self.application.redis)
        self._app_uuid = _app_uuid
        return True
Ejemplo n.º 5
0
    def _create_team(self, _request):
        from ppmessage.db.models import AppInfo
        
        _app_name = _request.get("team_name")
        _app_uuid = str(uuid.uuid1())
        _user_uuid = self._user_uuid
        _app_key = str(uuid.uuid1())
        _app_secret = str(uuid.uuid1())

        _row = AppInfo(uuid=_app_uuid, 
                       app_name=_app_name,
                       user_uuid=_user_uuid,
                       app_key=_app_key,
                       app_secret=_app_secret)
        _row.create_redis_keys(self.application.redis)
        _row.async_add(self.application.redis)
        self._app_uuid = _app_uuid
        return True
Ejemplo n.º 6
0
def create_app(_handler, _app_name, _user_uuid):
    _redis = _handler.application.redis                               

    _app_key = str(uuid.uuid1())
    _app_secret = str(uuid.uuid1())
    _app_uuid = str(uuid.uuid1())
    _user_email = _redis.hget(DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_email")
    _company_name = _redis.hget(DeviceUser.__tablename__ + ".uuid." + _user_uuid, "user_company")

    _app_values = {
        "uuid": _app_uuid,
        "user_uuid": _user_uuid,
        "app_name": _app_name,
        "app_key": _app_key,
        "app_secret": _app_secret,
        "app_billing_email": _user_email,
        "app_route_policy": APP_POLICY.BROADCAST,
    }
    
    if _company_name != None and len(_company_name) > 0:
        _app_values["company_name"] = _company_name
        
    _row = AppInfo(**_app_values)
    _row.async_add()
    _row.create_redis_keys(_redis)
                
    _data_uuid = str(uuid.uuid1())
    _data = {
        "uuid": _data_uuid,
        "user_uuid": _user_uuid,
        "app_uuid": _app_uuid,
        "is_owner_user": True,
        "is_service_user": True,
        "is_distributor_user": True,
        "is_portal_user": False
    }
    _row = AppUserData(**_data)
    _row.async_add()
    _row.create_redis_keys(_redis)

    # create api_info
    _create_kefu_client_apiinfo(_handler, _user_uuid, _app_uuid)
    _create_console_client_apiinfo(_handler, _user_uuid, _app_uuid)
    return _app_values