Skip to content

Commit 050745a

Browse files
committed
Merge 1.5 into master
2 parents 75ee754 + 07e5563 commit 050745a

File tree

8 files changed

+96
-185
lines changed

8 files changed

+96
-185
lines changed

.gitignore

Lines changed: 3 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -180,102 +180,7 @@ $RECYCLE.BIN/
180180

181181
#Jekyll
182182
/_site
183-
.vs/
184-
script/cibuild.sh
185-
script/citest.sh
186-
script/deploy.sh
187-
_layouts/default.html
188-
_layouts/home.html
189-
assets/css/docs.min.css
190-
assets/css/featherlight.min.css
191-
assets/css/font-awesome.min.css
192-
assets/css/style.css
193-
assets/fonts/FontAwesome.otf
194-
assets/fonts/fontawesome-webfont.eot
195-
assets/fonts/fontawesome-webfont.svg
196-
assets/fonts/fontawesome-webfont.ttf
197-
assets/fonts/fontawesome-webfont.woff
198-
assets/fonts/fontawesome-webfont.woff2
199-
assets/fonts/glyphicons-halflings-regular.eot
200-
assets/fonts/glyphicons-halflings-regular.svg
201-
assets/fonts/glyphicons-halflings-regular.ttf
202-
assets/fonts/glyphicons-halflings-regular.woff
203-
assets/fonts/glyphicons-halflings-regular.woff2
204-
assets/js/bootstrap.min.js
205-
assets/js/docs.min.js
206-
assets/js/featherlight.min.js
207-
assets/js/jquery-1.12.2.min.js
208-
assets/less/bootstrap-3.3.6/alerts.less
209-
assets/less/bootstrap-3.3.6/badges.less
210-
assets/less/bootstrap-3.3.6/bootstrap.less
211-
assets/less/bootstrap-3.3.6/breadcrumbs.less
212-
assets/less/bootstrap-3.3.6/button-groups.less
213-
assets/less/bootstrap-3.3.6/buttons.less
214-
assets/less/bootstrap-3.3.6/carousel.less
215-
assets/less/bootstrap-3.3.6/close.less
216-
assets/less/bootstrap-3.3.6/code.less
217-
assets/less/bootstrap-3.3.6/component-animations.less
218-
assets/less/bootstrap-3.3.6/dropdowns.less
219-
assets/less/bootstrap-3.3.6/forms.less
220-
assets/less/bootstrap-3.3.6/glyphicons.less
221-
assets/less/bootstrap-3.3.6/grid.less
222-
assets/less/bootstrap-3.3.6/input-groups.less
223-
assets/less/bootstrap-3.3.6/jumbotron.less
224-
assets/less/bootstrap-3.3.6/labels.less
225-
assets/less/bootstrap-3.3.6/list-group.less
226-
assets/less/bootstrap-3.3.6/media.less
227-
assets/less/bootstrap-3.3.6/mixins.less
228-
assets/less/bootstrap-3.3.6/mixins/alerts.less
229-
assets/less/bootstrap-3.3.6/mixins/background-variant.less
230-
assets/less/bootstrap-3.3.6/mixins/border-radius.less
231-
assets/less/bootstrap-3.3.6/mixins/buttons.less
232-
assets/less/bootstrap-3.3.6/mixins/center-block.less
233-
assets/less/bootstrap-3.3.6/mixins/clearfix.less
234-
assets/less/bootstrap-3.3.6/mixins/forms.less
235-
assets/less/bootstrap-3.3.6/mixins/gradients.less
236-
assets/less/bootstrap-3.3.6/mixins/grid-framework.less
237-
assets/less/bootstrap-3.3.6/mixins/grid.less
238-
assets/less/bootstrap-3.3.6/mixins/hide-text.less
239-
assets/less/bootstrap-3.3.6/mixins/image.less
240-
assets/less/bootstrap-3.3.6/mixins/labels.less
241-
assets/less/bootstrap-3.3.6/mixins/list-group.less
242-
assets/less/bootstrap-3.3.6/mixins/nav-divider.less
243-
assets/less/bootstrap-3.3.6/mixins/nav-vertical-align.less
244-
assets/less/bootstrap-3.3.6/mixins/opacity.less
245-
assets/less/bootstrap-3.3.6/mixins/pagination.less
246-
assets/less/bootstrap-3.3.6/mixins/panels.less
247-
assets/less/bootstrap-3.3.6/mixins/progress-bar.less
248-
assets/less/bootstrap-3.3.6/mixins/reset-filter.less
249-
assets/less/bootstrap-3.3.6/mixins/reset-text.less
250-
assets/less/bootstrap-3.3.6/mixins/resize.less
251-
assets/less/bootstrap-3.3.6/mixins/responsive-visibility.less
252-
assets/less/bootstrap-3.3.6/mixins/size.less
253-
assets/less/bootstrap-3.3.6/mixins/tab-focus.less
254-
assets/less/bootstrap-3.3.6/mixins/table-row.less
255-
assets/less/bootstrap-3.3.6/mixins/text-emphasis.less
256-
assets/less/bootstrap-3.3.6/mixins/text-overflow.less
257-
assets/less/bootstrap-3.3.6/mixins/vendor-prefixes.less
258-
assets/less/bootstrap-3.3.6/modals.less
259-
assets/less/bootstrap-3.3.6/navbar.less
260-
assets/less/bootstrap-3.3.6/navs.less
261-
assets/less/bootstrap-3.3.6/normalize.less
262-
assets/less/bootstrap-3.3.6/pager.less
263-
assets/less/bootstrap-3.3.6/pagination.less
264-
assets/less/bootstrap-3.3.6/panels.less
265-
assets/less/bootstrap-3.3.6/popovers.less
266-
assets/less/bootstrap-3.3.6/print.less
267-
assets/less/bootstrap-3.3.6/progress-bars.less
268-
assets/less/bootstrap-3.3.6/responsive-embed.less
269-
assets/less/bootstrap-3.3.6/responsive-utilities.less
270-
assets/less/bootstrap-3.3.6/scaffolding.less
271-
assets/less/bootstrap-3.3.6/tables.less
272-
assets/less/bootstrap-3.3.6/theme.less
273-
assets/less/bootstrap-3.3.6/thumbnails.less
274-
assets/less/bootstrap-3.3.6/tooltip.less
275-
assets/less/bootstrap-3.3.6/type.less
276-
assets/less/bootstrap-3.3.6/utilities.less
277-
assets/less/bootstrap-3.3.6/variables.less
278-
assets/less/bootstrap-3.3.6/wells.less
279-
assets/less/style.less
183+
script/
184+
assets/
185+
_layouts/
280186
Gemfile.lock
281-
SendGrid/packages/

SendGrid/Communication/Transport/SendGridSmtp.cs

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,30 @@
1616
//
1717

1818
using System;
19+
using System.Collections.Generic;
1920
using System.ComponentModel;
2021
using System.ComponentModel.Composition;
2122
using System.Net.Mail;
22-
23-
using Newtonsoft.Json;
23+
using Newtonsoft.Json.Linq;
2424

2525
using Rock;
2626
using Rock.Attribute;
27-
using Rock.Model;
2827
using Rock.Communication;
2928
using Rock.Communication.Transport;
3029

31-
namespace com.bricksandmortar.SendGrid
30+
namespace com.bricksandmortarstudio.SendGrid.Communication.Transport
3231
{
3332
/// <summary>
3433
/// Sends a communication through SMTP protocol
3534
/// </summary>
36-
[Description( "Sends a communication through SendGrid's SMTP API" )]
37-
[Export( typeof( TransportComponent ) )]
38-
[ExportMetadata( "ComponentName", "SendGrid SMTP" )]
39-
[TextField( "Server", "", true, "smtp.sendgrid.net", "", 0 )]
40-
[TextField( "Username", "A SendGrid credential username", true, "", "", 1 )]
41-
[IntegerField( "Port", "", true, 587, "", 3 )]
42-
[BooleanField( "Use SSL", "", false, "", 4 )]
43-
[TextField( "Password", "A SendGrid credential password", true, "", "", 2, null, true )]
35+
[Description("Sends a communication through SendGrid's SMTP API")]
36+
[Export(typeof(TransportComponent))]
37+
[ExportMetadata("ComponentName", "SendGrid SMTP")]
38+
[TextField("Server", "", true, "smtp.sendgrid.net")]
39+
[TextField("Username", "A SendGrid credential username", true, "", "", 1)]
40+
[IntegerField("Port", "", true, 587, "", 3)]
41+
[BooleanField("Use SSL", "", false, "", 4)]
42+
[TextField("Password", "A SendGrid credential password", true, "", "", 2, null, true)]
4443
public class SendGridSmtp : SMTPComponent
4544
{
4645
/// <summary>
@@ -70,45 +69,25 @@ public override string StatusNote
7069
/// </summary>
7170
/// <param name="message">The message.</param>
7271
/// <param name="recipient"></param>
73-
public override void AddAdditionalHeaders( MailMessage message, CommunicationRecipient recipient )
72+
public override void AddAdditionalHeaders(MailMessage message, Dictionary<string, string> headers)
7473
{
75-
SendGridHeader header = new SendGridHeader
74+
//Add SendGrid tracking header
75+
var header = new JObject();
76+
if (headers != null)
7677
{
77-
filters = new Filters {clicktrack = new Clicktrack {settings = new Settings {enable = 1}}},
78-
unique_args = new UniqueArgs {communication_recipient_guid = recipient.Guid.ToString()}
79-
};
80-
string headerJson = JsonConvert.SerializeObject( header );
81-
message.Headers.Add( "X-SMTPAPI", headerJson );
78+
var uniqueArgs = new JObject();
79+
foreach (var item in headers)
80+
{
81+
uniqueArgs.Add(item.Key, item.Value);
82+
}
83+
header.Add("unique_args", uniqueArgs);
84+
}
85+
var filters = new JProperty("filters",
86+
new JObject(new JProperty("clicktrack",
87+
new JObject(new JProperty("settings",
88+
new JObject(new JProperty("enable", 1)))))));
89+
header.Add(filters);
90+
message.Headers.Add("X-SMTPAPI", header.ToString());
8291
}
83-
84-
}
85-
86-
// ReSharper disable InconsistentNaming
87-
public class UniqueArgs
88-
{
89-
public string communication_recipient_guid { get; set; }
90-
}
91-
92-
public class Settings
93-
{
94-
public int enable { get; set; }
95-
}
96-
97-
public class Clicktrack
98-
{
99-
100-
public Settings settings { get; set; }
101-
}
102-
103-
public class Filters
104-
{
105-
public Clicktrack clicktrack { get; set; }
106-
}
107-
108-
public class SendGridHeader
109-
{
110-
public UniqueArgs unique_args { get; set; }
111-
public Filters filters { get; set; }
11292
}
113-
// ReSharper restore InconsistentNaming
11493
}

SendGrid/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
[assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyFileVersion("1.0.*")]

SendGrid/RockWeb/Webhooks/SendGrid.ashx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<%@ WebHandler Language="C#" Class="SendGrid" %>
2-
32
using System;
43
using System.Web;
54
using System.IO;
@@ -33,11 +32,11 @@ public class SendGrid : IHttpHandler
3332
string postedData = GetDocumentContents(_request);
3433

3534
var rockContext = new Rock.Data.RockContext();
36-
var timeZoneInfo = RockDateTime.OrgTimeZoneInfo;
37-
35+
3836
var communicationRecipientService = new CommunicationRecipientService(rockContext);
39-
var communicationRecipientActivityService = new CommunicationRecipientActivityService( rockContext );
37+
var communicationRecipientActivityService = new CommunicationRecipientActivityService(rockContext);
4038

39+
var timeZoneInfo = RockDateTime.OrgTimeZoneInfo;
4140
var parser = new Sendgrid.Webhooks.Service.WebhookParser();
4241
var events = parser.ParseEvents(postedData);
4342

@@ -48,6 +47,29 @@ public class SendGrid : IHttpHandler
4847
{
4948
_transactionCount++;
5049
unsavedCommunicationCount++;
50+
// Process a SendEmailWithEvents workflow action
51+
if (item.UniqueParameters.ContainsKey("workflow_action_guid"))
52+
{
53+
var actionGuid = item.UniqueParameters["workflow_action_guid"].AsGuidOrNull();
54+
string status = string.Empty;
55+
switch (item.EventType)
56+
{
57+
case WebhookEventType.Delivered: status = SendEmailWithEvents.SENT_STATUS; break;
58+
case WebhookEventType.Open: status = SendEmailWithEvents.OPENED_STATUS; break;
59+
case WebhookEventType.Click: status = SendEmailWithEvents.CLICKED_STATUS; break;
60+
case WebhookEventType.Dropped:
61+
case WebhookEventType.SpamReport:
62+
case WebhookEventType.Unsubscribe:
63+
case WebhookEventType.Group_Unsubscribe:
64+
case WebhookEventType.Bounce: status = SendEmailWithEvents.FAILED_STATUS; break;
65+
66+
}
67+
68+
if (actionGuid != null && !string.IsNullOrWhiteSpace(status))
69+
{
70+
SendEmailWithEvents.UpdateEmailStatus(actionGuid.Value, status, item.EventType.ConvertToString().SplitCase(), rockContext, true);
71+
}
72+
}
5173

5274
// Process a regular communication recipient
5375
if (item.UniqueParameters.ContainsKey("communication_recipient_guid"))
@@ -78,24 +100,22 @@ public class SendGrid : IHttpHandler
78100
"Unknown";
79101
var openActivity = new CommunicationRecipientActivity
80102
{
81-
CommunicationRecipientId = communicationRecipient.Id,
103+
CommunicationRecipientId = communicationRecipient.Id,
82104
ActivityType = "Opened",
83105
ActivityDateTime = item.TimeStamp,
84106
ActivityDetail =
85-
string.Format( "Opened from {0} ({1})", openEvent.UserAgent ?? "unknown",
107+
string.Format("Opened from {0} ({1})", openEvent.UserAgent ?? "unknown",
86108
openEvent.Ip).Truncate(2200)
87109
};
88-
89-
communicationRecipientActivityService.Add( openActivity );
110+
communicationRecipientActivityService.Add(openActivity);
90111
}
91112
break;
92113
case WebhookEventType.Click:
93114
var clickActivity = new CommunicationRecipientActivity
94115
{
95-
CommunicationRecipientId = communicationRecipient.Id,
96-
ActivityType = "Click"
116+
CommunicationRecipientId = communicationRecipient.Id,
117+
ActivityType = "Click"
97118
};
98-
99119
var clickEvent = item as ClickEvent;
100120
clickActivity.ActivityDateTime = item.TimeStamp;
101121
if (clickEvent != null)
@@ -104,8 +124,7 @@ public class SendGrid : IHttpHandler
104124
string.Format("Clicked the address {0} from {1} using {2}", clickEvent.Url,
105125
clickEvent.Ip, clickEvent.UserAgent).Truncate(2200);
106126
}
107-
108-
communicationRecipientActivityService.Add( clickActivity );
127+
communicationRecipientActivityService.Add(clickActivity);
109128
break;
110129
case WebhookEventType.Dropped:
111130
var dropEvent = item as DroppedEvent;
@@ -197,4 +216,4 @@ public class SendGrid : IHttpHandler
197216
}
198217
return documentContents;
199218
}
200-
}
219+
}

SendGrid/SendGrid.csproj

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,36 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35-
<Reference Include="DotLiquid, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
36-
<HintPath>..\packages\DotLiquid.1.0.0\lib\NET40\DotLiquid.dll</HintPath>
35+
<Reference Include="DotLiquid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82e46016ecf9f07c, processorArchitecture=MSIL">
36+
<HintPath>..\packages\\DotLiquid.1.0.0.0\lib\net451\DotLiquid.dll</HintPath>
3737
<Private>True</Private>
3838
</Reference>
39-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39+
<Reference Include="Newtonsoft.Json">
4040
<HintPath>..\packages\Newtonsoft.Json.6.0.5\lib\net45\Newtonsoft.Json.dll</HintPath>
41-
<Private>True</Private>
4241
</Reference>
43-
<Reference Include="Rock, Version=1.4.5.0, Culture=neutral, processorArchitecture=MSIL">
44-
<HintPath>..\packages\Rock.1.4.5.0\lib\net451\Rock.dll</HintPath>
45-
<Private>True</Private>
42+
<Reference Include="Rock">
43+
<HintPath>..\packages\Rock.1.5.0.69\lib\net451\Rock.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Sendgrid.Webhooks">
46+
<HintPath>..\packages\Sendgrid.Webhooks.1.1.0\lib\net40\Sendgrid.Webhooks.dll</HintPath>
4647
</Reference>
4748
<Reference Include="System" />
4849
<Reference Include="System.ComponentModel.Composition" />
49-
<Reference Include="System.Core" />
50-
<Reference Include="System.Xml.Linq" />
51-
<Reference Include="System.Data.DataSetExtensions" />
52-
<Reference Include="Microsoft.CSharp" />
53-
<Reference Include="System.Data" />
50+
<Reference Include="System.Web" />
5451
<Reference Include="System.Net.Http" />
55-
<Reference Include="System.Xml" />
5652
</ItemGroup>
5753
<ItemGroup>
5854
<Compile Include="Communication\Transport\SendGridSmtp.cs" />
5955
<Compile Include="Properties\AssemblyInfo.cs" />
6056
</ItemGroup>
61-
<ItemGroup />
57+
<ItemGroup>
58+
</ItemGroup>
6259
<ItemGroup>
6360
<None Include="app.config" />
61+
<None Include="packages.config" />
6462
<None Include="RockWeb\Webhooks\SendGrid.ashx">
6563
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
6664
</None>
67-
<None Include="packages.config" />
6865
</ItemGroup>
6966
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7067
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

SendGrid/app.config

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<configSections>
4+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
5+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
6+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
37
<runtime>
48
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
59
<dependentAssembly>
610
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
7-
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
11+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
812
</dependentAssembly>
913
</assemblyBinding>
1014
</runtime>
15+
<entityFramework>
16+
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
17+
<parameters>
18+
<parameter value="mssqllocaldb" />
19+
</parameters>
20+
</defaultConnectionFactory>
21+
<providers>
22+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
23+
</providers>
24+
</entityFramework>
1125
</configuration>

0 commit comments

Comments
 (0)