Revision a74ba506 snf-pithos-app/pithos/api/dispatch.py
b/snf-pithos-app/pithos/api/dispatch.py | ||
---|---|---|
5 | 5 |
from pithos.backends import connect_backend |
6 | 6 |
from pithos.api.util import hashmap_md5 |
7 | 7 |
|
8 |
from django.core.mail import send_mail |
|
9 |
from django.utils.translation import ugettext as _ |
|
10 |
|
|
11 |
from astakos.im.settings import DEFAULT_FROM_EMAIL |
|
12 |
|
|
8 | 13 |
def update_md5(m): |
9 | 14 |
if m['resource'] != 'object' or m['details']['action'] != 'object update': |
10 | 15 |
return |
... | ... | |
33 | 38 |
print 'WARNING: Can not update checksum for path "%s" (%s)' % (path, e) |
34 | 39 |
|
35 | 40 |
backend.close() |
41 |
|
|
42 |
def send_sharing_notification(m): |
|
43 |
if m['resource'] != 'sharing': |
|
44 |
return |
|
45 |
|
|
46 |
members = m['details']['members'] |
|
47 |
user = m['details']['user'] |
|
48 |
path = m['value'] |
|
49 |
account, container, name = path.split('/', 2) |
|
50 |
|
|
51 |
subject = 'Invitation to a Pithos+ shared object' |
|
52 |
from_email = DEFAULT_FROM_EMAIL |
|
53 |
recipient_list = members |
|
54 |
message = 'User %s has invited you to a Pithos+ shared object. You can view it under "Shared to me" at "%s".' %(user, path) |
|
55 |
try: |
|
56 |
send_mail(subject, message, from_email, recipient_list) |
|
57 |
print 'INFO: Sharing notification sent for path "%s" to %s' % (path, ','.join(recipient_list)) |
|
58 |
except (SMTPException, socket.error) as e: |
|
59 |
print 'WARNING: Can not update send email for sharing "%s" (%s)' % (path, e) |
Also available in: Unified diff