1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from mediagoblin
.tools
.mail
import send_email
18 from mediagoblin
.tools
.template
import render_template
19 from mediagoblin
import mg_globals
21 def send_comment_email(user
, comment
, media
, request
):
23 Sends comment email to user when a comment is made on their media.
26 - user: the user object to whom the email is sent
27 - comment: the comment object referencing user's media
28 - media: the media object the comment is about
29 - request: the request
32 comment_url
= u
'http://{host}{comment_uri}'.format(
34 comment_uri
=request
.urlgen(
35 'mediagoblin.user_pages.media_home.view_comment',
36 comment
= comment
._id
,
37 user
= media
.get_uploader
.username
,
38 media
= media
.slug_or_id
) + '#comment')
40 comment_author
= comment
.get_author
['username']
42 rendered_email
= render_template(
43 request
, 'mediagoblin/user_pages/comment_email.txt',
44 {'username':user
.username
,
45 'comment_author':comment_author
,
46 'comment_content':comment
.content
,
47 'comment_url':comment_url
})
50 mg_globals
.app_config
['email_sender_address'],
52 'GNU MediaGoblin - {comment_author} commented on your post'.format(
53 comment_author
=comment_author
),