| Line 37... |
Line 37... |
| 37 |
expireTimeCondition = datetime.now()+timedelta(hours=2)
|
37 |
expireTimeCondition = datetime.now()+timedelta(hours=2)
|
| 38 |
eligibleSmsNotficationCampaigns = list(get_mongo_connection(host=mongoHost).User.notificationcampaigns.find({'notification_processed':1, 'sendsms':1, 'smsprocessed':0,'created':{'$lte':to_java_date(timeCondition)}, 'expiresat':{'$gte':to_java_date(expireTimeCondition)}}))
|
38 |
eligibleSmsNotficationCampaigns = list(get_mongo_connection(host=mongoHost).User.notificationcampaigns.find({'notification_processed':1, 'sendsms':1, 'smsprocessed':0,'created':{'$lte':to_java_date(timeCondition)}, 'expiresat':{'$gte':to_java_date(expireTimeCondition)}}))
|
| 39 |
for notificationCampaign in eligibleSmsNotficationCampaigns:
|
39 |
for notificationCampaign in eligibleSmsNotficationCampaigns:
|
| 40 |
logging.debug('Notification_Campign_Id:- '+str(notificationCampaign.get('_id')))
|
40 |
logging.debug('Notification_Campign_Id:- '+str(notificationCampaign.get('_id')))
|
| 41 |
get_mongo_connection(host=mongoHost).User.notificationcampaigns.update({'_id':notificationCampaign.get('_id')},{"$set":{'smsprocessed':1}})
|
41 |
get_mongo_connection(host=mongoHost).User.notificationcampaigns.update({'_id':notificationCampaign.get('_id')},{"$set":{'smsprocessed':1}})
|
| 42 |
pushnotifications = list(get_mongo_connection(host=mongoHost).User.pushnotifications.find({'notification_campaign_id':str(notificationCampaign.get('_id'))}))
|
42 |
pushnotifications = list(get_mongo_connection(host=mongoHost).User.pushnotifications.find({'notification_campaign_id':notificationCampaign.get('_id')}))
|
| 43 |
pushnotificationUsersMap = {}
|
43 |
pushnotificationUsersMap = {}
|
| 44 |
notificationSuccessUsers = []
|
44 |
notificationSuccessUsers = []
|
| 45 |
smsToBeSentUsersMap = {}
|
45 |
smsToBeSentUsersMap = {}
|
| 46 |
for entry in pushnotifications:
|
46 |
for entry in pushnotifications:
|
| 47 |
if str(entry.get('type'))!='sent' and entry.get('user_id') not in notificationSuccessUsers:
|
47 |
if str(entry.get('type'))!='sent' and entry.get('user_id') not in notificationSuccessUsers:
|
| Line 59... |
Line 59... |
| 59 |
if userId in notificationSuccessUsers:
|
59 |
if userId in notificationSuccessUsers:
|
| 60 |
continue
|
60 |
continue
|
| 61 |
entry = entries[0]
|
61 |
entry = entries[0]
|
| 62 |
smsToBeSentUsersMap[userId] = entry
|
62 |
smsToBeSentUsersMap[userId] = entry
|
| 63 |
|
63 |
|
| - |
|
64 |
if len(smsToBeSentUsersMap.keys())==0:
|
| - |
|
65 |
continue
|
| 64 |
allUsers = Users.query.filter(Users.id.in_(tuple(smsToBeSentUsersMap.keys()))).all()
|
66 |
allUsers = Users.query.filter(Users.id.in_(tuple(smsToBeSentUsersMap.keys()))).all()
|
| 65 |
|
67 |
|
| 66 |
sentSmsUsers = []
|
68 |
sentSmsUsers = []
|
| 67 |
proSmsResponseIdMap = {}
|
69 |
proSmsResponseIdMap = {}
|
| 68 |
tranSmsResponseIdMap = {}
|
70 |
tranSmsResponseIdMap = {}
|
| 69 |
|
71 |
|
| 70 |
for user in allUsers:
|
72 |
for user in allUsers:
|
| 71 |
if user.mobile_number is not None and len(user.mobile_number)==10 and user.mobile_number not in sentSmsUsers:
|
73 |
if user.mobile_number is not None and len(user.mobile_number)==10 and user.mobile_number not in sentSmsUsers:
|
| 72 |
smsUrl='http://pm1.in/A/' + num_encode(str(notificationCampaign.get('_id'))) + '/' + num_encode(user.id)
|
74 |
smsUrl='http://pm1.in/A/' + num_encode(notificationCampaign.get('_id')) + '/' + num_encode(user.id)
|
| 73 |
smstext = str(notificationCampaign.get('messagetext')) + ' ' + smsUrl
|
75 |
smstext = str(notificationCampaign.get('messagetext')) + ' ' + smsUrl
|
| 74 |
#url_params = { 'Mobile' : '91'+user.mobile_number, 'Username' : 'srlsaholicP', 'Password' : 'srp8oct' , 'MessageType' : 'txt', 'SenderID' : '090000', 'Message' : notificationCampaign.messagetext }
|
76 |
#url_params = { 'Mobile' : '91'+user.mobile_number, 'Username' : 'srlsaholicP', 'Password' : 'srp8oct' , 'MessageType' : 'txt', 'SenderID' : '090000', 'Message' : notificationCampaign.messagetext }
|
| 75 |
url_params = ''
|
77 |
url_params = ''
|
| 76 |
if "TRAN_SMS" in smstext:
|
78 |
if "TRAN_SMS" in smstext:
|
| 77 |
url_params = { 'ani' : '91'+user.mobile_number, 'uname' : 'srlsaholic', 'passwd' : 'sr18mar' , 'cli' : 'PROFTM', 'message' : smstext.replace("TRAN_SMS", "").strip() }
|
79 |
url_params = { 'ani' : '91'+user.mobile_number, 'uname' : 'srlsaholic', 'passwd' : 'sr18mar' , 'cli' : 'PROFTM', 'message' : smstext.replace("TRAN_SMS", "").strip() }
|