def mark_delta_report_as_read(domain, last_read=None): """Update the "last-read" date for delta report.""" if last_read is None: last_read = datetime.datetime.now() db.set( 'delta_report_read:{}'.format(domain), last_read.strftime('%Y-%m-%dT%H:%M:%SZ') )
def update_last_email_sub_sent_date(sub_id, when=None): """Note that an email has been sent for a subscription.""" if when is None: when = datetime.datetime.now() db.set( 'email_sub_last_sent:{}'.format(sub_id), when.strftime( '%Y-%m-%dT%H:%M:%SZ' ) )
def update_resolution_report(domain, report=None, updated=None): """Update the resolution report for a domain.""" if report is None: report = {} if updated is None: updated = datetime.datetime.now() db.set('resolution_report:{}'.format(domain), report) db.set( 'resolution_report_updated:{}'.format(domain), updated.strftime('%Y-%m-%dT%H:%M:%SZ') )
def update_delta_report(domain, delta=None, updated=None): """Update the delta report for a domain.""" if delta is None: delta = {'new': [], 'updated': [], 'deleted': []} if updated is None: updated = datetime.datetime.now() db.set('delta_report:{}'.format(domain), delta) db.set( 'delta_report_updated:{}'.format(domain), updated.strftime('%Y-%m-%dT%H:%M:%SZ') )
def propose_subscription(verify_code, email_address, domain): """Store that a sub has been proposed (pending email verification).""" db.set( 'email_sub_pending:{}'.format(verify_code), { 'email_address': email_address, 'domain': domain, 'since': datetime.datetime.now().strftime( '%Y-%m-%dT%H:%M:%SZ' ), } )
def subscribe_email(sub_id, email_address, domain): """Add a subscription for an email to a domain.""" db.set('email_sub:{}'.format(sub_id), { 'email_address': email_address, 'domain': domain, })
def register_domain(domain): """Register a new domain for reporting. If the domain is already registered this is a no-op. """ db.set('registered_for_reporting:{}'.format(domain), True)