async Task <SlackSettingsViewModel> GetModel() { var settings = await _TwitterSettingsStore.GetAsync(); if (settings != null) { // Decrypt the secret var webHookUrl = string.Empty; if (!string.IsNullOrWhiteSpace(settings.WebHookUrl)) { try { var protector = _dataProtectionProvider.CreateProtector(nameof(SlackOptionsConfiguration)); webHookUrl = protector.Unprotect(settings.WebHookUrl); } catch (Exception e) { _logger.LogError($"There was a problem encrypting the Twitter app secret. {e.Message}"); } } return(new SlackSettingsViewModel() { WebHookUrl = webHookUrl }); } // return default settings return(new SlackSettingsViewModel()); }
public void Configure(PlatoSlackOptions options) { var settings = _slackSettingsStore .GetAsync() .GetAwaiter() .GetResult(); if (settings != null) { if (!String.IsNullOrWhiteSpace(settings.WebHookUrl)) { try { options.WebHookUrl = _encrypter.Decrypt(settings.WebHookUrl); } catch (Exception e) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError(e, $"There was a problem decrypting the Slack Web Hook URL. {e.Message}"); } } } } }
async Task <SlackSettingsViewModel> GetModel() { var settings = await _TwitterSettingsStore.GetAsync(); if (settings != null) { // Decrypt the secret var webHookUrl = string.Empty; if (!string.IsNullOrWhiteSpace(settings.WebHookUrl)) { try { webHookUrl = _encrypter.Decrypt(settings.WebHookUrl); } catch (Exception e) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError($"There was a problem dencrypting the Slack Web Hook URL. {e.Message}"); } } } return(new SlackSettingsViewModel() { WebHookUrl = webHookUrl }); } // return default settings return(new SlackSettingsViewModel()); }
public void Configure(SlackOptions options) { var settings = _slackSettingsStore .GetAsync() .GetAwaiter() .GetResult(); if (settings != null) { if (!String.IsNullOrWhiteSpace(settings.WebHookUrl)) { try { var protector = _dataProtectionProvider.CreateProtector(nameof(SlackOptionsConfiguration)); options.WebHookUrl = protector.Unprotect(settings.WebHookUrl); } catch (Exception e) { _logger.LogError($"There was a problem decrypting the Slack Web Hook URL - {e.Message}"); } } } }