def _create(self, _ppcom_trace_uuid):
        _redis = self.application.redis
        _key = DeviceUser.__tablename__ + ".ppcom_trace_uuid." + _ppcom_trace_uuid
        _uuid = _redis.get(_key)

        if _uuid != None:
            _user = redis_hash_to_dict(_redis, DeviceUser, _uuid)
            if _user != None:
                _rdata = self.getReturnData()
                _rdata["user_uuid"] = _uuid
                _rdata["user_email"] = _user["user_email"]
                _rdata["user_fullname"] = _user["user_fullname"]
                _rdata["user_icon"] = _user["user_icon"]
                return
        
        _du_uuid = str(uuid.uuid1())
        _user_email = _du_uuid[:6] + "@" + self.app_uuid[:6]
        _user_name = self._unknown_user_name()
        
        _values = {
            "uuid": _du_uuid,
            "ppcom_trace_uuid": _ppcom_trace_uuid,
            "user_status": USER_STATUS.ANONYMOUS,
            "is_anonymous_user": True,
            "user_name": _user_name,
            "user_email": _user_email,
            "user_fullname": _user_name,
            "user_icon": create_user_icon(_du_uuid),
        }
        
        _row = DeviceUser(**_values)
        _row.async_add(self.application.redis)
        _row.create_redis_keys(self.application.redis)

        _data_uuid = str(uuid.uuid1())
        _values = {
            "uuid": _data_uuid,
            "user_uuid": _du_uuid,
            "app_uuid": self.app_uuid,
            "is_portal_user": True,
            "is_service_user": False,
            "is_owner_user": False,
            "is_distributor_user": False,
        }
        _row = AppUserData(**_values)
        _row.async_add(self.application.redis)
        _row.create_redis_keys(self.application.redis)
        
        _rdata = self.getReturnData()
        _rdata["user_uuid"] = _du_uuid
        _rdata["user_fullname"] = _user_name
        _rdata["user_email"] = _user_email
        _rdata["user_name"] = _user_name

        _ip = self.request.headers.get("X-Real-Ip") or self.request.headers.get("remote_ip") or self.request.remote_ip
        logging.info(str(self.request.headers))
        logging.info("create anonymous ip: %s" % _ip)
        IOLoop.instance().spawn_callback(self._create_user_name, user_uuid=_du_uuid, ip=_ip)
        return
    def _create(self, _ppcom_trace_uuid):
        _redis = self.application.redis
        _key = DeviceUser.__tablename__ + ".ppcom_trace_uuid." + _ppcom_trace_uuid
        _uuid = _redis.get(_key)

        if _uuid != None:
            _user = redis_hash_to_dict(_redis, DeviceUser, _uuid)
            if _user != None:
                _rdata = self.getReturnData()
                _rdata["user_uuid"] = _uuid
                _rdata["user_email"] = _user["user_email"]
                _rdata["user_fullname"] = _user["user_fullname"]
                _rdata["user_icon"] = _user["user_icon"]
                return
        
        _du_uuid = str(uuid.uuid1())
        _user_email = _du_uuid[:6] + "@" + self.app_uuid[:6]
        _user_name = self._unknown_user_name()
        
        _values = {
            "uuid": _du_uuid,
            "ppcom_trace_uuid": _ppcom_trace_uuid,
            "user_status": USER_STATUS.ANONYMOUS,
            "is_anonymous_user": True,
            "user_name": _user_name,
            "user_email": _user_email,
            "user_fullname": _user_name,
            "user_icon": create_user_icon(_du_uuid),
        }
        
        _row = DeviceUser(**_values)
        _row.async_add(self.application.redis)
        _row.create_redis_keys(self.application.redis)

        _data_uuid = str(uuid.uuid1())
        _values = {
            "uuid": _data_uuid,
            "user_uuid": _du_uuid,
            "app_uuid": self.app_uuid,
            "is_portal_user": True,
            "is_service_user": False,
            "is_owner_user": False
        }
        _row = AppUserData(**_values)
        _row.async_add(self.application.redis)
        _row.create_redis_keys(self.application.redis)
        
        _rdata = self.getReturnData()
        _rdata["user_uuid"] = _du_uuid
        _rdata["user_fullname"] = _user_name
        _rdata["user_email"] = _user_email
        _rdata["user_name"] = _user_name

        _ip = self.request.headers.get("X-Real-Ip") or self.request.headers.get("remote_ip") or self.request.remote_ip
        logging.info(str(self.request.headers))
        logging.info("create anonymous ip: %s" % _ip)
        IOLoop.instance().spawn_callback(self._create_user_name, user_uuid=_du_uuid, ip=_ip)
        return
Beispiel #3
0
def _ppmessage_random_identicon(_string):
    _count = 0
    for _i in _string:
        _count = _count + ord(_i)
    _mod = str(_count % 256)

    from ppmessage.core.utils.createicon import create_user_icon
    _url = create_user_icon(_mod)
    return _url
Beispiel #4
0
def _ppmessage_random_identicon(_string):
    _count = 0
    for _i in _string:
        _count = _count + ord(_i)
    _mod = str(_count % 256)

    from ppmessage.core.utils.createicon import create_user_icon
    _url = create_user_icon(_mod)
    return _url
Beispiel #5
0
    def _create(self, _ppcom_trace_uuid):
        _redis = self.application.redis
        _key = DeviceUser.__tablename__ + ".ppcom_trace_uuid." + _ppcom_trace_uuid
        _uuid = _redis.get(_key)
        logging.info(_key)
        if _uuid != None:
            _user = redis_hash_to_dict(_redis, DeviceUser, _uuid)
            if _user != None:
                _rdata = self.getReturnData()
                _rdata["user_uuid"] = _uuid
                _rdata["user_email"] = _user["user_email"]
                _rdata["user_fullname"] = _user["user_fullname"]
                _rdata["user_icon"] = _user["user_icon"]
                return

        _du_uuid = str(uuid.uuid1())
        _user_email = _du_uuid[:6] + "@" + self.app_uuid[:6]
        _user_name = self._create_user_name()

        _values = {
            "uuid": _du_uuid,
            "ppcom_trace_uuid": _ppcom_trace_uuid,
            "user_status": USER_STATUS.ANONYMOUS,
            "is_anonymous_user": True,
            "user_name": _user_name,
            "user_email": _user_email,
            "user_fullname": _user_name,
            "user_icon": create_user_icon(_du_uuid),
        }

        _row = DeviceUser(**_values)
        _row.async_add()
        _row.create_redis_keys(self.application.redis)

        _data_uuid = str(uuid.uuid1())
        _values = {
            "uuid": _data_uuid,
            "user_uuid": _du_uuid,
            "app_uuid": self.app_uuid,
            "is_portal_user": True,
            "is_service_user": False,
            "is_owner_user": False,
            "is_distributor_user": False,
        }
        _row = AppUserData(**_values)
        _row.async_add()
        _row.create_redis_keys(self.application.redis)

        _rdata = self.getReturnData()
        _rdata["user_uuid"] = _du_uuid
        _rdata["user_fullname"] = _user_name
        _rdata["user_email"] = _user_email
        _rdata["user_name"] = _user_name
        return
    def _create(self, _ppcom_trace_uuid):
        _redis = self.application.redis
        _key = DeviceUser.__tablename__ + ".ppcom_trace_uuid." + _ppcom_trace_uuid
        _uuid = _redis.get(_key)
        logging.info(_key)
        if _uuid != None:
            _user = redis_hash_to_dict(_redis, DeviceUser, _uuid)
            if _user != None:
                _rdata = self.getReturnData()
                _rdata["user_uuid"] = _uuid
                _rdata["user_email"] = _user["user_email"]
                _rdata["user_fullname"] = _user["user_fullname"]
                _rdata["user_icon"] = _user["user_icon"]
                return
        
        _du_uuid = str(uuid.uuid1())
        _user_email = _du_uuid[:6] + "@" + self.app_uuid[:6]
        _user_name = self._create_user_name()
        
        _values = {
            "uuid": _du_uuid,
            "ppcom_trace_uuid": _ppcom_trace_uuid,
            "user_status": USER_STATUS.ANONYMOUS,
            "is_anonymous_user": True,
            "user_name": _user_name,
            "user_email": _user_email,
            "user_fullname": _user_name,
            "user_icon": create_user_icon(_du_uuid),
        }
        
        _row = DeviceUser(**_values)
        _row.async_add(self.application.redis)
        _row.create_redis_keys(self.application.redis)

        _data_uuid = str(uuid.uuid1())
        _values = {
            "uuid": _data_uuid,
            "user_uuid": _du_uuid,
            "app_uuid": self.app_uuid,
            "is_portal_user": True,
            "is_service_user": False,
            "is_owner_user": False,
            "is_distributor_user": False,
        }
        _row = AppUserData(**_values)
        _row.async_add(self.application.redis)
        _row.create_redis_keys(self.application.redis)
        
        _rdata = self.getReturnData()
        _rdata["user_uuid"] = _du_uuid
        _rdata["user_fullname"] = _user_name
        _rdata["user_email"] = _user_email
        _rdata["user_name"] = _user_name
        return
def update_group_icon(_redis, _group_uuid):
    _key = OrgUserGroupData.__tablename__ + ".group_uuid." + _group_uuid
    _users = _redis.smembers(_key)
    _group_icon = None
    if len(_users) == 0:
        _group_icon = create_user_icon(_group_uuid)
    else:
        _group_icon = create_group_icon(_redis, _users)
    _row = OrgGroup(uuid=_group_uuid, group_icon=_group_icon)
    _row.update_redis_keys(_redis)
    _row.async_update()
    return
def update_group_icon(_redis, _group_uuid):
    _key = OrgUserGroupData.__tablename__ + ".group_uuid." + _group_uuid
    _users = _redis.smembers(_key)
    _group_icon = None
    if len(_users) == 0:
        _group_icon = create_user_icon(_group_uuid)
    else:
        _group_icon = create_group_icon(_redis, _users)
    _row = OrgGroup(uuid=_group_uuid, group_icon=_group_icon)
    _row.update_redis_keys(_redis)
    _row.async_update()
    return
    def _get(self, _app_uuid, _group_name, _group_desc):
        _redis = self.application.redis
        _uuid = str(uuid.uuid1())
        _row = OrgGroup(uuid=_uuid,
                        app_uuid=_app_uuid,
                        group_name=_group_name,
                        group_icon=create_user_icon(_uuid),
                        group_desc=_group_desc)
        _row.async_add()
        _row.create_redis_keys(_redis)

        _group = redis_hash_to_dict(_redis, OrgGroup, _row.uuid)
        if _group == None:
            self.setErrorCode(API_ERR.NO_ORG_GROUP)
            return
        _r = self.getReturnData()
        _r.update(_group)
        return
 def _get(self, _app_uuid, _group_name, _group_desc):
     _redis = self.application.redis
     _uuid = str(uuid.uuid1())
     _row = OrgGroup(
         uuid=_uuid,
         app_uuid=_app_uuid,
         group_name=_group_name,
         group_icon=create_user_icon(_uuid), 
         group_desc=_group_desc
     )
     _row.async_add()
     _row.create_redis_keys(_redis)
             
     _group = redis_hash_to_dict(_redis, OrgGroup, _row.uuid)
     if _group == None:
         self.setErrorCode(API_ERR.NO_ORG_GROUP)
         return
     _r = self.getReturnData()
     _r.update(_group)
     return