From ba68d1010feea9a163b059f6a07c2cc5561958a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Domeradzki?= Date: Wed, 25 Dec 2024 14:34:18 +0100 Subject: [PATCH] Add optional filtering for plugins GET endpoint --- .../IPC/Controllers/Api/PluginsController.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs b/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs index c3870d34b..d7a286dcc 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/PluginsController.cs @@ -37,9 +37,28 @@ namespace ArchiSteamFarm.IPC.Controllers.Api; [Route("Api/Plugins")] public sealed class PluginsController : ArchiController { + /// + /// Gets active plugins loaded into the process. + /// [HttpGet] [ProducesResponseType>>((int) HttpStatusCode.OK)] - public ActionResult>> PluginsGet() => Ok(new GenericResponse>(PluginsCore.ActivePlugins)); + public ActionResult>> PluginsGet([FromQuery] bool official = true, [FromQuery] bool custom = true) { + HashSet result = []; + + foreach (IPlugin plugin in PluginsCore.ActivePlugins) { + if (plugin is OfficialPlugin) { + if (official) { + result.Add(plugin); + } + } else { + if (custom) { + result.Add(plugin); + } + } + } + + return Ok(new GenericResponse>(result)); + } /// /// Makes ASF update selected plugins.