V13: Update IWebHookService to proper casing (#15169)
* Update to proper casing * Fixed naming --------- Co-authored-by: Zeegaan <nge@umbraco.dk> Co-authored-by: Andreas Zerbst <andr317c@live.dk>
This commit is contained in:
@@ -332,7 +332,7 @@ namespace Umbraco.Cms.Core.DependencyInjection
|
||||
// Register filestream security analyzers
|
||||
Services.AddUnique<IFileStreamSecurityValidator,FileStreamSecurityValidator>();
|
||||
Services.AddUnique<IDynamicRootService,DynamicRoot.DynamicRootService>();
|
||||
Services.AddUnique<IWebHookService, WebhookService>();
|
||||
Services.AddUnique<IWebhookService, WebhookService>();
|
||||
Services.AddUnique<IWebhookLogService, WebhookLogService>();
|
||||
Services.AddUnique<IWebhookLogFactory, WebhookLogFactory>();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ using Umbraco.Cms.Core.Models;
|
||||
|
||||
namespace Umbraco.Cms.Core.Services;
|
||||
|
||||
public interface IWebHookService
|
||||
public interface IWebhookService
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a webhook.
|
||||
@@ -4,7 +4,7 @@ using Umbraco.Cms.Core.Scoping;
|
||||
|
||||
namespace Umbraco.Cms.Core.Services;
|
||||
|
||||
public class WebhookService : IWebHookService
|
||||
public class WebhookService : IWebhookService
|
||||
{
|
||||
private readonly ICoreScopeProvider _provider;
|
||||
private readonly IWebhookRepository _webhookRepository;
|
||||
|
||||
@@ -12,12 +12,12 @@ public class ContentDeleteWebhookEvent : WebhookEventContentBase<ContentDeletedN
|
||||
{
|
||||
public ContentDeleteWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webHookService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
|
||||
@@ -18,14 +18,14 @@ public class ContentPublishWebhookEvent : WebhookEventContentBase<ContentPublish
|
||||
|
||||
public ContentPublishWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IApiContentBuilder apiContentBuilder)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webHookService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
|
||||
@@ -12,12 +12,12 @@ public class ContentUnpublishWebhookEvent : WebhookEventContentBase<ContentUnpub
|
||||
{
|
||||
public ContentUnpublishWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webHookService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
|
||||
@@ -12,12 +12,12 @@ public class MediaDeleteWebhookEvent : WebhookEventContentBase<MediaDeletedNotif
|
||||
{
|
||||
public MediaDeleteWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webHookService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
|
||||
@@ -18,14 +18,14 @@ public class MediaSaveWebhookEvent : WebhookEventContentBase<MediaSavedNotificat
|
||||
|
||||
public MediaSaveWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor,
|
||||
IApiMediaBuilder apiMediaBuilder)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webHookService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public abstract class WebhookEventBase<TNotification> : IWebhookEvent, INotifica
|
||||
|
||||
protected IWebhookFiringService WebhookFiringService { get; }
|
||||
|
||||
protected IWebHookService WebHookService { get; }
|
||||
protected IWebhookService WebhookService { get; }
|
||||
|
||||
protected WebhookSettings WebhookSettings { get; private set; }
|
||||
|
||||
@@ -31,13 +31,13 @@ public abstract class WebhookEventBase<TNotification> : IWebhookEvent, INotifica
|
||||
|
||||
protected WebhookEventBase(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
{
|
||||
|
||||
WebhookFiringService = webhookFiringService;
|
||||
WebHookService = webHookService;
|
||||
WebhookService = webhookService;
|
||||
_serverRoleAccessor = serverRoleAccessor;
|
||||
|
||||
// assign properties based on the attribute, if it is found
|
||||
@@ -91,7 +91,7 @@ public abstract class WebhookEventBase<TNotification> : IWebhookEvent, INotifica
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable<Webhook> webhooks = await WebHookService.GetByAliasAsync(Alias);
|
||||
IEnumerable<Webhook> webhooks = await WebhookService.GetByAliasAsync(Alias);
|
||||
|
||||
await ProcessWebhooks(notification, webhooks, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public abstract class WebhookEventContentBase<TNotification, TEntity> : WebhookE
|
||||
{
|
||||
protected WebhookEventContentBase(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebHookService webHookService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
|
||||
: base(webhookFiringService, webhookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,15 +13,15 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers;
|
||||
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
|
||||
public class WebhookController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
private readonly IWebHookService _webHookService;
|
||||
private readonly IWebhookService _webhookService;
|
||||
private readonly IUmbracoMapper _umbracoMapper;
|
||||
private readonly WebhookEventCollection _webhookEventCollection;
|
||||
private readonly IWebhookLogService _webhookLogService;
|
||||
private readonly IWebhookPresentationFactory _webhookPresentationFactory;
|
||||
|
||||
public WebhookController(IWebHookService webHookService, IUmbracoMapper umbracoMapper, WebhookEventCollection webhookEventCollection, IWebhookLogService webhookLogService, IWebhookPresentationFactory webhookPresentationFactory)
|
||||
public WebhookController(IWebhookService webhookService, IUmbracoMapper umbracoMapper, WebhookEventCollection webhookEventCollection, IWebhookLogService webhookLogService, IWebhookPresentationFactory webhookPresentationFactory)
|
||||
{
|
||||
_webHookService = webHookService;
|
||||
_webhookService = webhookService;
|
||||
_umbracoMapper = umbracoMapper;
|
||||
_webhookEventCollection = webhookEventCollection;
|
||||
_webhookLogService = webhookLogService;
|
||||
@@ -31,7 +31,7 @@ public class WebhookController : UmbracoAuthorizedJsonController
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll(int skip = 0, int take = int.MaxValue)
|
||||
{
|
||||
PagedModel<Webhook> webhooks = await _webHookService.GetAllAsync(skip, take);
|
||||
PagedModel<Webhook> webhooks = await _webhookService.GetAllAsync(skip, take);
|
||||
|
||||
IEnumerable<WebhookViewModel> webhookViewModels = webhooks.Items.Select(_webhookPresentationFactory.Create);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class WebhookController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
Webhook updateModel = _umbracoMapper.Map<Webhook>(webhookViewModel)!;
|
||||
|
||||
await _webHookService.UpdateAsync(updateModel);
|
||||
await _webhookService.UpdateAsync(updateModel);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class WebhookController : UmbracoAuthorizedJsonController
|
||||
public async Task<IActionResult> Create(WebhookViewModel webhookViewModel)
|
||||
{
|
||||
Webhook webhook = _umbracoMapper.Map<Webhook>(webhookViewModel)!;
|
||||
await _webHookService.CreateAsync(webhook);
|
||||
await _webhookService.CreateAsync(webhook);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class WebhookController : UmbracoAuthorizedJsonController
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetByKey(Guid key)
|
||||
{
|
||||
Webhook? webhook = await _webHookService.GetAsync(key);
|
||||
Webhook? webhook = await _webhookService.GetAsync(key);
|
||||
|
||||
return webhook is null ? NotFound() : Ok(webhook);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class WebhookController : UmbracoAuthorizedJsonController
|
||||
[HttpDelete]
|
||||
public async Task<IActionResult> Delete(Guid key)
|
||||
{
|
||||
await _webHookService.DeleteAsync(key);
|
||||
await _webhookService.DeleteAsync(key);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
vm.page = {};
|
||||
vm.webhooks = [];
|
||||
vm.events = [];
|
||||
vm.webHooksContentTypes = {};
|
||||
vm.webhooksContentTypes = {};
|
||||
vm.webhookEvents = {};
|
||||
|
||||
function init() {
|
||||
@@ -88,17 +88,17 @@
|
||||
function resolveTypeNames(webhook) {
|
||||
let resource = determineResource(webhook.events[0].eventType.toLowerCase());
|
||||
|
||||
if (vm.webHooksContentTypes[webhook.key]){
|
||||
delete vm.webHooksContentTypes[webhook.key];
|
||||
if (vm.webhooksContentTypes[webhook.key]){
|
||||
delete vm.webhooksContentTypes[webhook.key];
|
||||
}
|
||||
|
||||
webhook.contentTypeKeys.forEach(key => {
|
||||
resource.getById(key)
|
||||
.then(data => {
|
||||
if (!vm.webHooksContentTypes[webhook.key]) {
|
||||
vm.webHooksContentTypes[webhook.key] = data.name;
|
||||
if (!vm.webhooksContentTypes[webhook.key]) {
|
||||
vm.webhooksContentTypes[webhook.key] = data.name;
|
||||
} else {
|
||||
vm.webHooksContentTypes[webhook.key] += ", " + data.name;
|
||||
vm.webhooksContentTypes[webhook.key] += ", " + data.name;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -176,7 +176,7 @@
|
||||
.then(result => {
|
||||
vm.webhooks = result;
|
||||
vm.webhookEvents = {};
|
||||
vm.webHooksContentTypes = {};
|
||||
vm.webhooksContentTypes = {};
|
||||
|
||||
vm.webhooks.forEach(webhook => {
|
||||
resolveTypeNames(webhook);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<span>{{ vm.webhookEvents[webhook.key] }}</span>
|
||||
</td>
|
||||
<td>{{ webhook.url }}</td>
|
||||
<td>{{ vm.webHooksContentTypes[webhook.key] }}</td>
|
||||
<td>{{ vm.webhooksContentTypes[webhook.key] }}</td>
|
||||
<td style="text-align: right;">
|
||||
<umb-button
|
||||
type="button"
|
||||
|
||||
@@ -37,14 +37,14 @@ public class WebhookLogServiceTests : UmbracoIntegrationTest
|
||||
Assert.IsNotNull(webhookLogsPaged);
|
||||
Assert.IsNotEmpty(webhookLogsPaged.Items);
|
||||
Assert.AreEqual(1, webhookLogsPaged.Items.Count());
|
||||
var webHookLog = webhookLogsPaged.Items.First();
|
||||
Assert.AreEqual(createdWebhookLog.Date.ToString(CultureInfo.InvariantCulture), webHookLog.Date.ToString(CultureInfo.InvariantCulture));
|
||||
Assert.AreEqual(createdWebhookLog.EventAlias, webHookLog.EventAlias);
|
||||
Assert.AreEqual(createdWebhookLog.RequestBody, webHookLog.RequestBody);
|
||||
Assert.AreEqual(createdWebhookLog.ResponseBody, webHookLog.ResponseBody);
|
||||
Assert.AreEqual(createdWebhookLog.StatusCode, webHookLog.StatusCode);
|
||||
Assert.AreEqual(createdWebhookLog.RetryCount, webHookLog.RetryCount);
|
||||
Assert.AreEqual(createdWebhookLog.Key, webHookLog.Key);
|
||||
var webhookLog = webhookLogsPaged.Items.First();
|
||||
Assert.AreEqual(createdWebhookLog.Date.ToString(CultureInfo.InvariantCulture), webhookLog.Date.ToString(CultureInfo.InvariantCulture));
|
||||
Assert.AreEqual(createdWebhookLog.EventAlias, webhookLog.EventAlias);
|
||||
Assert.AreEqual(createdWebhookLog.RequestBody, webhookLog.RequestBody);
|
||||
Assert.AreEqual(createdWebhookLog.ResponseBody, webhookLog.ResponseBody);
|
||||
Assert.AreEqual(createdWebhookLog.StatusCode, webhookLog.StatusCode);
|
||||
Assert.AreEqual(createdWebhookLog.RetryCount, webhookLog.RetryCount);
|
||||
Assert.AreEqual(createdWebhookLog.Key, webhookLog.Key);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
||||
public class WebhookServiceTests : UmbracoIntegrationTest
|
||||
{
|
||||
private IWebHookService WebhookService => GetRequiredService<IWebHookService>();
|
||||
private IWebhookService WebhookService => GetRequiredService<IWebhookService>();
|
||||
|
||||
[Test]
|
||||
[TestCase("https://example.com", Constants.WebhookEvents.Aliases.ContentPublish, "00000000-0000-0000-0000-010000000000")]
|
||||
|
||||
Reference in New Issue
Block a user