Don't send the whole script result back from the API.

This commit is contained in:
Jared Goodwin 2023-07-26 12:52:15 -07:00
parent 95ebedf89e
commit e70d083a3f
3 changed files with 21 additions and 7 deletions

View File

@ -48,7 +48,7 @@ public class ScriptExecutor : IScriptExecutor
result.InputType = ScriptInputType.Api;
result.SenderUserName = senderUsername;
await SendResultsToApi(result, authToken);
_ = await SendResultsToApi(result, authToken);
await hubConnection.SendAsync("ScriptResultViaApi", requestID);
}
catch (Exception ex)
@ -78,7 +78,7 @@ public class ScriptExecutor : IScriptExecutor
{
return;
}
await hubConnection.SendAsync("ScriptResult", responseResult.ID);
await hubConnection.SendAsync("ScriptResult", responseResult.Id);
}
catch (Exception ex)
{
@ -143,7 +143,7 @@ public class ScriptExecutor : IScriptExecutor
result.InputType = scriptInputType;
result.SavedScriptId = savedScriptId;
var responseResult = await SendResultsToApi(result, expiringToken);
_ = await SendResultsToApi(result, expiringToken);
}
catch (Exception ex)
{
@ -196,7 +196,7 @@ public class ScriptExecutor : IScriptExecutor
}
throw new InvalidOperationException($"Unknown shell type: {shell}");
}
private async Task<ScriptResult?> SendResultsToApi(object result, string expiringToken)
private async Task<ScriptResultResponse?> SendResultsToApi(object result, string expiringToken)
{
var targetURL = _configService.GetConnectionInfo().Host + $"/API/ScriptResults";
@ -212,6 +212,6 @@ public class ScriptExecutor : IScriptExecutor
}
var content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<ScriptResult>(content, JsonSerializerHelper.CaseInsensitiveOptions);
return JsonSerializer.Deserialize<ScriptResultResponse>(content, JsonSerializerHelper.CaseInsensitiveOptions);
}
}

View File

@ -54,7 +54,7 @@ public class ScriptResultsController : ControllerBase
[HttpPost]
[ServiceFilter(typeof(ExpiringTokenFilter))]
public async Task<ActionResult<ScriptResult>> Post([FromBody] ScriptResult result)
public async Task<ActionResult<ScriptResultResponse>> Post([FromBody] ScriptResult result)
{
_dataService.AddOrUpdateScriptResult(result);
@ -111,6 +111,9 @@ public class ScriptResultsController : ControllerBase
await _dataService.AddScriptResultToScriptRun(result.ID, result.ScriptRunId.Value);
}
return result;
return new ScriptResultResponse()
{
Id = result.ID
};
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Remotely.Shared.Models;
public class ScriptResultResponse
{
public required string Id { get; init; }
}