Notifications should be back up and using smtp and db settings from web.config

This commit is contained in:
TimGeyssens
2015-02-05 15:31:01 +01:00
parent f4f30b9243
commit b8d1e01f24
4 changed files with 24 additions and 23 deletions
@@ -25,6 +25,9 @@ namespace NotificationsCore.NotificationTypes
{
var topic = (Topic)args[0];
string url = (string)args[1];
Member member = (Member)args[2];
if (topic.IsSpam)
{
umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, string.Format("[Notifications] Topic ID {0} is marked as spam, no notification sent{0}", topic.Id));
@@ -42,7 +45,7 @@ namespace NotificationsCore.NotificationTypes
string subject = details.SelectSingleNode("//subject").InnerText;
string body = details.SelectSingleNode("//body").InnerText;
Member member = (Member)args[2];
//currently using document api instead of nodefactory
Document forum = new Document(topic.ParentId);
@@ -52,7 +55,7 @@ namespace NotificationsCore.NotificationTypes
var domain = details.SelectSingleNode("//domain").InnerText;
body = string.Format(body, forum.Text, "http://" + domain + args[1], member.Text, topic.Title, HttpUtility.HtmlDecode(umbraco.library.StripHtml(topic.Body)));
body = string.Format(body, forum.Text, "http://" + domain + url, member.Text, topic.Title, HttpUtility.HtmlDecode(umbraco.library.StripHtml(topic.Body)));
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString);
@@ -8,6 +8,9 @@ using System.Data.SqlClient;
using umbraco.cms.businesslogic.member;
using System.Web;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Core;
using Umbraco.Web.Security;
namespace NotificationsCore.NotificationTypes
{
@@ -22,9 +25,13 @@ namespace NotificationsCore.NotificationTypes
{
try
{
Comment com = (Comment)args[0];
Topic topic = (Topic)args[1];
IMember mem = (IMember)args[2];
string url = (string)args[2];
IMember mem = (IMember)args[3];
if (com.IsSpam)
@@ -35,8 +42,8 @@ namespace NotificationsCore.NotificationTypes
//SMTP SETTINGS
SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText);
c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText);
SmtpClient c = new SmtpClient();
//c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText);
//SENDER ADDRESS
MailAddress from = new MailAddress(
@@ -47,11 +54,12 @@ namespace NotificationsCore.NotificationTypes
var domain = details.SelectSingleNode("//domain").InnerText;
var subject = string.Format(details.SelectSingleNode("//subject").InnerText, topic.Title);
var body = details.SelectSingleNode("//body").InnerText;
body = string.Format(body, topic.Title, "http://" + domain + args[1], mem.Name, HttpUtility.HtmlDecode(umbraco.library.StripHtml(com.Body)));
body = string.Format(body, topic.Title, "http://" + domain + url + "#comment-" + com.Id, mem.Name, HttpUtility.HtmlDecode(umbraco.library.StripHtml(com.Body)));
//connect to DB
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["umbracoDbDSN"]);
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString);
SqlCommand comm = new SqlCommand("Select memberId from forumTopicSubscribers where topicId = @topicId", conn);
comm.Parameters.AddWithValue("@topicId", topic.Id);
conn.Open();
@@ -64,7 +72,7 @@ namespace NotificationsCore.NotificationTypes
int mid = dr.GetInt32(0);
try
{
Member m = new Member(mid);
var m = new umbraco.cms.businesslogic.member.Member(mid);
if (m.Id != com.MemberId
&& m.getProperty("bugMeNot").Value.ToString() != "1")
+2 -2
View File
@@ -53,7 +53,7 @@ namespace NotificationsWeb.EventHandlers
var member = e.Topic.AuthorAsMember();
not.Invoke(Config.ConfigurationFile, Config.AssemblyDir, "NewTopic", e.Topic, member);
not.Invoke(Config.ConfigurationFile, Config.AssemblyDir, "NewTopic", e.Topic,e.Topic.Url, member);
}
void CommentService_Created(object sender, uForum.CommentEventArgs e)
@@ -67,7 +67,7 @@ namespace NotificationsWeb.EventHandlers
//send notifications
InstantNotification not = new InstantNotification();
not.Invoke(Config.ConfigurationFile, Config.AssemblyDir, "NewComment", e.Comment, topic, member);
not.Invoke(Config.ConfigurationFile, Config.AssemblyDir, "NewComment", e.Comment, topic, topic.Url, member);
}
+3 -13
View File
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OurUmbraco.Site", "OurUmbraco.Site\OurUmbraco.Site.csproj", "{911907FB-3B9D-4E5F-9A45-16700A451A54}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{84E122E2-FB7D-4732-A764-B6EFB1F524DE}"
@@ -15,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uPowers", "uPowers\uPowers.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "our.umbraco.org", "our.umbraco.org\our.umbraco.org.csproj", "{A625544F-660A-4C01-BA49-1B467D0322D9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotificationMailer", "NotificationMailer\NotificationMailer.csproj", "{F41D51B7-3ECF-4C4C-955E-6E761345E18E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uRepo", "uRepo\uRepo.csproj", "{47FD2B14-1653-4052-AD53-1871A8F85E0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "uEvents", "uEvents\uEvents.csproj", "{F356B339-296A-4594-81B6-CF69A802483E}"
@@ -88,16 +88,6 @@ Global
{A625544F-660A-4C01-BA49-1B467D0322D9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A625544F-660A-4C01-BA49-1B467D0322D9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A625544F-660A-4C01-BA49-1B467D0322D9}.Release|x86.ActiveCfg = Release|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Debug|x86.ActiveCfg = Debug|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Release|Any CPU.Build.0 = Release|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F41D51B7-3ECF-4C4C-955E-6E761345E18E}.Release|x86.ActiveCfg = Release|Any CPU
{47FD2B14-1653-4052-AD53-1871A8F85E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47FD2B14-1653-4052-AD53-1871A8F85E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47FD2B14-1653-4052-AD53-1871A8F85E0E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU