|
@@ -16,6 +16,7 @@ from pyfcm import FCMNotification
|
|
|
|
|
|
from AnsjerPush.config import JPUSH_CONFIG, FCM_CONFIG, APNS_CONFIG, BASE_DIR, APNS_MODE
|
|
|
from Model.models import UidPushModel, SysMsgModel
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
from Service.CommonService import CommonService
|
|
|
|
|
|
|
|
@@ -33,6 +34,14 @@ class PowerWarningView(View):
|
|
|
def validation(self, request_dict):
|
|
|
logger = logging.getLogger('info')
|
|
|
uid = request_dict.get('uid', None)
|
|
|
+
|
|
|
+ # 限制每6小时推一次
|
|
|
+ redisObj = RedisObject()
|
|
|
+ is_limit = redisObj.CONN.setnx(uid+'limit_power_warning', 1)
|
|
|
+ redisObj.CONN.expire(uid+'limit_power_warning', 6*60*60)
|
|
|
+ if not is_limit:
|
|
|
+ return JsonResponse(status=200, data={'code': 0, 'msg': 'push limited!'})
|
|
|
+
|
|
|
channel = request_dict.get('channel', None)
|
|
|
electricity = request_dict.get('electricity', None)
|
|
|
logger.info('调用低电量推送接口的uid: {},electricity: {}'.format(uid, electricity))
|