diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs index bc13660a1..294b18353 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs @@ -20,4 +20,7 @@ public class ElementButton [JsonPropertyName("is_secondary")] public bool IsSecondary { get; set; } + + [JsonPropertyName("post_action_disclaimer")] + public string? PostActionDisclaimer { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Repositories/Enums/RepositoryEnum.cs b/src/Infrastructure/BotSharp.Abstraction/Repositories/Enums/RepositoryEnum.cs new file mode 100644 index 000000000..f71845a53 --- /dev/null +++ b/src/Infrastructure/BotSharp.Abstraction/Repositories/Enums/RepositoryEnum.cs @@ -0,0 +1,7 @@ +namespace BotSharp.Abstraction.Repositories.Enums; + +public static class RepositoryEnum +{ + public const string FileRepository = nameof(FileRepository); + public const string MongoRepository = nameof(MongoRepository); +} diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs index 356707a87..0b61977e0 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs @@ -1,3 +1,4 @@ +using BotSharp.Abstraction.Repositories.Enums; using System.IO; namespace BotSharp.Core.Agents.Services; @@ -6,12 +7,19 @@ public partial class AgentService { public async Task RefreshAgents() { + string refreshResult; var dbSettings = _services.GetRequiredService(); + if (dbSettings.Default == RepositoryEnum.FileRepository) + { + refreshResult = $"Invalid database repository setting: {dbSettings.Default}"; + _logger.LogWarning(refreshResult); + return refreshResult; + } + var agentDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dbSettings.FileRepository, _agentSettings.DataDir); - string refreshResult; if (!Directory.Exists(agentDir)) { refreshResult = $"Cannot find the directory: {agentDir}"; diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs index 747bd11cd..0cce42093 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs @@ -1,6 +1,7 @@ using BotSharp.Abstraction.Agents.Models; using BotSharp.Abstraction.Functions.Models; using BotSharp.Abstraction.Repositories; +using BotSharp.Abstraction.Repositories.Enums; using BotSharp.Abstraction.Routing.Models; using System.IO; @@ -42,6 +43,16 @@ public async Task UpdateAgent(Agent agent, AgentField updateField) public async Task UpdateAgentFromFile(string id) { string updateResult; + var dbSettings = _services.GetRequiredService(); + var agentSettings = _services.GetRequiredService(); + + if (dbSettings.Default == RepositoryEnum.FileRepository) + { + updateResult = $"Invalid database repository setting: {dbSettings.Default}"; + _logger.LogWarning(updateResult); + return updateResult; + } + var agent = _db.GetAgent(id); if (agent == null) { @@ -50,8 +61,6 @@ public async Task UpdateAgentFromFile(string id) return updateResult; } - var dbSettings = _services.GetRequiredService(); - var agentSettings = _services.GetRequiredService(); var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dbSettings.FileRepository, agentSettings.DataDir); diff --git a/src/Infrastructure/BotSharp.Core/Repository/RepositoryPlugin.cs b/src/Infrastructure/BotSharp.Core/Repository/RepositoryPlugin.cs index ee397e38e..3160597a5 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/RepositoryPlugin.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/RepositoryPlugin.cs @@ -1,3 +1,4 @@ +using BotSharp.Abstraction.Repositories.Enums; using BotSharp.Abstraction.Settings; using Microsoft.Extensions.Configuration; @@ -32,7 +33,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config) var myDatabaseSettings = new BotSharpDatabaseSettings(); config.Bind("Database", myDatabaseSettings); - if (myDatabaseSettings.Default == "FileRepository") + if (myDatabaseSettings.Default == RepositoryEnum.FileRepository) { services.AddScoped(); } diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs index a7a574fa0..8c4c43b99 100644 --- a/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs +++ b/src/Plugins/BotSharp.Plugin.MongoStorage/MongoStoragePlugin.cs @@ -1,4 +1,5 @@ using BotSharp.Abstraction.Plugins.Models; +using BotSharp.Abstraction.Repositories.Enums; using BotSharp.Plugin.MongoStorage.Repository; namespace BotSharp.Plugin.MongoStorage; @@ -18,7 +19,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config) var dbSettings = new BotSharpDatabaseSettings(); config.Bind("Database", dbSettings); - if (dbSettings.Default == "MongoRepository") + if (dbSettings.Default == RepositoryEnum.MongoRepository) { services.AddScoped((IServiceProvider x) => {