| Line 32... |
Line 32... |
| 32 |
}
|
32 |
}
|
| 33 |
|
33 |
|
| 34 |
db = MySQLdb.connect('localhost',"root","shop2020","dtr" )
|
34 |
db = MySQLdb.connect('localhost',"root","shop2020","dtr" )
|
| 35 |
cursor = db.cursor()
|
35 |
cursor = db.cursor()
|
| 36 |
|
36 |
|
| 37 |
PUSH_NOTIFICATIONS_SQL = "select p.id, p.user_id, n.*, g.gcm_regid from pushnotifications p join notification_campaigns n on p.notification_campaign_id = n.id left outer join (select * from (select * from gcm_users order by id desc) as X group by user_id) as g on p.user_id = g.user_id where p.type ='pending'"
|
37 |
PUSH_NOTIFICATIONS_SQL = "select p.id, p.user_id, n.*, g.gcm_regid from pushnotifications p join notification_campaigns n on p.notification_campaign_id = n.id left outer join (select * from (select * from gcm_users order by id desc) as X group by user_id, imeinumber) as g on p.user_id = g.user_id where p.type ='pending'"
|
| 38 |
ALL_STORES_SQL = "select * from stores"
|
38 |
ALL_STORES_SQL = "select * from stores"
|
| 39 |
|
39 |
|
| 40 |
cursor.execute(ALL_STORES_SQL)
|
40 |
cursor.execute(ALL_STORES_SQL)
|
| 41 |
result_stores = cursor.fetchall()
|
41 |
result_stores = cursor.fetchall()
|
| 42 |
domainStoresMap = {}
|
42 |
domainStoresMap = {}
|
| Line 108... |
Line 108... |
| 108 |
json_result = json.loads(urllib2.urlopen(pushpostrequest).read())
|
108 |
json_result = json.loads(urllib2.urlopen(pushpostrequest).read())
|
| 109 |
notificationRecord.url = json_result['url']
|
109 |
notificationRecord.url = json_result['url']
|
| 110 |
logging.debug('User Id:-'+str(notificationRecord.userId)+' Notification Url:- '+ str(notificationRecord.url))
|
110 |
logging.debug('User Id:-'+str(notificationRecord.userId)+' Notification Url:- '+ str(notificationRecord.url))
|
| 111 |
else:
|
111 |
else:
|
| 112 |
notificationRecord.url = notificationRecord.url+'?user_id='+str(notificationRecord.userId)
|
112 |
notificationRecord.url = notificationRecord.url+'?user_id='+str(notificationRecord.userId)
|
| - |
|
113 |
logging.debug('User Id:-'+str(notificationRecord.userId)+' Notification Url:- '+ str(notificationRecord.url))
|
| 113 |
|
114 |
|
| 114 |
data = {"message":notificationRecord.message,"cid":notificationRecord.campaignId,"title":notificationRecord.title,
|
115 |
data = {"message":notificationRecord.message,"cid":notificationRecord.campaignId,"title":notificationRecord.title,
|
| 115 |
"type":notificationRecord.type,"url":notificationRecord.url,"vibrate":1,"sound":1,"largeIcon":"large_icon",
|
116 |
"type":notificationRecord.type,"url":notificationRecord.url,"vibrate":1,"sound":1,"largeIcon":"large_icon",
|
| 116 |
"smallIcon":"small_icon"}
|
117 |
"smallIcon":"small_icon"}
|
| 117 |
|
118 |
|
| Line 129... |
Line 130... |
| 129 |
logging.debug('User Id:- '+str(notificationRecord.userId)+' Response :-'+str(response.text))
|
130 |
logging.debug('User Id:- '+str(notificationRecord.userId)+' Response :-'+str(response.text))
|
| 130 |
result = json.loads(response.text)
|
131 |
result = json.loads(response.text)
|
| 131 |
pushnotification = Pushnotifications.get_by(id=notificationRecord.pushNotificationId)
|
132 |
pushnotification = Pushnotifications.get_by(id=notificationRecord.pushNotificationId)
|
| 132 |
|
133 |
|
| 133 |
if result["success"]:
|
134 |
if result["success"]:
|
| - |
|
135 |
if pushnotification.message is None or pushnotification.message!="success":
|
| 134 |
pushnotification.type = "sent"
|
136 |
pushnotification.type = "sent"
|
| 135 |
pushnotification.status = True
|
137 |
pushnotification.status = True
|
| 136 |
pushnotification.message = "success"
|
138 |
pushnotification.message = "success"
|
| 137 |
session.commit()
|
139 |
session.commit()
|
| 138 |
else:
|
140 |
else:
|
| 139 |
pushnotification.type = "sent"
|
141 |
pushnotification.type = "sent"
|
| 140 |
pushnotification.status = False
|
142 |
pushnotification.status = False
|
| 141 |
pushnotification.message = result["results"][0]["error"]
|
143 |
pushnotification.message = result["results"][0]["error"]
|
| 142 |
|
144 |
|