fix: use local instance
This commit is contained in:
parent
5f25431182
commit
9416c27971
@ -80,12 +80,26 @@ def send_request(target, object_iri):
|
||||
def send_email_on_notification(sender, instance, created, **kwargs):
|
||||
if created and instance.summary and settings.JABBER_DEFAULT_HOST and instance.user.email:
|
||||
try:
|
||||
who = requests.get(instance.author).json()['name'] or 'Unknown Person' # I've no idea how to handle dead links.
|
||||
where = requests.get(instance.object).json()['name'] or 'some unknown place' # So let's get to the unknown :)
|
||||
if(instance.author == instance.object):
|
||||
if instance.author.startswith(settings.SITE_URL):
|
||||
who = str(Model.resolve_id(instance.author.replace(settings.SITE_URL,'')))
|
||||
else:
|
||||
who = requests.get(instance.author).json()['name']
|
||||
except:
|
||||
who = "Unknown Person"
|
||||
|
||||
try:
|
||||
if instance.object.startswith(settings.SITE_URL):
|
||||
where = str(Model.resolve_id(instance.object.replace(settings.SITE_URL,'')))
|
||||
else:
|
||||
where = requests.get(instance.object).json()['name']
|
||||
except:
|
||||
where = "Unknown place"
|
||||
|
||||
if(who == where):
|
||||
where = "has sent you a private message"
|
||||
else:
|
||||
where = "mention you on " + where
|
||||
|
||||
html_message = loader.render_to_string(
|
||||
'email.html',
|
||||
{
|
||||
@ -95,6 +109,7 @@ def send_email_on_notification(sender, instance, created, **kwargs):
|
||||
'object': where
|
||||
}
|
||||
)
|
||||
|
||||
send_mail(
|
||||
'Notification on ' + settings.JABBER_DEFAULT_HOST,
|
||||
instance.summary,
|
||||
@ -103,8 +118,3 @@ def send_email_on_notification(sender, instance, created, **kwargs):
|
||||
fail_silently=True,
|
||||
html_message=html_message
|
||||
)
|
||||
except:
|
||||
logging.error('Djangoldp_notifications: Can\'t mail the user')
|
||||
else:
|
||||
if created:
|
||||
raise Exception('Djangoldp_notifications: Misconfiguration, missing JABBER_DEFAULT_HOST or no mail for user found')
|
||||
|
Loading…
Reference in New Issue
Block a user