Compare commits
2 Commits
25ec371961
...
1d249d13ba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d249d13ba | ||
| 8dfaa7e0f7 |
@ -26,8 +26,39 @@ public class BotService : IBotService
|
|||||||
|
|
||||||
public async Task<BotRegistrationResponseDto> RegisterBotAsync(BotRegistrationDto dto)
|
public async Task<BotRegistrationResponseDto> RegisterBotAsync(BotRegistrationDto dto)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Registering new bot: {BotName}", dto.Name);
|
_logger.LogInformation("Registering bot: {BotName} (Type: {BotType})", dto.Name, dto.Type);
|
||||||
|
|
||||||
|
// Check if a bot with the same name and type already exists
|
||||||
|
var existingBot = await _context.Bots
|
||||||
|
.FirstOrDefaultAsync(b => b.Name == dto.Name && b.Type == dto.Type);
|
||||||
|
|
||||||
|
if (existingBot != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Bot already exists: {BotId}. Updating existing bot instead of creating duplicate.", existingBot.Id);
|
||||||
|
|
||||||
|
// Update existing bot
|
||||||
|
existingBot.Description = dto.Description;
|
||||||
|
existingBot.Version = dto.Version;
|
||||||
|
existingBot.Settings = JsonSerializer.Serialize(dto.InitialSettings);
|
||||||
|
existingBot.PersonalityName = string.IsNullOrEmpty(dto.PersonalityName) ? existingBot.PersonalityName : dto.PersonalityName;
|
||||||
|
existingBot.Status = BotStatus.Active;
|
||||||
|
existingBot.IsActive = true;
|
||||||
|
existingBot.LastConfigSyncAt = DateTime.UtcNow;
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
_logger.LogInformation("Existing bot updated: {BotId}", existingBot.Id);
|
||||||
|
|
||||||
|
return new BotRegistrationResponseDto
|
||||||
|
{
|
||||||
|
BotId = existingBot.Id,
|
||||||
|
BotKey = existingBot.BotKey,
|
||||||
|
Name = existingBot.Name,
|
||||||
|
Settings = dto.InitialSettings
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new bot if none exists
|
||||||
var botKey = await GenerateBotKeyAsync();
|
var botKey = await GenerateBotKeyAsync();
|
||||||
|
|
||||||
var bot = new Bot
|
var bot = new Bot
|
||||||
@ -48,7 +79,7 @@ public class BotService : IBotService
|
|||||||
_context.Bots.Add(bot);
|
_context.Bots.Add(bot);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
_logger.LogInformation("Bot registered successfully: {BotId}", bot.Id);
|
_logger.LogInformation("New bot registered successfully: {BotId}", bot.Id);
|
||||||
|
|
||||||
return new BotRegistrationResponseDto
|
return new BotRegistrationResponseDto
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
"ExpiryInHours": 2
|
"ExpiryInHours": 2
|
||||||
},
|
},
|
||||||
"SilverPay": {
|
"SilverPay": {
|
||||||
"BaseUrl": "http://localhost:8001",
|
"BaseUrl": "http://10.0.0.51:5500",
|
||||||
"ApiKey": "sp_test_key_development",
|
"ApiKey": "OCTk42VKenf5KZqKDDRAAskxf53yJsEby72j99Fc",
|
||||||
"WebhookSecret": "webhook_secret_dev",
|
"WebhookSecret": "webhook_secret_dev",
|
||||||
"DefaultWebhookUrl": "http://localhost:5000/api/orders/payments/webhook",
|
"DefaultWebhookUrl": "http://localhost:5000/api/orders/payments/webhook",
|
||||||
"AllowUnsignedWebhooks": true
|
"AllowUnsignedWebhooks": true
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
"Comment": "Optional secret key for webhook authentication"
|
"Comment": "Optional secret key for webhook authentication"
|
||||||
},
|
},
|
||||||
"LittleShop": {
|
"LittleShop": {
|
||||||
"ApiUrl": "http://littleshop:5000",
|
"ApiUrl": "http://localhost:5000",
|
||||||
"OnionUrl": "",
|
"OnionUrl": "",
|
||||||
"Username": "admin",
|
"Username": "admin",
|
||||||
"Password": "admin",
|
"Password": "admin",
|
||||||
@ -34,7 +34,7 @@
|
|||||||
"EnableAnalytics": false,
|
"EnableAnalytics": false,
|
||||||
"RequirePGPForShipping": false,
|
"RequirePGPForShipping": false,
|
||||||
"EphemeralByDefault": true,
|
"EphemeralByDefault": true,
|
||||||
"EnableTor": true,
|
"EnableTor": false,
|
||||||
"TorSocksHost": "tor-gateway",
|
"TorSocksHost": "tor-gateway",
|
||||||
"TorSocksPort": 9050,
|
"TorSocksPort": 9050,
|
||||||
"TorControlPort": 9051,
|
"TorControlPort": 9051,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user