Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for #81: log email_relay events #82

Merged
merged 1 commit into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions emails/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from datetime import datetime
from email.utils import parseaddr
from hashlib import sha256
import json
import logging

from decouple import config
from socketlabs.injectionapi import SocketLabsClient
Expand All @@ -18,6 +20,9 @@
from .models import RelayAddress, Profile


logger = logging.getLogger('events')


@csrf_exempt
def index(request):
if (not request.user.is_authenticated and
Expand Down Expand Up @@ -144,6 +149,13 @@ def _inbound_logic(json_body):
print(e)
return HttpResponse("Address does not exist")

logger.info('email_relay', extra={
'relay_address_id': relay_address.id,
'relay_address': sha256(local_portion.encode('utf-8')).hexdigest(),
'real_address': sha256(
relay_address.user.email.encode('utf-8')
).hexdigest(),
})
# Forward to real email address
sl_message = BasicMessage()
sl_message.subject = subject
Expand Down
4 changes: 4 additions & 0 deletions privaterelay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@
'handlers': ['console'],
'level': 'DEBUG',
},
'events': {
'handlers': ['console'],
'level': 'INFO',
},
}
}

Expand Down