in src/governance/client/Controllers/UpdatesController.cs [20:61]
public async Task<CheckUpdateResponse> CheckUpdates()
{
var ccfClient = await this.CcfClientManager.GetGovClient();
using HttpResponseMessage response =
await ccfClient.GetAsync($"gov/members/proposals" +
$"?api-version={this.CcfClientManager.GetGovApiVersion()}");
await response.ValidateStatusCodeAsync(this.Logger);
var proposals = await response.Content.ReadFromJsonAsync<ListProposalResponse>();
List<ListProposalResponse.Proposal> possibleUpdates = new();
if (proposals?.Value != null && proposals.Value.Any())
{
possibleUpdates = proposals.Value.Where(p => p.ProposalState == "Open").ToList();
}
var result = new CheckUpdateResponse { Proposals = new() };
foreach (var proposal in possibleUpdates)
{
using HttpResponseMessage response2 =
await ccfClient.GetAsync($"gov/members/proposals/{proposal.ProposalId}/actions" +
$"?api-version={this.CcfClientManager.GetGovApiVersion()}");
await response2.ValidateStatusCodeAsync(this.Logger);
var actions = await response2.Content.ReadFromJsonAsync<ActionsResponse>();
if (actions?.Actions != null)
{
var updateAction = actions.Actions.Find(a =>
a.Name == "set_constitution" ||
a.Name == "set_js_app" ||
a.Name == "add_snp_host_data" ||
a.Name == "remove_snp_host_data");
if (updateAction != null)
{
result.Proposals.Add(new()
{
ProposalId = proposal.ProposalId,
ActionName = updateAction.Name
});
}
}
}
return result;
}