Set up comment notifications so that media owners are alerted anytime someone comments, or to alert those who have made comments that someone else has added to their thread. There are 2 types of notifications:
The Comment Notification Email alerts media owners that someone has commented on their submission.
The Thread Notification Email alerts users who previously commented on an item, that another user has added a comment to the same item.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body> {$content} </body>
</html>
<table width="500" style="font-family:Arial;"> <tr> <td style="border:1px solid #ccc; padding: 10px;"> <table> <tr> <td> <h2 style="font-size:14px;">{$$firstname},</h2> <p style="font-size:12px;"> {$$message} </p> <table width="500"> <tr> <td style="margin-top:10px; padding:10px; background-color:#e2e2e2;" width="318"> <p style=" font-size:14px;"> {$$comment} </p> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td style="padding:10px; font-size:10px; color:#505050; text-align:center;"> Check out all the entries at <a href="http://INSERT REDIRECT LINK HERE</a> </td> </tr> <tr> <td style="padding:10px; font-size:10px; color:#505050; text-align:center;"> OPT OUT FROM THE NOTIFICATIONS AT: <BR /> <a href="http://INSERT LINK TO USER PROFILE MANAGER HERE</a> </td> </tr> </table>
You will end up with:
Then create the second email template, which is for New Thread Comments:
<table width="500" style="font-family:Arial;">
<tr>
<td style="border:1px solid #ccc; padding: 10px;">
<table>
<tr>
<td>
<h2 style="font-size:14px;">{$$email_recipient_firstname},</h2>
<p style="font-size:12px;">
{$$author} just posted a comment on "{$$media_title}":</p>
<table width="500">
<tr>
<td style="margin-top:10px; padding:10px; background-color:#e2e2e2;" width="318">
<p style=" font-size:14px;">
{$$comment}
</p>
</td>
</tr>
</table> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="padding:10px; font-size:10px; color:#505050; text-align:center;">
See more at <a href="http://INSERT REDIRECT LINK TO COMMENT HERE</a>
</td>
</tr>
<tr>
<td style="padding:10px; font-size:10px; color:#505050; text-align:center;">
OPT OUT FROM THE NOTIFICATIONS AT: <BR />
<a href="http://INSERT REDIRECT LINK TO USER PROFILE MANAGER HERE</a>
</td>
</tr>
</table>
You should have 2 email templates in the end, as shown below:
See the media.insertTextFile API documentation for full details.
Below is an example API call used to create a comment and auto-approve the comment. Email notifications will be sent immediately in this case:
http://api.newspark.ca/services/rest/media.insertTextFile?vhost=[VID]&fileData[title]=Comment test&fileData[message]=Message1&fileData[parentid]=[MEDIA_ID] &fileData[context]=COMMENT&fileData[moderationstatus]=1&fileData[uid]=[USERID_OF_COMMENTER]&fileData[channel]= [CHANNELID_FOR_COMMENTS]&APIKEY=[APIKEY]
Below is an example API call used to add a comment that requires moderation. This means that notification emails are sent only when the comment has been manually approved by moderators in New Spark Platform.
http://api.newspark.ca/services/rest/media.insertTextFile?vhost=[VID]&fileData[title]=Comment test&fileData[message]=Message1&fileData[parentid]=[MEDIA_ID] &fileData[context]=COMMENT&fileData[moderationstatus]=0&fileData[uid]=[USERID_OF_COMMENTER]&fileData[channel]= 15963&APIKEY=[APIKEY]
See users.updateuserInfo API for full details.
Below is an example API call to toggle user settings to opt out of media comment notifications.
http://api.newspark.ca/services/rest/users.updateUserInfo?id=1945997&newProperties[disable_media_notifications]=1&APIKEY=[APIKEY]
Below is an example API call to toggle user settings to opt out of thread comment notifications.
http://api.newspark.ca/services/rest/users.updateUserInfo?id=1945997&newProperties[disable_thread_notifications]=1&APIKEY=[APIKEY]
You may need a way to dynamically create the redirect links in the email template, so that when the user views the email, the link that they click on should take them back to the correct URL every time. You can do this by saving the URL where the comment was made as the metadata to the comment.
Example:
http://api.newspark.ca/services/rest/media.insertTextFile?vhost=[VID]&fileData[title]=Comment test&fileData[message]=Message1&fileData[parentid]=[MEDIA_ID] &fileData[context]=COMMENT&fileData[moderationstatus]=1&fileData[uid]=[USERID_OF_COMMENTER]&fileData[channel]= [CHANNELID_FOR_COMMENTS]&fileData[metadata][user][commenturl]=website.com&APIKEY=[APIKEY]
Then to retrieve this value in the email template, use the syntax in bold below:
<table width="500" style="font-family:Arial;"> <tr> <td style="border:1px solid #ccc; padding: 10px;"> <table> <tr> <td> <h2 style="font-size:14px;">{$$firstname},</h2> <p style="font-size:12px;"> {$$message} </p> <table width="500"> <tr> <td style="margin-top:10px; padding:10px; background-color:#e2e2e2;" width="318"> <p style=" font-size:14px;"> {$$comment} </p> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td style="padding:10px; font-size:10px; color:#505050; text-align:center;"> Check out all the entries at <a href="http://{$$comment_meta.user.commenturl}</a> </td> </tr> <tr> <td style="padding:10px; font-size:10px; color:#505050; text-align:center;"> OPT OUT FROM THE NOTIFICATIONS AT: <BR /> <a href="http://INSERT LINK TO USER PROFILE MANAGER HERE</a> </td> </tr> </table>