def update_contacts(user_id, p_contacts): logger.warning('update_contacts user_id:%s numbers:%s' % (user_id, str(p_contacts))) u_ph = col_get(USERPHONE, {"user_id" : user_id}, find='one') if u_ph: logger.warning('update_contacts user_id:%s removing existing user store' % (user_id)) col_remove(USERPHONE, {"user_id" : user_id}) new_u_ph = {'user_id' : user_id, 'contacts' : p_contacts} logger.warning('update_contacts user_id:%s adding user store' % (user_id)) nid = col_insert(USERPHONE, new_u_ph) return True
def schedule_master_activity(sid): logger.warning('schedule_master_activity sid:%s' % str(sid)) s_act = col_get(SCHEDULEDACTIVITY_, {"_id" : ObjectId(sid)}, {}, 'one') if not s_act: logger.warning('Scheduled activity %s doesnt exist, exiting' % str(s_act)) return logger.warning('schedule_master_activity creating activity %s' % str(s_act)) activity = Activity.create_activity(suggester=None, text=s_act.get('text'), expiry = s_act.get('expiry'), visibility='n', status=Activity.MASTER, confirm_msg = s_act.get('details'), where = s_act.get('where'), when = s_act.get('when'), network = s_act.get('network')) logger.warning('schedule_master_activity sid:%s aid:%s, removing scheduled act' % (str(sid), str(activity.get('_id')))) col_remove(SCHEDULEDACTIVITY_, {"_id" : ObjectId(sid)}) logger.warning('schedule_master_activity sid:%s aid:%s pushing to: %s' % (str(sid), str(activity.get('_id')), s_act.get('network'))) Activity.push_activity(activity['_id']) pull_default_hrs = get_eta(hours=settings.DEFAULT_USER_PULL_HOURS) pull_confirmed_hours = get_eta(hours=settings.CONFIRMED_USER_PULL_AFTER_WHEN_HOURS) logger.warning('schedule_master_activity sid:%s expire_activity_default:%s pull_default:%s pull_confirmed_activity_default:%s' % (str(sid), s_act.get('expiry').strftime('%Y-%m-%d %H:%M'), pull_default_hrs.strftime('%Y-%m-%d %H:%M'), pull_confirmed_hours.strftime('%Y-%m-%d %H:%M'))) expire_activity_default.apply_async(args=[activity["_id"]], eta=s_act.get('expiry')) pull_default.apply_async(args=[activity["_id"]], eta=pull_default_hrs) # pull_confirmed_activity_default.apply_async(args=[activity["_id"]], eta=pull_confirmed_hours) #Then we kick off the normal notifications notification_tasks.new_activity(activity["_id"])