Exemple #1
0
    def event_toughcloud_mail_account_open(self, userinfo):
        """ toughCloud mail api open notify without password event """
        if not userinfo:
            return

        if not userinfo.get('email'):
            logger.error('user email is None exit')
            return

        try:
            api_secret = self.get_param_value("toughcloud_license")
            service_mail = self.get_param_value("toughcloud_service_mail")
            if not service_mail:
                return
            api_token = yield tools.get_sys_token()
            params = dict(token=api_token.strip(),
                          action='email',
                          mailto=userinfo.get('email'),
                          tplname=self.MAIL_TPLNAME,
                          customer=utils.safestr(userinfo.get('realname')),
                          username=userinfo.get('account_number'),
                          product=utils.safestr(userinfo.get('product_name')),
                          expire=userinfo.get('expire_date'),
                          service_call=self.get_param_value(
                              "toughcloud_service_call", ''),
                          service_mail=service_mail,
                          nonce=str(int(time.time())))
            params['sign'] = apiutils.make_sign(api_secret.strip(),
                                                params.values())
            resp = yield httpclient.fetch(self.MAIL_APIURL,
                                          postdata=urlencode(params))
            logger.info(resp.body)
            logger.info('open account send email without password success')
        except Exception as err:
            logger.exception(err)
    def event_toughcloud_mail_account_expire(self, userinfo):
        """ toughcloud mail api notify event """
        if not userinfo:
            return

        api_secret = self.get_param_value("toughcloud_license")
        service_mail=self.get_param_value("toughcloud_service_mail")
        if not service_mail:
            return
        api_token = yield tools.get_sys_token()
        params = dict(
            token=api_token.strip(),
            mailto=userinfo.email,
            tplname=self.MAIL_TPLNAME,
            customer=utils.safestr(userinfo.realname),
            username=userinfo.account_number,
            product=utils.safestr(userinfo.product_name),
            expire=userinfo.expire_date,
            service_call=self.get_param_value("toughcloud_service_call",''),
            service_mail=service_mail,
            nonce = str(int(time.time()))
        )
        params['sign'] = apiutils.make_sign(api_secret.strip(), params.values())
        try:
            resp = yield httpclient.fetch(self.MAIL_APIURL, postdata=urlencode(params))
            logger.info(resp.body)
        except Exception as err:
            logger.exception(err)
Exemple #3
0
    def event_toughcloud_sms_account_open(self, userinfo):
        """ toughCloud sms api open notify event """
        if not userinfo:
            return

        if not userinfo.get('phone'):
            logger.error('user phone is None exit')
            return

        api_secret = self.get_param_value("toughcloud_license")
        api_token = yield tools.get_sys_token()
        params = dict(token=api_token.strip(),
                      action='sms',
                      tplname=self.SMS_TPLNAME,
                      phone=userinfo.get('phone'),
                      customer=utils.safestr(userinfo.get('realname')),
                      username=userinfo.get('account_number'),
                      product=utils.safestr(userinfo.get('product_name')),
                      password=userinfo.get('password'),
                      expire=userinfo.get('expire_date'),
                      nonce=str(int(time.time())))
        params['sign'] = apiutils.make_sign(api_secret.strip(),
                                            params.values())
        try:
            resp = yield httpclient.fetch(self.SMS_APIURL,
                                          postdata=urlencode(params))
            logger.info(resp.body)
            logger.info('open account send short message success')
        except Exception as err:
            logger.exception(err)
    def event_toughcloud_mail_account_open(self, userinfo):
        """ toughCloud mail api open notify without password event """
        if not userinfo:
            return

        if not userinfo.get('email'):
            logger.error('user email is None exit')
            return

        try:
            api_secret = self.get_param_value("toughcloud_license")
            service_mail = self.get_param_value("toughcloud_service_mail")
            if not service_mail:
                return
            api_token = yield tools.get_sys_token()
            params = dict(
                token=api_token.strip(),
                action='email',
                mailto=userinfo.get('email'),
                tplname=self.MAIL_TPLNAME,
                customer=utils.safestr(userinfo.get('realname')),
                username=userinfo.get('account_number'),
                product=utils.safestr(userinfo.get('product_name')),
                expire=userinfo.get('expire_date'),
                service_call=self.get_param_value("toughcloud_service_call", ''),
                service_mail=service_mail,
                nonce=str(int(time.time()))
            )
            params['sign'] = apiutils.make_sign(api_secret.strip(), params.values())
            resp = yield httpclient.fetch(self.MAIL_APIURL, postdata=urlencode(params))
            logger.info(resp.body)
            logger.info('open account send email without password success')
        except Exception as err:
            logger.exception(err)
    def event_toughcloud_sms_account_open(self, userinfo):
        """ toughCloud sms api open notify event """
        if not userinfo:
            return

        if not userinfo.get('phone'):
            logger.error('user phone is None exit')
            return

        api_secret = self.get_param_value("toughcloud_license")
        api_token = yield tools.get_sys_token()
        params = dict(
            token=api_token.strip(),
            action='sms',
            tplname=self.SMS_TPLNAME,
            phone=userinfo.get('phone'),
            customer=utils.safestr(userinfo.get('realname')),
            username=userinfo.get('account_number'),
            product=utils.safestr(userinfo.get('product_name')),
            password=userinfo.get('password'),
            expire=userinfo.get('expire_date'),
            nonce=str(int(time.time()))
        )
        params['sign'] = apiutils.make_sign(api_secret.strip(), params.values())
        try:
            resp = yield httpclient.fetch(self.SMS_APIURL, postdata=urlencode(params))
            logger.info(resp.body)
            logger.info('open account send short message success')
        except Exception as err:
            logger.exception(err)
Exemple #6
0
    def event_toughcloud_mail_account_expire(self, userinfo):
        """ toughcloud mail api notify event """
        if not userinfo:
            return

        api_secret = self.get_param_value("toughcloud_license")
        service_mail = self.get_param_value("toughcloud_service_mail")
        if not service_mail:
            return
        api_token = yield tools.get_sys_token()
        params = dict(token=api_token.strip(),
                      mailto=userinfo.email,
                      tplname=self.MAIL_TPLNAME,
                      customer=utils.safestr(userinfo.realname),
                      username=userinfo.account_number,
                      product=utils.safestr(userinfo.product_name),
                      expire=userinfo.expire_date,
                      service_call=self.get_param_value(
                          "toughcloud_service_call", ''),
                      service_mail=service_mail,
                      nonce=str(int(time.time())))
        params['sign'] = apiutils.make_sign(api_secret.strip(),
                                            params.values())
        try:
            resp = yield httpclient.fetch(self.MAIL_APIURL,
                                          postdata=urlencode(params))
            logger.info(resp.body)
        except Exception as err:
            logger.exception(err)
Exemple #7
0
 def event_toughcloud_mail_account_expire(self, userinfo):
     """ toughcloud mail api notify event """
     api_secret = self.get_param_value("toughcloud_api_secret", "")
     if not userinfo:
         return
     params = dict(sid=tools.get_sys_uuid(),
                   tplname=self.MAIL_TPLNAME,
                   customer=utils.safestr(userinfo.realname),
                   username=userinfo.account_number,
                   product=utils.safestr(userinfo.product_name),
                   expire=userinfo.expire_date,
                   service_call=self.get_param_value("service_call", ''),
                   service_mail=self.get_param_value("service_mail", ''),
                   nonce=str(int(time.time())))
     params['sign'] = apiutils.make_sign(api_secret, params.values())
     d = httpclient.fetch(self.MAIL_APIURL, postdata=urlencode(params))
     d.addCallback(lambda r: logger.info(r.body)).addErrback(
         logger.exception)
     return d
 def event_toughcloud_mail_account_expire(self, userinfo):
     """ toughcloud mail api notify event """
     api_secret = self.get_param_value("toughcloud_api_secret","")
     if not userinfo:
         return
     params = dict(
         sid=tools.get_sys_uuid(),
         tplname=self.MAIL_TPLNAME,
         customer=utils.safestr(userinfo.realname),
         username=userinfo.account_number,
         product=utils.safestr(userinfo.product_name),
         expire=userinfo.expire_date,
         service_call=self.get_param_value("service_call",''),
         service_mail=self.get_param_value("service_mail",''),
         nonce = str(int(time.time()))
     )
     params['sign'] = apiutils.make_sign(api_secret, params.values())
     d = httpclient.fetch(self.MAIL_APIURL, postdata=urlencode(params))
     d.addCallback(lambda r:logger.info(r.body)).addErrback(logger.exception)
     return d