This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding mailchimp processor * Update subscribers/slack/worker/Processors/MailChimpMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Processors/MailChimpMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Processors/MailChimpMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Processors/MailChimpMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Program.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Program.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Program.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Program.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Model/VcapServices.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/AppConfig.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Processors/MailChimpMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Program.cs Co-authored-by: tobiasbrown <[email protected]> * removing blank space in app config * Update subscribers/slack/worker/Program.cs Co-authored-by: tobiasbrown <[email protected]> * removing blank lines * linting * linting Co-authored-by: tobiasbrown <[email protected]>
- Loading branch information
1 parent
a0ed5da
commit 85a3bff
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
subscribers/slack/worker/Processors/MailChimpMessageProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using Dta.Marketplace.Subscribers.Slack.Worker.Model; | ||
using Dta.Marketplace.Subscribers.Slack.Worker.Services; | ||
|
||
namespace Dta.Marketplace.Subscribers.Slack.Worker.Processors { | ||
internal class MailchimpMessageProcessor : AbstractMessageProcessor { | ||
private readonly ISlackService _slackService; | ||
|
||
public MailchimpMessageProcessor(ILogger<AppService> logger, IOptions<AppConfig> config, ISlackService slackService) : base(logger, config) { | ||
_slackService = slackService; | ||
} | ||
|
||
public async override Task<bool> Process(AwsSnsMessage awsSnsMessage) { | ||
switch (awsSnsMessage.MessageAttributes.EventType.Value) { | ||
case "mailchimp": | ||
var definition = new { | ||
mailchimp = new { | ||
message = "", | ||
error = "" | ||
} | ||
}; | ||
var message = JsonConvert.DeserializeAnonymousType(awsSnsMessage.Message, definition); | ||
var slackMessage = | ||
$@":email:*Mailchimp Error*:email: | ||
Message: {message.mailchimp.message} | ||
Error: {message.mailchimp.error}"; | ||
|
||
return await _slackService.SendSlackMessage(_config.Value.MailchimpSlackUrl, slackMessage); | ||
|
||
default: | ||
_logger.LogDebug("Unknown processor for {@AwsSnsMessage}.", awsSnsMessage); | ||
break; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters