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.
Mar 2339 Pre-fill seller form using ABN (#29)
* adding the case of abr_failed * adding message * successfull added abr failed message * changing the message * removing console writeline * same message as before * Update subscribers/slack/worker/Processors/UserMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * cleaning up variable names * changing abr variable names * Update subscribers/slack/worker/Processors/UserMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * Update subscribers/slack/worker/Processors/UserMessageProcessor.cs Co-authored-by: tobiasbrown <[email protected]> * adding abr message processor * Remove old abr * remove message from slack * adding mesage for error * removing abr object in slack message processor * change name to abr * added fix Co-authored-by: tobiasbrown <[email protected]>
- Loading branch information
1 parent
1880ada
commit ac7ec69
Showing
4 changed files
with
46 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
37 changes: 37 additions & 0 deletions
37
subscribers/slack/worker/Processors/AbrMessageProcessor.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,37 @@ | ||
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 AbrMessageProcessor : AbstractMessageProcessor { | ||
private readonly ISlackService _slackService; | ||
|
||
public AbrMessageProcessor(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 "abr_failed": | ||
var definition = new { | ||
error = "" | ||
}; | ||
var message = JsonConvert.DeserializeAnonymousType(awsSnsMessage.Message, definition); | ||
var slackMessage = | ||
$@":imp:*ABR API failed*:imp: | ||
Error: {message.error}"; | ||
|
||
return await _slackService.SendSlackMessage(_config.Value.AbrSlackUrl, 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