From 9e9776cee0fb5e4567f8f2e853e78d1d3b643572 Mon Sep 17 00:00:00 2001 From: Artem Riabushenko Date: Fri, 10 Apr 2026 20:23:35 +0300 Subject: [PATCH 1/3] Made workflow definition ID multiple input in event --- Apps.Contentful/Apps.Contentful.csproj | 2 +- .../WorkflowStepDataHandlerHandler.cs | 8 +++--- .../WorkflowDefinitionOptionalIdentifier.cs | 2 +- .../Requests/WorkflowStepFilterRequest.cs | 9 ++----- .../Webhooks/WorkflowWebhookList.cs | 27 ++++++++++--------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Apps.Contentful/Apps.Contentful.csproj b/Apps.Contentful/Apps.Contentful.csproj index d26ee3b..11a580d 100644 --- a/Apps.Contentful/Apps.Contentful.csproj +++ b/Apps.Contentful/Apps.Contentful.csproj @@ -6,7 +6,7 @@ enable Contentful The headless content management system - 1.8.10 + 1.8.11 Apps.Contentful diff --git a/Apps.Contentful/DataSourceHandlers/WorkflowStepDataHandlerHandler.cs b/Apps.Contentful/DataSourceHandlers/WorkflowStepDataHandlerHandler.cs index 2e5082c..dff059c 100644 --- a/Apps.Contentful/DataSourceHandlers/WorkflowStepDataHandlerHandler.cs +++ b/Apps.Contentful/DataSourceHandlers/WorkflowStepDataHandlerHandler.cs @@ -18,13 +18,15 @@ public class WorkflowStepDataHandler( public async Task> GetDataAsync(DataSourceContext context, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(workflowStepFilterRequest.WorkflowDefinitionId)) + var workflowDefinitionId = workflowStepFilterRequest.WorkflowDefinitionId?.FirstOrDefault(); + + if (string.IsNullOrEmpty(workflowDefinitionId)) { throw new InvalidOperationException("You should provide a workflow definition ID first"); } var client = new ContentfulRestClient(Creds, identifier.Environment); - var request = new ContentfulRestRequest($"/workflow_definitions/{workflowStepFilterRequest.WorkflowDefinitionId}", Method.Get, Creds); + var request = new ContentfulRestRequest($"/workflow_definitions/{workflowDefinitionId}", Method.Get, Creds); var workflowDefinition = await client.ExecuteWithErrorHandling(request); return workflowDefinition.Steps @@ -32,4 +34,4 @@ public async Task> GetDataAsync(DataSourceContext con x.Name.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase)) .ToDictionary(x => x.StepId, x => x.Name); } -} \ No newline at end of file +} diff --git a/Apps.Contentful/Models/Identifiers/WorkflowDefinitionOptionalIdentifier.cs b/Apps.Contentful/Models/Identifiers/WorkflowDefinitionOptionalIdentifier.cs index 9361a28..d7571a5 100644 --- a/Apps.Contentful/Models/Identifiers/WorkflowDefinitionOptionalIdentifier.cs +++ b/Apps.Contentful/Models/Identifiers/WorkflowDefinitionOptionalIdentifier.cs @@ -7,5 +7,5 @@ namespace Apps.Contentful.Models.Identifiers; public class WorkflowDefinitionOptionalIdentifier { [Display("Workflow definition ID"), DataSource(typeof(WorkflowDefinitionDataHandler))] - public string? WorkflowDefinitionId { get; set; } + public IEnumerable? WorkflowDefinitionId { get; set; } } \ No newline at end of file diff --git a/Apps.Contentful/Models/Requests/WorkflowStepFilterRequest.cs b/Apps.Contentful/Models/Requests/WorkflowStepFilterRequest.cs index 647fde1..8170c99 100644 --- a/Apps.Contentful/Models/Requests/WorkflowStepFilterRequest.cs +++ b/Apps.Contentful/Models/Requests/WorkflowStepFilterRequest.cs @@ -1,15 +1,10 @@ -using Apps.Contentful.DataSourceHandlers; using Apps.Contentful.Models.Identifiers; using Blackbird.Applications.Sdk.Common; -using Blackbird.Applications.Sdk.Common.Dynamic; namespace Apps.Contentful.Models.Requests; public class WorkflowStepFilterRequest : WorkflowDefinitionOptionalIdentifier { - [Display("Current step ID"), DataSource(typeof(WorkflowStepDataHandler))] - public string? CurrentStepId { get; set; } - [Display("Current step name", Description = "Filter by the name of the current step")] - public string? CurrentStepName { get; set; } -} \ No newline at end of file + public IEnumerable? CurrentStepName { get; set; } +} diff --git a/Apps.Contentful/Webhooks/WorkflowWebhookList.cs b/Apps.Contentful/Webhooks/WorkflowWebhookList.cs index b33c921..7eccf34 100644 --- a/Apps.Contentful/Webhooks/WorkflowWebhookList.cs +++ b/Apps.Contentful/Webhooks/WorkflowWebhookList.cs @@ -34,8 +34,18 @@ private async Task> HandleWebhookRes { var content = webhookRequest.Body.ToString()!; var workflowDto = JsonConvert.DeserializeObject(content)!; + var workflowDefinitionId = workflowDto.Sys.WorkflowDefinition.Sys.Id; + + if (request.WorkflowDefinitionId?.Any() == true && + request.WorkflowDefinitionId.Contains(workflowDefinitionId) == false) + { + return new WebhookResponse + { + ReceivedWebhookRequestType = WebhookRequestType.Preflight + }; + } - var workflowDefinitionRequest = new ContentfulRestRequest($"/workflow_definitions/{workflowDto.Sys.WorkflowDefinition.Sys.Id}", Method.Get, Creds); + var workflowDefinitionRequest = new ContentfulRestRequest($"/workflow_definitions/{workflowDefinitionId}", Method.Get, Creds); var client = new ContentfulRestClient(Creds, environmentIdentifier.Environment); var workflowDefinition = await client.ExecuteWithErrorHandling(workflowDefinitionRequest); @@ -44,16 +54,9 @@ private async Task> HandleWebhookRes var nextStep = nextStepIndex < workflowDefinition.Steps.Count ? workflowDefinition.Steps[nextStepIndex] : null; var previousStep = workflowDefinition.Steps.FirstOrDefault(x => x.StepId == workflowDto.PreviousStepId); - - if (request.CurrentStepId != null && request.CurrentStepId != workflowDto.StepId) - { - return new WebhookResponse - { - ReceivedWebhookRequestType = WebhookRequestType.Preflight - }; - } - - if (request.CurrentStepName != null && request.CurrentStepName != currentStep.Name) + + if (request.CurrentStepName?.Any() == true && + request.CurrentStepName.Contains(currentStep.Name) == false) { return new WebhookResponse { @@ -95,4 +98,4 @@ private async Task> HandleWebhookRes } }; } -} \ No newline at end of file +} From daf96fb41c0b6bd2a7b3d716ffd1001e8cfb0bb6 Mon Sep 17 00:00:00 2001 From: Anton Fesenko <111450737+Fesenko-A@users.noreply.github.com> Date: Tue, 14 Apr 2026 17:35:48 +0300 Subject: [PATCH 2/3] add boolean parsing for uploading custom JSONs --- Apps.Contentful/Apps.Contentful.csproj | 2 +- .../HtmlHelpers/EntryToJsonConverter.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Apps.Contentful/Apps.Contentful.csproj b/Apps.Contentful/Apps.Contentful.csproj index 11a580d..8c4f621 100644 --- a/Apps.Contentful/Apps.Contentful.csproj +++ b/Apps.Contentful/Apps.Contentful.csproj @@ -6,7 +6,7 @@ enable Contentful The headless content management system - 1.8.11 + 1.8.12 Apps.Contentful diff --git a/Apps.Contentful/HtmlHelpers/EntryToJsonConverter.cs b/Apps.Contentful/HtmlHelpers/EntryToJsonConverter.cs index 60ddd9b..4adfbb1 100644 --- a/Apps.Contentful/HtmlHelpers/EntryToJsonConverter.cs +++ b/Apps.Contentful/HtmlHelpers/EntryToJsonConverter.cs @@ -360,7 +360,11 @@ private static JToken ParseValueFromNode(HtmlNode node) return ParseUlAsArray(ulChild); } - var textValue = System.Web.HttpUtility.HtmlDecode(node.InnerText.Trim()); + var textValue = HttpUtility.HtmlDecode(node.InnerText.Trim()); + + if (bool.TryParse(textValue, out var boolValue)) + return JValue.FromObject(boolValue); + return JValue.FromObject(textValue); } @@ -387,8 +391,12 @@ private static JToken ParseUlAsArray(HtmlNode ulNode) continue; } - var textValue = System.Web.HttpUtility.HtmlDecode(li.InnerText.Trim()); - array.Add(JValue.FromObject(textValue)); + var textValue = HttpUtility.HtmlDecode(li.InnerText.Trim()); + + if (bool.TryParse(textValue, out var boolValue)) + array.Add(JValue.FromObject(boolValue)); + else + array.Add(JValue.FromObject(textValue)); } } From 77d4ea491be9237aff9d445422085040cd61d0d5 Mon Sep 17 00:00:00 2001 From: Anton Fesenko <111450737+Fesenko-A@users.noreply.github.com> Date: Tue, 14 Apr 2026 17:39:08 +0300 Subject: [PATCH 3/3] fix version --- Apps.Contentful/Apps.Contentful.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps.Contentful/Apps.Contentful.csproj b/Apps.Contentful/Apps.Contentful.csproj index 8c4f621..11a580d 100644 --- a/Apps.Contentful/Apps.Contentful.csproj +++ b/Apps.Contentful/Apps.Contentful.csproj @@ -6,7 +6,7 @@ enable Contentful The headless content management system - 1.8.12 + 1.8.11 Apps.Contentful