Subversion Repositories SmartDukaan

Rev

Rev 18020 | Rev 18486 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18020 Rev 18247
Line 140... Line 140...
140
        response = requests.post(GCM_URL, data=post_data_json, headers=headers)
140
        response = requests.post(GCM_URL, data=post_data_json, headers=headers)
141
        logging.debug('User Id:- '+str(notificationRecord.userId)+' Response :-'+str(response.text))
141
        logging.debug('User Id:- '+str(notificationRecord.userId)+' Response :-'+str(response.text))
142
        result = json.loads(response.text)
142
        result = json.loads(response.text)
143
        
143
        
144
        if result["success"]:
144
        if result["success"]:
145
            update_params = { 'user_id' : notificationRecord.userId,  'notification_campaign_id' : notificationRecord.campaignId, 'type' : 'sent', 'status':1, 'message':'success' }
145
            update_params = { 'user_id' : notificationRecord.userId,  'notification_campaign_id' : notificationRecord.campaignId, 'oldType':'pending', 'type' : 'sent', 'status':1, 'message':'success' }
146
            encoded_update_params = urllib.urlencode(update_params)
146
            encoded_update_params = urllib.urlencode(update_params)
147
            updateReq = urllib2.Request(PUSH_NOTIFICATIONS_UPDATE_URL+encoded_update_params)
147
            updateReq = urllib2.Request(PUSH_NOTIFICATIONS_UPDATE_URL+encoded_update_params)
148
            updateResponse = urllib2.urlopen(updateReq)
148
            updateResponse = urllib2.urlopen(updateReq)
149
            response_str = updateResponse.read()
149
            response_str = updateResponse.read()
150
            logging.debug('User Id:- '+str(notificationRecord.userId)+' Update Response :-'+str(response_str))
150
            logging.debug('User Id:- '+str(notificationRecord.userId)+' Update Response :-'+str(response_str))
151
        else:
151
        else:
152
            update_params = { 'user_id' : notificationRecord.userId,  'notification_campaign_id' : notificationRecord.campaignId, 'type' : 'sent', 'status':0, 'message':result["results"][0]["error"] }
152
            update_params = { 'user_id' : notificationRecord.userId,  'notification_campaign_id' : notificationRecord.campaignId, 'oldType':'pending', 'type' : 'sent', 'status':0, 'message':result["results"][0]["error"] }
153
            encoded_update_params = urllib.urlencode(update_params)
153
            encoded_update_params = urllib.urlencode(update_params)
154
            updateReq = urllib2.Request(PUSH_NOTIFICATIONS_UPDATE_URL+encoded_update_params)
154
            updateReq = urllib2.Request(PUSH_NOTIFICATIONS_UPDATE_URL+encoded_update_params)
155
            updateResponse = urllib2.urlopen(updateReq)
155
            updateResponse = urllib2.urlopen(updateReq)
156
            response_str = updateResponse.read()
156
            response_str = updateResponse.read()
157
            logging.debug('User Id:- '+str(notificationRecord.userId)+' Update Response :-'+str(response_str))
157
            logging.debug('User Id:- '+str(notificationRecord.userId)+' Update Response :-'+str(response_str))