🐛 Fix bots errors
This commit is contained in:
@@ -65,7 +65,7 @@ public class BotAccountController(
|
|||||||
|
|
||||||
[MaxLength(256)] public string? Nick { get; set; } = string.Empty;
|
[MaxLength(256)] public string? Nick { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Required] [MaxLength(1024)] public string Slug { get; set; } = string.Empty;
|
[Required] [MaxLength(1024)] public string? Slug { get; set; } = string.Empty;
|
||||||
|
|
||||||
[MaxLength(128)] public string? Language { get; set; }
|
[MaxLength(128)] public string? Language { get; set; }
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ public class BotAccountController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{botId:guid}")]
|
[HttpPatch("{botId:guid}")]
|
||||||
public async Task<IActionResult> UpdateBot(
|
public async Task<IActionResult> UpdateBot(
|
||||||
[FromRoute] string pubName,
|
[FromRoute] string pubName,
|
||||||
[FromRoute] Guid projectId,
|
[FromRoute] Guid projectId,
|
||||||
@@ -234,15 +234,16 @@ public class BotAccountController(
|
|||||||
if (request.Location is not null) botAccount.Profile.Location = request.Location;
|
if (request.Location is not null) botAccount.Profile.Location = request.Location;
|
||||||
if (request.Birthday is not null) botAccount.Profile.Birthday = request.Birthday?.ToTimestamp();
|
if (request.Birthday is not null) botAccount.Profile.Birthday = request.Birthday?.ToTimestamp();
|
||||||
|
|
||||||
|
if (request.Slug is not null) bot.Slug = request.Slug;
|
||||||
|
if (request.IsActive is not null) bot.IsActive = request.IsActive.Value;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var updatedBot = await botService.UpdateBotAsync(
|
var updatedBot = await botService.UpdateBotAsync(
|
||||||
bot,
|
bot,
|
||||||
botAccount,
|
botAccount,
|
||||||
request.PictureId,
|
request.PictureId,
|
||||||
request.BackgroundId,
|
request.BackgroundId
|
||||||
request.Slug,
|
|
||||||
request.IsActive
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return Ok(updatedBot);
|
return Ok(updatedBot);
|
||||||
|
@@ -89,29 +89,16 @@ public class BotAccountService(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<BotAccount> UpdateBotAsync(BotAccount bot,
|
public async Task<BotAccount> UpdateBotAsync(
|
||||||
|
BotAccount bot,
|
||||||
Account account,
|
Account account,
|
||||||
string? pictureId,
|
string? pictureId,
|
||||||
string? backgroundId,
|
string? backgroundId
|
||||||
string? slug = null,
|
|
||||||
bool? isActive = null
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var updated = false;
|
db.Update(bot);
|
||||||
if (slug != null && bot.Slug != slug)
|
await db.SaveChangesAsync();
|
||||||
{
|
|
||||||
bot.Slug = slug;
|
|
||||||
updated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isActive.HasValue && bot.IsActive != isActive.Value)
|
|
||||||
{
|
|
||||||
bot.IsActive = isActive.Value;
|
|
||||||
updated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!updated) return bot;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Update the bot account in the Pass service
|
// Update the bot account in the Pass service
|
||||||
|
Reference in New Issue
Block a user