forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingController.cs
More file actions
37 lines (31 loc) · 1.03 KB
/
SettingController.cs
File metadata and controls
37 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using BotSharp.Abstraction.Settings;
using BotSharp.Core.Plugins;
namespace BotSharp.OpenAPI.Controllers;
[Authorize]
[ApiController]
public class SettingController : ControllerBase
{
private readonly IServiceProvider _services;
private readonly ISettingService _settingService;
public SettingController(IServiceProvider services,
ISettingService settingService)
{
_services = services;
_settingService = settingService;
}
[HttpGet("/settings")]
public List<string> GetSettings()
{
var pluginService = _services.GetRequiredService<PluginLoader>();
var plugins = pluginService.GetPlugins(_services);
return plugins.Where(x => x.Module.Settings != null && !string.IsNullOrEmpty(x.Module.Settings.Name))
.Select(x => x.Module.Settings.Name)
.OrderBy(x => x)
.ToList();
}
[HttpGet("/setting/{id}")]
public object GetSettingDetail([FromRoute] string id)
{
return _settingService.GetDetail(id, mask: true);
}
}