-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added hub and flow tokens. Clean up and add more serialization bits.
- Loading branch information
1 parent
1a830c5
commit 0681e02
Showing
13 changed files
with
154 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.301" | ||
"version": "8.0.302", | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) David Pine. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace ProfanityFilter.WebApi.Hubs; | ||
|
||
public sealed class ProfanityHub(IProfaneContentFilterService filter) : Hub | ||
{ | ||
[HubMethodName("live")] | ||
public async IAsyncEnumerable<ProfanityFilterResponse> LiveStream( | ||
IAsyncEnumerable<ProfanityFilterRequest> liveRequests, | ||
[EnumeratorCancellation] | ||
CancellationToken cancellationToken) | ||
{ | ||
await foreach (var request in liveRequests) | ||
{ | ||
var parameters = new FilterParameters( | ||
request.Strategy, request.Target); | ||
|
||
var result = await filter.FilterProfanityAsync( | ||
request.Text, parameters, cancellationToken); | ||
|
||
if (result is null or { FinalOutput: null }) | ||
{ | ||
yield break; | ||
} | ||
|
||
yield return (result, request.Strategy); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) David Pine. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace ProfanityFilter.WebApi.Models; | ||
|
||
public sealed record class FilterTargetResponse( | ||
string Name, | ||
int Value, | ||
string Description) | ||
{ | ||
public static implicit operator FilterTargetResponse(FilterTarget target) | ||
{ | ||
var description = target switch | ||
{ | ||
FilterTarget.Title => "Used to indicate that the target of the filter should not include escaped Markdown.", | ||
FilterTarget.Body => "Used to indicate that the target of the filter should include escaped Markdown.", | ||
_ => "Same as body, used to indicate that the target of the filter should include escaped Markdown.", | ||
}; | ||
|
||
return new FilterTargetResponse( | ||
Name: Enum.GetName(target) ?? target.ToString(), | ||
Value: (int)target, | ||
Description: description); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters