def save_canarydrop(canarydrop=None): """Persist a Canarydrop into the Redis instance. Arguments: canarydrop -- Canarydrop object. """ if not canarydrop: raise ValueError canarytoken = canarydrop.canarytoken db.hmset(KEY_CANARYDROP+canarytoken.value(), canarydrop.serialize()) log.info('Saved canarydrop: {canarydrop}'.format( canarydrop=canarydrop.serialize())) #if the canarydrop is new, save to the timeline if db.zscore(KEY_CANARYDROPS_TIMELINE, canarytoken.value()) == None: current_time = datetime.datetime.utcnow().strftime("%s.%f") db.zadd(KEY_CANARYDROPS_TIMELINE, current_time, canarytoken.value()) if canarydrop['alert_email_recipient']: add_email_token_idx(canarydrop['alert_email_recipient'],canarytoken.value()) if canarydrop['alert_webhook_url']: add_webhook_token_idx(canarydrop['alert_webhook_url'],canarytoken.value())
def save_canarydrop(canarydrop=None): """Persist a Canarydrop into the Redis instance. Arguments: canarydrop -- Canarydrop object. """ if not canarydrop: raise ValueError canarytoken = canarydrop.canarytoken db.hmset(KEY_CANARYDROP+canarytoken.value(), canarydrop.serialize()) log.msg('Saved canarydrop: {canarydrop}'.format( canarydrop=canarydrop.serialize())) #if the canarydrop is new, save to the timeline if db.zscore(KEY_CANARYDROPS_TIMELINE, canarytoken.value()) == None: current_time = datetime.datetime.utcnow().strftime("%s.%f") db.zadd(KEY_CANARYDROPS_TIMELINE, current_time, canarytoken.value())