| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,16 @@ public async Task<IActionResult> ExecuteTrigger(string triggerSlug, TriggerReque | |||
| 25 | 25 | return NotFound(); | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | - var result = await trigger.ExecuteAsync(triggerRequest); | ||
| 28 | + if (await trigger.ExecuteAsync(triggerRequest) is not { } result) | ||
| 29 | + { | ||
| 30 | + throw new InvalidOperationException("The trigger response is invalid: the response is null."); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + if (result.Count > triggerRequest.Limit) | ||
| 34 | + { | ||
| 35 | + logger.LogWarning("The trigger response data count ({DataCount}) is greater than the limit ({Limit}). Excess data will be removed ", result.Count, triggerRequest.Limit); | ||
| 36 | + result = result.Take(triggerRequest.Limit).ToList(); | ||
| 37 | + } | ||
| 29 | 38 | ||
| 30 | 39 | return Ok(result); | |
| 31 | 40 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,6 @@ public interface ITrigger | |||
| 12 | 12 | /// </summary> | |
| 13 | 13 | /// <param name="triggerRequest">The trigger request that contains the trigger fields data.</param> | |
| 14 | 14 | /// <param name="cancellationToken"></param> | |
| 15 | - /// <returns>The Trigger response.</returns> | ||
| 16 | - Task<TriggerResponse> ExecuteAsync(TriggerRequest triggerRequest, CancellationToken cancellationToken = default); | ||
| 15 | + /// <returns>A list of <see cref="TriggerData"/> or derived class.</returns> | ||
| 16 | + Task<IReadOnlyList<TriggerData>> ExecuteAsync(TriggerRequest triggerRequest, CancellationToken cancellationToken = default); | ||
| 17 | 17 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + using System.Text.Json.Serialization; | ||
| 2 | + | ||
| 3 | + namespace InvvardDev.Ifttt.Toolkit; | ||
| 4 | + | ||
| 5 | + public record TriggerData([property: JsonIgnore] string Id, | ||
| 6 | + [property: JsonIgnore] DateTimeOffset Timestamp) | ||
| 7 | + { | ||
| 8 | + public Meta Meta { get; init; } = new(Id, Timestamp.ToUnixTimeSeconds().ToString()); | ||
| 9 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + namespace InvvardDev.Ifttt.Toolkit; | ||
| 2 | + | ||
| 3 | + public record Meta(string Id, string Timestamp); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments