Remove doc required

This commit is contained in:
2025-10-28 17:55:41 +07:00
parent da908d7da2
commit 1181a0920a
2 changed files with 38 additions and 35 deletions

View File

@@ -105,7 +105,7 @@ public class TradingController : BaseController
public async Task<ActionResult<Position>> ClosePosition(Guid identifier) public async Task<ActionResult<Position>> ClosePosition(Guid identifier)
{ {
var position = await _tradingService.GetPositionByIdentifierAsync(identifier); var position = await _tradingService.GetPositionByIdentifierAsync(identifier);
var result = await _closeTradeCommandHandler.Handle(new ClosePositionCommand(position, position.AccountId)); var result = await _closeTradeCommandHandler.Handle(new ClosePositionCommand(position, position.AccountId));
return Ok(result); return Ok(result);
} }
@@ -190,7 +190,8 @@ public class TradingController : BaseController
// Check if user has permission to initialize this address // Check if user has permission to initialize this address
if (!await CanUserInitializeAddress(user.Name, publicAddress)) if (!await CanUserInitializeAddress(user.Name, publicAddress))
{ {
return Forbid("You don't have permission to initialize this wallet address. You can only initialize your own wallet addresses."); return Forbid(
"You don't have permission to initialize this wallet address. You can only initialize your own wallet addresses.");
} }
var result = await _tradingService.InitPrivyWallet(publicAddress, TradingExchanges.GmxV2); var result = await _tradingService.InitPrivyWallet(publicAddress, TradingExchanges.GmxV2);
@@ -228,19 +229,22 @@ public class TradingController : BaseController
// Regular users can only initialize their own addresses // Regular users can only initialize their own addresses
// Check if the address belongs to one of the user's accounts // Check if the address belongs to one of the user's accounts
var account = await _accountService.GetAccountByKey(publicAddress, true, false); var account = await _accountService.GetAccountByKey(publicAddress, true, false);
if (account?.User?.Name == userName) if (account?.User?.Name == userName)
{ {
_logger.LogInformation("User {UserName} initializing their own address {Address}", userName, publicAddress); _logger.LogInformation("User {UserName} initializing their own address {Address}", userName,
publicAddress);
return true; return true;
} }
_logger.LogWarning("User {UserName} attempted to initialize address {Address} that doesn't belong to them", userName, publicAddress); _logger.LogWarning("User {UserName} attempted to initialize address {Address} that doesn't belong to them",
userName, publicAddress);
return false; return false;
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogWarning(ex, "Unable to verify ownership of address {Address} for user {UserName}", publicAddress, userName); _logger.LogWarning(ex, "Unable to verify ownership of address {Address} for user {UserName}", publicAddress,
userName);
return false; return false;
} }
} }
@@ -268,11 +272,6 @@ public class TradingController : BaseController
return BadRequest("Strategy is required."); return BadRequest("Strategy is required.");
} }
if (string.IsNullOrWhiteSpace(request.DocumentationUrl))
{
return BadRequest("Documentation URL is required.");
}
if (string.IsNullOrWhiteSpace(request.RequesterName)) if (string.IsNullOrWhiteSpace(request.RequesterName))
{ {
return BadRequest("Requester name is required."); return BadRequest("Requester name is required.");
@@ -281,7 +280,7 @@ public class TradingController : BaseController
try try
{ {
var webhookUrl = _configuration["N8n:IndicatorRequestWebhookUrl"]; var webhookUrl = _configuration["N8n:IndicatorRequestWebhookUrl"];
if (string.IsNullOrEmpty(webhookUrl)) if (string.IsNullOrEmpty(webhookUrl))
{ {
_logger.LogError("N8n indicator request webhook URL is not configured"); _logger.LogError("N8n indicator request webhook URL is not configured");
@@ -289,26 +288,26 @@ public class TradingController : BaseController
} }
var httpClient = _httpClientFactory.CreateClient(); var httpClient = _httpClientFactory.CreateClient();
_logger.LogInformation( _logger.LogInformation(
"Submitting indicator request: {IndicatorName} - {Strategy} by {Requester}", "Submitting indicator request: {IndicatorName} - {Strategy} by {Requester}",
request.IndicatorName, request.IndicatorName,
request.StrategyDescription, request.StrategyDescription,
request.RequesterName); request.RequesterName);
// Send as JSON payload // Send as JSON payload
var response = await httpClient.PostAsJsonAsync(webhookUrl, request); var response = await httpClient.PostAsJsonAsync(webhookUrl, request);
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
_logger.LogInformation( _logger.LogInformation(
"Successfully submitted indicator request: {IndicatorName} by {Requester}", "Successfully submitted indicator request: {IndicatorName} by {Requester}",
request.IndicatorName, request.IndicatorName,
request.RequesterName); request.RequesterName);
return Ok(new return Ok(new
{ {
Success = true, Success = true,
Message = "Indicator request submitted successfully.", Message = "Indicator request submitted successfully.",
IndicatorName = request.IndicatorName, IndicatorName = request.IndicatorName,
Strategy = request.StrategyDescription, Strategy = request.StrategyDescription,
@@ -322,21 +321,21 @@ public class TradingController : BaseController
"Failed to submit indicator request. Status: {StatusCode}, Response: {Response}", "Failed to submit indicator request. Status: {StatusCode}, Response: {Response}",
response.StatusCode, response.StatusCode,
responseContent); responseContent);
return StatusCode(500, new return StatusCode(500, new
{ {
Success = false, Success = false,
Error = $"Failed to submit indicator request. Status: {response.StatusCode}" Error = $"Failed to submit indicator request. Status: {response.StatusCode}"
}); });
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error submitting indicator request: {IndicatorName}", request.IndicatorName); _logger.LogError(ex, "Error submitting indicator request: {IndicatorName}", request.IndicatorName);
return StatusCode(500, new return StatusCode(500, new
{ {
Success = false, Success = false,
Error = "An error occurred while submitting the indicator request." Error = "An error occurred while submitting the indicator request."
}); });
} }
} }

View File

@@ -1,5 +1,7 @@
#nullable enable #nullable enable
using System.ComponentModel.DataAnnotations;
namespace Managing.Api.Models.Requests; namespace Managing.Api.Models.Requests;
/// <summary> /// <summary>
@@ -10,17 +12,19 @@ public class IndicatorRequestDto
/// <summary> /// <summary>
/// Name of the indicator (e.g., "MACD", "RSI", "Bollinger Bands") /// Name of the indicator (e.g., "MACD", "RSI", "Bollinger Bands")
/// </summary> /// </summary>
public string IndicatorName { get; set; } = string.Empty; [Required]
public string IndicatorName { get; set; }
/// <summary> /// <summary>
/// Strategy or description of how the indicator is used (e.g., "MACD Cross", "RSI Divergence") /// Strategy or description of how the indicator is used (e.g., "MACD Cross", "RSI Divergence")
/// </summary> /// </summary>
[Required]
public string StrategyDescription { get; set; } = string.Empty; public string StrategyDescription { get; set; } = string.Empty;
/// <summary> /// <summary>
/// Primary documentation URL for the indicator /// Primary documentation URL for the indicator
/// </summary> /// </summary>
public string DocumentationUrl { get; set; } = string.Empty; public string? DocumentationUrl { get; set; }
/// <summary> /// <summary>
/// Image URL for the indicator (optional) - can be a chart, diagram, or visual representation /// Image URL for the indicator (optional) - can be a chart, diagram, or visual representation
@@ -30,6 +34,6 @@ public class IndicatorRequestDto
/// <summary> /// <summary>
/// Name of the person requesting the indicator /// Name of the person requesting the indicator
/// </summary> /// </summary>
[Required]
public string RequesterName { get; set; } = string.Empty; public string RequesterName { get; set; } = string.Empty;
} }