Browse Source

推送V2接口优化

locky 3 năm trước cách đây
mục cha
commit
091d9d6583
1 tập tin đã thay đổi với 18 bổ sung15 xóa
  1. 18 15
      Controller/DetectControllerV2.py

+ 18 - 15
Controller/DetectControllerV2.py

@@ -99,7 +99,7 @@ class NotificationView(View):
             redisObj = RedisObject(db=6)
             have_ykey = redisObj.get_data(key=ykey)  # uid_set 数据库缓存
             have_pkey = redisObj.get_data(key=pkey)  # 一分钟限制key
-            have_dkey = redisObj.get_data(key=dkey)  # 推送类型限制
+            have_dkey = redisObj.get_data(key=dkey)  # 推送消息时间间隔
             logger.info('ykey:{}, pkey: {}, dkey: {},'.format(have_ykey, have_pkey, have_dkey))
 
             # 一分钟内不推送
@@ -128,14 +128,16 @@ class NotificationView(View):
             if not nickname:
                 nickname = uid
 
-            if detect_group == '0' or detect_group == '':
-                redisObj.set_data(key=dkey, val=1, expire=detect_interval)
-            else:
-                detect_group_list = detect_group.split(',')
-                if event_type in detect_group_list:
-                    if detect_interval < 60:
-                        detect_interval = 60
+            if not have_dkey:
+                # 设置推送消息的时间间隔
+                if detect_group == '0' or detect_group == '':
                     redisObj.set_data(key=dkey, val=1, expire=detect_interval)
+                else:
+                    detect_group_list = detect_group.split(',')
+                    if event_type in detect_group_list:
+                        if detect_interval < 60:
+                            detect_interval = 60
+                        redisObj.set_data(key=dkey, val=1, expire=detect_interval)
 
             if is_st == 1 or is_st == 3:    # 使用aws s3
                 aws_s3_client = s3_client(region=region)
@@ -170,13 +172,14 @@ class NotificationView(View):
                 kwag_args['msg_text'] = msg_text
                 logger.info('推送要的数据: {}'.format(kwag_args))
 
-                # 根据推送类型确定code
-                if push_type == 0:  # ios apns
-                    do_apns_code = self.do_apns(**kwag_args)
-                elif push_type == 1:  # android gcm
-                    do_fcm_code = self.do_fcm(**kwag_args)
-                elif push_type == 2:  # android jpush
-                    do_jpush_code = self.do_jpush(**kwag_args)
+                # 推送消息
+                if not have_dkey:
+                    if push_type == 0:  # ios apns
+                        do_apns_code = self.do_apns(**kwag_args)
+                    elif push_type == 1:  # android gcm
+                        do_fcm_code = self.do_fcm(**kwag_args)
+                    elif push_type == 2:  # android jpush
+                        do_jpush_code = self.do_jpush(**kwag_args)
 
                 # 以下是存库
                 userID_id = up["userID_id"]