Skip to content

Commit

Permalink
Merge pull request #104 from Poltuu/up
Browse files Browse the repository at this point in the history
ADD : onbeforeAdd hook
  • Loading branch information
Poltuu authored Jun 17, 2020
2 parents 367f308 + b7c0533 commit 6940357
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Harpoon.Registrations.EFStorage/WebHookRegistrationStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public async Task<WebHookRegistrationStoreResult> InsertWebHookAsync(IPrincipal
Filters = webHook.Filters.Select(f => new WebHookFilter { Trigger = f.Trigger }).ToList()
};

if (!OnBeforeAdd(dbWebHook))
{
return WebHookRegistrationStoreResult.Success;
}

try
{
_context.Add(dbWebHook);
Expand All @@ -130,6 +135,13 @@ public async Task<WebHookRegistrationStoreResult> InsertWebHookAsync(IPrincipal
}
}

/// <summary>
/// Returns a value indicating if the webhook should be added. Give the opportunity to modify the webhook as well.
/// </summary>
/// <param name="webhook"></param>
/// <returns></returns>
protected virtual bool OnBeforeAdd(WebHook webhook) => true;

/// <inheritdoc />
public async Task<WebHookRegistrationStoreResult> UpdateWebHookAsync(IPrincipal user, IWebHook webHook, CancellationToken cancellationToken = default)
{
Expand Down

0 comments on commit 6940357

Please sign in to comment.