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/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));
}
}
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
+}