aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Search/API
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-12-17 16:31:12 -0600
committerGitHub <noreply@github.com>2024-12-17 16:31:12 -0600
commitac4518147eebd921edb7cf465013eabc37fae4e7 (patch)
tree5de10a59601042e0c9bd9e4a168e2e26a9165342 /src/slskd/Search/API
parentf1b250ccd31bfbb38d47ebd3570c072539c98430 (diff)
parent57704f7a402bd779c74b42b460c6bb0d206cbe0c (diff)
downloadslskd-ac4518147eebd921edb7cf465013eabc37fae4e7.tar.gz
Merge pull request #1257 from slskd/search-retention
Add the ability to configure search record retention
Diffstat (limited to 'src/slskd/Search/API')
-rw-r--r--src/slskd/Search/API/Controllers/SearchesController.cs2
-rw-r--r--src/slskd/Search/API/Hubs/SearchHub.cs29
2 files changed, 26 insertions, 5 deletions
diff --git a/src/slskd/Search/API/Controllers/SearchesController.cs b/src/slskd/Search/API/Controllers/SearchesController.cs
index 56c5f533..d6d96bbe 100644
--- a/src/slskd/Search/API/Controllers/SearchesController.cs
+++ b/src/slskd/Search/API/Controllers/SearchesController.cs
@@ -210,7 +210,7 @@ namespace slskd.Search.API
return Forbid();
}
- var search = await Searches.FindAsync(search => search.Id == id, includeResponses: true);
+ var search = await Searches.FindAsync(search => search.Id == id, includeResponses: false);
if (search == default)
{
diff --git a/src/slskd/Search/API/Hubs/SearchHub.cs b/src/slskd/Search/API/Hubs/SearchHub.cs
index b1fbf725..e1cfb4b5 100644
--- a/src/slskd/Search/API/Hubs/SearchHub.cs
+++ b/src/slskd/Search/API/Hubs/SearchHub.cs
@@ -39,16 +39,19 @@ namespace slskd.Search.API
/// <summary>
/// Broadcast an update for a search.
/// </summary>
+ /// <remarks>
+ /// Responses are removed prior to sending.
+ /// </remarks>
/// <param name="hub">The hub.</param>
/// <param name="search">The search to broadcast.</param>
/// <returns>The operation context.</returns>
public static Task BroadcastUpdateAsync(this IHubContext<SearchHub> hub, Search search)
{
- return hub.Clients.All.SendAsync(SearchHubMethods.Update, search);
+ return hub.Clients.All.SendAsync(SearchHubMethods.Update, search with { Responses = null });
}
/// <summary>
- /// Broadcast the present application options.
+ /// Broadcast a newly received search response.
/// </summary>
/// <param name="hub">The hub.</param>
/// <param name="searchId">The ID of the search associated with the response.</param>
@@ -59,14 +62,32 @@ namespace slskd.Search.API
return hub.Clients.All.SendAsync(SearchHubMethods.Response, new { searchId, response });
}
+ /// <summary>
+ /// Broadcast the creation of a new search.
+ /// </summary>
+ /// <remarks>
+ /// Responses are removed prior to sending.
+ /// </remarks>
+ /// <param name="hub">The hub.</param>
+ /// <param name="search">The search to broadcast.</param>
+ /// <returns>The operation context.</returns>
public static Task BroadcastCreateAsync(this IHubContext<SearchHub> hub, Search search)
{
- return hub.Clients.All.SendAsync(SearchHubMethods.Create, search);
+ return hub.Clients.All.SendAsync(SearchHubMethods.Create, search with { Responses = null });
}
+ /// <summary>
+ /// Broadcast the deletion of a search.
+ /// </summary>
+ /// <remarks>
+ /// Responses are removed prior to sending.
+ /// </remarks>
+ /// <param name="hub">The hub.</param>
+ /// <param name="search">The search to broadcast.</param>
+ /// <returns>The operation context.</returns>
public static Task BroadcastDeleteAsync(this IHubContext<SearchHub> hub, Search search)
{
- return hub.Clients.All.SendAsync(SearchHubMethods.Delete, search);
+ return hub.Clients.All.SendAsync(SearchHubMethods.Delete, search with { Responses = null });
}
}