@@ -41,50 +41,5 @@ def notify(self, interests, notification):
4141 'interests' : interests ,
4242 }
4343 params .update (notification )
44- self .validate_notification (params )
4544 path = "/%s/%s/apps/%s/notifications" % (API_PREFIX , API_VERSION , self .app_id )
4645 return Request (self , POST , path , params )
47-
48- def validate_notification (self , notification ):
49- gcm_payload = notification .get ('gcm' )
50-
51- if not gcm_payload and not notification .get ('apns' ) :
52- raise ValueError ("Notification must have fields APNS or GCM" )
53-
54- if gcm_payload :
55- for restricted_key in RESTRICTED_GCM_KEYS :
56- gcm_payload .pop (restricted_key , None )
57-
58- ttl = gcm_payload .get ('time_to_live' )
59- if ttl :
60- if not isinstance (ttl , int ):
61- raise ValueError ("GCM time_to_live must be an int" )
62-
63- if not (0 <= ttl <= GCM_TTL ):
64- raise ValueError ("GCM time_to_live must be between 0 and 241920 (4 weeks)" )
65-
66- gcm_payload_notification = gcm_payload .get ('notification' )
67- if gcm_payload_notification :
68- title = gcm_payload_notification .get ('title' )
69- icon = gcm_payload_notification .get ('icon' )
70- if not isinstance (title , str ):
71- raise ValueError ("GCM notification title is required must be a string" )
72-
73- if not isinstance (icon , str ):
74- raise ValueError ("GCM notification icon is required must be a string" )
75-
76- if len (title ) is 0 :
77- raise ValueError ("GCM notification title must not be empty" )
78-
79- if len (icon ) is 0 :
80- raise ValueError ("GCM notification icon must not be empty" )
81-
82- webhook_url = notification .get ('webhook_url' )
83- webhook_level = notification .get ('webhook_level' )
84-
85- if webhook_level :
86- if not webhook_url :
87- raise ValueError ("webhook_level cannot be used without a webhook_url" )
88-
89- if not webhook_level in WEBHOOK_LEVELS :
90- raise ValueError ("webhook_level must be either INFO or DEBUG. Blank will default to INFO" )
0 commit comments