예제 #1
0
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')
    )
예제 #2
0
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'
        )
    )
예제 #3
0
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')
    )
예제 #4
0
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')
    )
예제 #5
0
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'
            ),
        }
    )
예제 #6
0
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,
    })
예제 #7
0
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)