def send_share_notification(share_id):
"""Super simple you're content has been shared notification to a user."""
if settings.DEBUG:
return
try:
content = Content.objects.get(id=share_id, content_type=ContentType.SHARE, share_of__local=True)
except Content.DoesNotExist:
logger.warning("No share content found with id %s", share_id)
return
content_url = "%s%s" % (settings.SOCIALHOME_URL, content.share_of.get_absolute_url())
subject = _("New share of: %s" % content.share_of.short_text_inline)
context = get_common_context()
context.update({
"subject": subject, "actor_name": content.author.name_or_handle,
"actor_url": "%s%s" % (settings.SOCIALHOME_URL, content.author.get_absolute_url()),
"content_url": content_url, "name": content.share_of.author.name_or_handle,
})
send_mail(
"%s%s" % (settings.EMAIL_SUBJECT_PREFIX, subject),
render_to_string("notifications/share.txt", context=context),
settings.DEFAULT_FROM_EMAIL,
[content.share_of.author.user.email],
fail_silently=False,
html_message=render_to_string("notifications/share.html", context=context),
)
评论列表
文章目录