فهرست منبع

修改推送图片,限制低电量每24小时推一次

locky 2 سال پیش
والد
کامیت
adf39a488a
1فایلهای تغییر یافته به همراه9 افزوده شده و 2 حذف شده
  1. 9 2
      Controller/DetectControllerV2.py

+ 9 - 2
Controller/DetectControllerV2.py

@@ -346,10 +346,9 @@ class NotificationView(View):
         logger = logging.getLogger('info')
         logger.info('推送图片测试:{} {} {} {} {} {} {} {}'.format(push_type, uid, appBundleId, token_val, event_type, n_time,
                                                             msg_title, msg_text))
-        time.sleep(3)
         try:
             image_url = aws_s3_client.generate_presigned_url('get_object', Params={'Bucket': bucket, 'Key': key},
-                                                             ExpiresIn=86400)
+                                                             ExpiresIn=300)
             logger.info('推送图片url:{}'.format(image_url))
             if push_type == 0:
                 GatewayPushService.ios_apns_push(uid, appBundleId, token_val, n_time, event_type, msg_title, msg_text,
@@ -797,6 +796,14 @@ class PWnotificationView(View):
     def validation(self, request_dict):
         logger = logging.getLogger('info')
         uid = request_dict.get('uid', None)
+
+        # 限制每24小时推一次
+        redisObj = RedisObject()
+        is_limit = redisObj.CONN.setnx(uid+'limit_power_warning', 1)
+        redisObj.CONN.expire(uid+'limit_power_warning', 24*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))