Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
727f3fe
Create webhook models
Zeegaan Aug 28, 2023
3fa9d5f
Define interfaces for service and repository
Zeegaan Aug 28, 2023
c511fa3
Create Webhook dto and corresponding factory
Zeegaan Aug 28, 2023
b97abb4
implement WebhookRepository.cs
Zeegaan Aug 28, 2023
f683405
Remove entity name from models, as that should be resolved in mapping…
Zeegaan Aug 28, 2023
ccec84d
Add new table to schema creator
Zeegaan Aug 28, 2023
b427570
Register repo for DI
Zeegaan Aug 28, 2023
a2a9065
Remove more mentions of entityname
Zeegaan Aug 28, 2023
039c330
Refactor repository to guids
Zeegaan Aug 28, 2023
aab96de
Implement WebhookService
Zeegaan Aug 28, 2023
54ac9c5
Use scopes in service
Zeegaan Aug 29, 2023
db6ed7c
Start creating tests for service
Zeegaan Aug 29, 2023
11fd1e6
Refactor delete to use Id and not entire entity
Zeegaan Aug 29, 2023
6aa3f2b
Rework Webhooks to be able to have multiple entity keys
Zeegaan Sep 11, 2023
4d90483
Implement GetAll functionality
Zeegaan Sep 11, 2023
e457600
Implement webhook controller
Zeegaan Sep 11, 2023
e24cf0e
Imeplement get all events action
Zeegaan Sep 11, 2023
8f3fc3b
Add equalityComparer deletegate to Webhook
Zeegaan Sep 11, 2023
e04ec6b
Add datacontract attirbutes to properties
Zeegaan Sep 11, 2023
b0e7ddb
Implement backoffice webhooks tree
Zeegaan Sep 11, 2023
bef79a1
Implement first webhooks menu
Zeegaan Sep 11, 2023
5097145
Make WebHookController authorized
Zeegaan Sep 12, 2023
adbf506
Update to have tabs with webhooks and logs
Zeegaan Sep 12, 2023
7e34939
Enable create overlay
Zeegaan Sep 12, 2023
4646115
Push to entityKeys array
Zeegaan Sep 12, 2023
d4faf6f
Fix up pagination
Zeegaan Sep 12, 2023
e245db5
Implement delete functionality
Zeegaan Sep 12, 2023
cdbda08
remove pagination
Zeegaan Sep 12, 2023
6430cbf
add log view
Zeegaan Sep 12, 2023
296e775
Fix create to be able to select more than one content type
Zeegaan Sep 13, 2023
be86890
implement type name resolving for content
Zeegaan Sep 13, 2023
9401547
Refactor to use less duplication
Zeegaan Sep 13, 2023
6576519
Implement update functionality in frontend
Zeegaan Sep 13, 2023
44adc7f
Rename database table
Zeegaan Sep 19, 2023
dd6e06c
Make multiple events possible
Zeegaan Sep 19, 2023
07b8565
create new event picker
Zeegaan Sep 19, 2023
a075ea6
Refactor to actually add new database table with proper name
Zeegaan Sep 19, 2023
35fd634
Make it possible to select multiple events
Zeegaan Sep 19, 2023
85b39d2
Fix updating current items
Zeegaan Sep 19, 2023
3323958
Fix up update functionality after db rework
Zeegaan Sep 19, 2023
682451b
Add webhook icon
Zeegaan Sep 19, 2023
0d4a3e7
Switch to match heartcore icons
Zeegaan Sep 20, 2023
d059c10
Refactor to use bases instead of Enum
Zeegaan Sep 21, 2023
c7c8562
Refactor to make IWebhookEvent to Collection, so it can be injected i…
Zeegaan Sep 21, 2023
6ba193f
Fix up frontend to match new models
Zeegaan Sep 21, 2023
05c395d
Fix integration tests
Zeegaan Sep 22, 2023
8be6258
Remove obsolete entity key from webhookdto
Zeegaan Sep 22, 2023
65ba2a5
Introduce constants instead of hard coded strings
Zeegaan Sep 25, 2023
9800145
Start implementation of firing mechanism
Zeegaan Sep 26, 2023
bd52ba8
Add new GetByEventName method
Zeegaan Sep 26, 2023
be29bd2
Add 1 to many list on WebhookDto
Zeegaan Sep 26, 2023
4d5e01a
Implement new repository pattern
Zeegaan Sep 27, 2023
8fc0079
Implement GetByEventName
Zeegaan Sep 27, 2023
ba501ef
Fix up repository to use all async
Zeegaan Sep 28, 2023
818be73
Refactor events to fire
Zeegaan Sep 28, 2023
2e9184d
Refactor WebhookEvents to be more DRY
Zeegaan Sep 28, 2023
1c77eb2
Add custom header
Zeegaan Sep 28, 2023
4859dd3
Start implementing log repository
Zeegaan Sep 28, 2023
4bd4aa1
Implement GetPaged
Zeegaan Sep 29, 2023
8d7fc22
Implement WebhookLogService
Zeegaan Oct 2, 2023
4fd4b6a
Implement GetLogs
Zeegaan Oct 3, 2023
9501346
Add url to webhook log
Zeegaan Oct 3, 2023
ece9bbb
Implement log overview
Zeegaan Oct 3, 2023
2ef7042
Formatting
Zeegaan Oct 4, 2023
e67ab16
Implement details view
Zeegaan Oct 4, 2023
8fda54a
Refactor to get actual retry count
Zeegaan Oct 4, 2023
49250c7
Refactor firing to fire only when Enabled
Zeegaan Oct 5, 2023
24a5fa7
Add Status code to detailed view
Zeegaan Oct 6, 2023
3f7de88
Add configuration to disable webhooks entirely
Zeegaan Oct 10, 2023
8ceab7b
Implement custom headers frontend
Zeegaan Oct 11, 2023
cf962a9
Implement persistence of custom headers
Zeegaan Oct 12, 2023
50765f3
Refactor retry service to also retry on non success status codes.
Zeegaan Oct 18, 2023
e3221fd
Refactor registration of Webhooks, to also register as NotificationHa…
Zeegaan Oct 26, 2023
b706373
Merge remote-tracking branch 'origin/v13/dev' into v12/feature/webhooks
Zeegaan Oct 26, 2023
6078d66
Add webhooks migration
Zeegaan Oct 26, 2023
9339f49
Add key for adding webhook headers
Zeegaan Oct 26, 2023
cd751a6
Fix up test
Zeegaan Oct 26, 2023
28b1a8a
Change event icon to flag
Zeegaan Oct 26, 2023
2c41744
Remember event, when editing what events you have chosen
Zeegaan Oct 26, 2023
7f648ce
Refactor reflection to check if INotificationAsyncHandler instead
Zeegaan Oct 27, 2023
f6ace10
Formatting
Zeegaan Oct 27, 2023
d40a6f9
Refactor webhook model to no longer derive from EntityBase
Zeegaan Oct 27, 2023
66da03e
Rename entityKeys to content keys
Zeegaan Oct 27, 2023
866ecb7
Rename controller to lowercase H
Zeegaan Oct 27, 2023
f46ee0d
Add null check before trying to access selectedEvents
Zeegaan Oct 27, 2023
ad7c680
Add configuration for maximum number of retries
Zeegaan Oct 27, 2023
2005500
Add index to date
Zeegaan Oct 27, 2023
90a268b
Add webhook Key to logs
Zeegaan Oct 27, 2023
090fea6
Check for SchedulingPublisher before sending webhooks
Zeegaan Oct 27, 2023
4f0c4a4
rename requestObject to payload
Zeegaan Oct 30, 2023
c62f6cb
Refactor event to send appropriate payloads
Zeegaan Oct 30, 2023
bb8ce08
Refactor logging to happen for every try.
Zeegaan Oct 30, 2023
40e3aa2
Order date by descending
Zeegaan Oct 30, 2023
05388b5
Add todo
Zeegaan Oct 30, 2023
db163b4
Change firing service to use String not ByteContent
Zeegaan Oct 30, 2023
ba2a8a6
Update Headers to Interface instead of concrete implementation
Zeegaan Oct 30, 2023
a8516da
Dont return if a table exists already
Zeegaan Oct 30, 2023
c6f248f
Rename updateModel to webhook
Zeegaan Oct 30, 2023
c0c816a
Annotate WebhookController.cs with PluginController attribute
Zeegaan Oct 30, 2023
6493ac9
Add danish translations
Zeegaan Oct 30, 2023
6407d77
Do not check if fail
Zeegaan Oct 30, 2023
ad5e730
Dont filter when selecting custom items
Zeegaan Oct 30, 2023
ba81ddb
Remove delay from WebhookFiringService
Zeegaan Oct 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/Umbraco.Core/Configuration/Models/WebhookSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.ComponentModel;

namespace Umbraco.Cms.Core.Configuration.Models;

[UmbracoOptions(Constants.Configuration.ConfigWebhook)]
public class WebhookSettings
{
private const bool StaticEnabled = true;
private const int StaticMaximumRetries = 5;

/// <summary>
/// Gets or sets a value indicating whether webhooks are enabled.
/// </summary>
/// <remarks>
/// <para>
/// By default, webhooks are enabled.
/// If this option is set to <c>false</c> webhooks will no longer send web-requests.
/// </para>
/// </remarks>
[DefaultValue(StaticEnabled)]
public bool Enabled { get; set; } = StaticEnabled;

/// <summary>
/// Gets or sets a value indicating the maximum number of retries for all webhooks.
/// </summary>
/// <remarks>
/// <para>
/// By default, maximum number of retries is 5.
/// If this option is set to <c>0</c> webhooks will no longer retry.
/// </para>
/// </remarks>
[DefaultValue(StaticMaximumRetries)]
public int MaximumRetries { get; set; } = StaticMaximumRetries;
}
2 changes: 2 additions & 0 deletions src/Umbraco.Core/Constants-Applications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static class Trees

public const string LogViewer = "logViewer";

public const string Webhooks = "webhooks";

public static class Groups
{
public const string Settings = "settingsGroup";
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Core/Constants-Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static class Configuration
public const string ConfigHelpPage = ConfigPrefix + "HelpPage";
public const string ConfigInstallDefaultData = ConfigPrefix + "InstallDefaultData";
public const string ConfigDataTypes = ConfigPrefix + "DataTypes";
public const string ConfigWebhook = ConfigPrefix + "Webhook";

public static class NamedOptions
{
Expand Down
5 changes: 5 additions & 0 deletions src/Umbraco.Core/Constants-Icons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,10 @@ public static class Icons
/// System user group icon
/// </summary>
public const string UserGroup = "icon-users";

/// <summary>
/// Webhooks icon
/// </summary>
public const string Webhooks = "icon-directions-alt";
Copy link
Copy Markdown
Contributor

@bjarnef bjarnef Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to keep this in singular form @Zeegaan ?
So Webhook like we have User, Folder, Template... although Packages are plural. Maybe we should have a Package constant instead and eventually obsolete the Packages constant.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, sounds correct to me! 😁

Copy link
Copy Markdown
Contributor

@bjarnef bjarnef Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zeegaan does it require VS2022 17.8.0 preview to run v13/dev branch?

I tried to enable .NET 8 preview
https://anthonygiretti.com/2023/06/10/net-8-why-net-8-preview-doesnt-show-up-in-visual-studio-2022/

but it seems to return these warnings.

Targeting .NET 8.0 or higher in Visual Studio 2022 17.7 is not supported.

so not sure if the static assets are built correct as I get this error on startup:

The view '~/umbraco/UmbracoWebsite/Maintenance.cshtml' was not found.

Copy link
Copy Markdown
Member Author

@Zeegaan Zeegaan Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not using VS personally (Rider 😍) But yes presumably you'd have to use a preview of VS, when using the dotnet 8 rc-2 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://dotnetthoughts.net/working-with-dotnet8-projects-in-vs2022/

Yes, I think it requires the latest VS2022 preview to run for now:
dotnet/core#8790

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just edited in VS 2022, but ran via command line next to it:

dotnet build
dotnet run

}
}
32 changes: 32 additions & 0 deletions src/Umbraco.Core/Constants-WebhookEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Umbraco.Cms.Core;

public static partial class Constants
{
public static class WebhookEvents
{
/// <summary>
/// Webhook event name for content publish.
/// </summary>
public const string ContentPublish = "ContentPublish";

/// <summary>
/// Webhook event name for content delete.
/// </summary>
public const string ContentDelete = "ContentDelete";

/// <summary>
/// Webhook event name for content unpublish.
/// </summary>
public const string ContentUnpublish = "ContentUnpublish";

/// <summary>
/// Webhook event name for media delete.
/// </summary>
public const string MediaDelete = "MediaDelete";

/// <summary>
/// Webhook event name for media save.
/// </summary>
public const string MediaSave = "MediaSave";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Umbraco.Cms.Core.Tour;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Core.WebAssets;
using Umbraco.Cms.Core.Webhooks;
using Umbraco.Extensions;

namespace Umbraco.Cms.Core.DependencyInjection;
Expand Down Expand Up @@ -128,6 +129,7 @@ internal static void AddAllCoreCollectionBuilders(this IUmbracoBuilder builder)
builder.FilterHandlers().Add(() => builder.TypeLoader.GetTypes<IFilterHandler>());
builder.SortHandlers().Add(() => builder.TypeLoader.GetTypes<ISortHandler>());
builder.ContentIndexHandlers().Add(() => builder.TypeLoader.GetTypes<IContentIndexHandler>());
builder.WebhookEvents().AddCoreWebhooks();
}

/// <summary>
Expand Down Expand Up @@ -195,6 +197,12 @@ public static MediaUrlProviderCollectionBuilder MediaUrlProviders(this IUmbracoB
public static SectionCollectionBuilder Sections(this IUmbracoBuilder builder)
=> builder.WithCollectionBuilder<SectionCollectionBuilder>();

/// <summary>
/// Gets the backoffice sections/applications collection builder.
/// </summary>
/// <param name="builder">The builder.</param>
public static WebhookEventCollectionBuilder WebhookEvents(this IUmbracoBuilder builder) => builder.WithCollectionBuilder<WebhookEventCollectionBuilder>();

/// <summary>
/// Gets the components collection builder.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public static IUmbracoBuilder AddConfiguration(this IUmbracoBuilder builder)
.AddUmbracoOptions<PackageMigrationSettings>()
.AddUmbracoOptions<ContentDashboardSettings>()
.AddUmbracoOptions<HelpPageSettings>()
.AddUmbracoOptions<DataTypesSettings>();
.AddUmbracoOptions<DataTypesSettings>()
.AddUmbracoOptions<WebhookSettings>();

// Configure connection string and ensure it's updated when the configuration changes
builder.Services.AddSingleton<IConfigureOptions<ConnectionStrings>, ConfigureConnectionStrings>();
Expand Down
4 changes: 4 additions & 0 deletions src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
using Umbraco.Cms.Core.Telemetry;
using Umbraco.Cms.Core.Templates;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Core.Webhooks;
using Umbraco.Extensions;

namespace Umbraco.Cms.Core.DependencyInjection
Expand Down Expand Up @@ -329,6 +330,9 @@ private void AddCoreServices()

// Register filestream security analyzers
Services.AddUnique<IFileStreamSecurityValidator,FileStreamSecurityValidator>();
Services.AddUnique<IWebHookService, WebhookService>();
Services.AddUnique<IWebhookLogService, WebhookLogService>();
Services.AddUnique<IWebhookLogFactory, WebhookLogFactory>();
}
}
}
6 changes: 6 additions & 0 deletions src/Umbraco.Core/EmbeddedResources/Lang/da.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,12 @@
<key alias="welcomeIntro">
<![CDATA[Denne guide vil bringe dig gennem konfigurationsprocessen af <strong>Umbraco %0%</strong> for en frisk installation eller for en opgradering fra version 3.0.<br/><br/>Tryk på <strong>Næste</strong> for at begynde på guiden.]]></key>
</area>
<area alias="webhooks">
<key alias="addWebhook">Opret webhook</key>
<key alias="addWebhookHeader">Tilføj webhook header</key>
<key alias="addDocumentType">Tilføj dokument type</key>
<key alias="addMediaType">Tilføj medie Type</key>
</area>
<area alias="language">
<key alias="cultureCode">Culture Code</key>
<key alias="displayName">Culture Name</key>
Expand Down
8 changes: 8 additions & 0 deletions src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,13 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="historyCleanupGloballyDisabled"><![CDATA[<strong>NOTE!</strong> The cleanup of historically content versions are disabled globally. These settings will not take effect before it is enabled.]]></key>
<key alias="changeDataTypeHelpText">Changing a data type with stored values is disabled. To allow this you can change the Umbraco:CMS:DataTypes:CanBeChanged setting in appsettings.json.</key>
</area>
<area alias="webhooks">
<key alias="addWebhook">Create webhook</key>
<key alias="addWebhookHeader">Add webhook header</key>
<key alias="logs">Logs</key>
<key alias="addDocumentType">Add Document Type</key>
<key alias="addMediaType">Add Media Type</key>
</area>
<area alias="languages">
<key alias="addLanguage">Add language</key>
<key alias="culture">ISO code</key>
Expand Down Expand Up @@ -2119,6 +2126,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="settingsGroup">Settings</key>
<key alias="templatingGroup">Templating</key>
<key alias="thirdPartyGroup">Third Party</key>
<key alias="webhooks">Webhooks</key>
</area>
<area alias="update">
<key alias="updateAvailable">New update ready</key>
Expand Down
6 changes: 6 additions & 0 deletions src/Umbraco.Core/Models/DefaultPayloadModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Umbraco.Cms.Core.Models;

internal class DefaultPayloadModel
{
public Guid Id { get; set; }
}
27 changes: 27 additions & 0 deletions src/Umbraco.Core/Models/Webhook.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Umbraco.Cms.Core.Models;

public class Webhook
{
public Webhook(string url, bool? enabled = null, Guid[]? entityKeys = null, string[]? events = null, IDictionary<string, string>? headers = null)
{
Url = url;
Headers = headers ?? new Dictionary<string, string>();
Events = events ?? Array.Empty<string>();
ContentTypeKeys = entityKeys ?? Array.Empty<Guid>();
Enabled = enabled ?? false;
}

public int Id { get; set; }

public Guid Key { get; set; }

public string Url { get; set; }

public string[] Events { get; set; }

public Guid[] ContentTypeKeys {get; set; }

public bool Enabled { get; set; }

public IDictionary<string, string> Headers { get; set; }
}
28 changes: 28 additions & 0 deletions src/Umbraco.Core/Models/WebhookLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Umbraco.Cms.Core.Models;

public class WebhookLog
{
public int Id { get; set; }

public Guid WebhookKey { get; set; }

public Guid Key { get; set; }

public string Url { get; set; } = string.Empty;

public string StatusCode { get; set; } = string.Empty;

public DateTime Date { get; set; }

public string EventName { get; set; } = string.Empty;

public int RetryCount { get; set; }

public string RequestHeaders { get; set; } = string.Empty;

public string? RequestBody { get; set; } = string.Empty;

public string ResponseHeaders { get; set; } = string.Empty;

public string ResponseBody { get; set; } = string.Empty;
}
8 changes: 8 additions & 0 deletions src/Umbraco.Core/Models/WebhookResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Umbraco.Cms.Core.Models;

public class WebhookResponseModel
{
public HttpResponseMessage? HttpResponseMessage { get; set; }

public int RetryCount { get; set; }
}
15 changes: 15 additions & 0 deletions src/Umbraco.Core/PaginationHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Umbraco.Cms.Core;

public static class PaginationHelper
{
public static void ConvertSkipTakeToPaging(int skip, int take, out long pageNumber, out int pageSize)
{
if (skip % take != 0)
{
throw new ArgumentException("Invalid skip/take, Skip must be a multiple of take - i.e. skip = 10, take = 5");
}

pageSize = take;
pageNumber = skip / take;
}
}
5 changes: 5 additions & 0 deletions src/Umbraco.Core/Persistence/Constants-DatabaseSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public static class Tables
public const string LogViewerQuery = TableNamePrefix + "LogViewerQuery";

public const string CreatedPackageSchema = TableNamePrefix + "CreatedPackageSchema";
public const string Webhook = TableNamePrefix + "Webhook";
public const string Webhook2ContentTypeKeys = Webhook + "2ContentTypeKeys";
public const string Webhook2Events = Webhook + "2Events";
public const string Webhook2Headers = Webhook + "2Headers";
public const string WebhookLog = TableNamePrefix + "WebhookLog";
}
}
}
11 changes: 11 additions & 0 deletions src/Umbraco.Core/Persistence/Repositories/IWebhookLogRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Webhooks;

namespace Umbraco.Cms.Core.Persistence.Repositories;

public interface IWebhookLogRepository
{
Task CreateAsync(WebhookLog log);

Task<PagedModel<WebhookLog>> GetPagedAsync(int skip, int take);
}
49 changes: 49 additions & 0 deletions src/Umbraco.Core/Persistence/Repositories/IWebhookRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Persistence.Repositories;

public interface IWebhookRepository
{
/// <summary>
/// Gets all of the webhooks in the current database.
/// </summary>
/// <param name="skip">Number of entries to skip.</param>
/// <param name="take">Number of entries to take.</param>
/// <returns>A paged model of <see cref="Webhook" /> objects.</returns>
Task<PagedModel<Webhook>> GetAllAsync(int skip, int take);

/// <summary>
/// Gets all of the webhooks in the current database.
/// </summary>
/// <param name="webhook">The webhook you want to create.</param>
/// <returns>The created <see cref="Webhook" /> webhook</returns>
Task<Webhook> CreateAsync(Webhook webhook);

/// <summary>
/// Gets a webhook by key
/// </summary>
/// <param name="key">The key of the webhook which will be retrieved.</param>
/// <returns>The <see cref="Webhook" /> webhook with the given key.</returns>
Task<Webhook?> GetAsync(Guid key);

/// <summary>
/// Gets a webhook by key
/// </summary>
/// <param name="eventName">The key of the webhook which will be retrieved.</param>
/// <returns>The <see cref="Webhook" /> webhook with the given key.</returns>
Task<PagedModel<Webhook>> GetByEventNameAsync(string eventName);

/// <summary>
/// Gets a webhook by key
/// </summary>
/// <param name="webhook">The webhook to be deleted.</param>
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
Task DeleteAsync(Webhook webhook);

/// <summary>
/// Updates a given webhook
/// </summary>
/// <param name="webhook">The webhook to be updated.</param>
/// <returns>The updated <see cref="Webhook" /> webhook.</returns>
Task UpdateAsync(Webhook webhook);
}
18 changes: 18 additions & 0 deletions src/Umbraco.Core/Services/IWebHookService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Services;

public interface IWebHookService
{
Task<Webhook> CreateAsync(Webhook webhook);

Task UpdateAsync(Webhook webhook);

Task DeleteAsync(Guid key);

Task<Webhook?> GetAsync(Guid key);

Task<PagedModel<Webhook>> GetAllAsync(int skip, int take);

Task<IEnumerable<Webhook>> GetByEventNameAsync(string eventName);
}
8 changes: 8 additions & 0 deletions src/Umbraco.Core/Services/IWebhookFiringService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Services;

public interface IWebhookFiringService
{
Task FireAsync(Webhook webhook, string eventName, object? payload, CancellationToken cancellationToken);
}
9 changes: 9 additions & 0 deletions src/Umbraco.Core/Services/IWebhookLogFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Webhooks;

namespace Umbraco.Cms.Core.Services;

public interface IWebhookLogFactory
{
Task<WebhookLog> CreateAsync(string eventName, WebhookResponseModel responseModel, Webhook webhook, CancellationToken cancellationToken);
}
Loading