fixed ime function

This commit is contained in:
Oliver Kieselbach
2026-04-06 16:31:04 +02:00
parent 0525f9c78f
commit e709d568c0
2 changed files with 23 additions and 3 deletions
@@ -1 +1 @@
863
865
@@ -1,4 +1,5 @@
using System.Net;
using AutopilotMonitor.Functions.Helpers;
using AutopilotMonitor.Shared.DataAccess;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
@@ -9,7 +10,8 @@ namespace AutopilotMonitor.Functions.Functions.Metrics
/// <summary>
/// Returns all known IME agent versions with first/last seen dates and session counts.
/// Permanent archive that survives data retention — tracks Microsoft IME releases over time.
/// Access: MemberRead (any tenant member can see global IME version history).
/// Access: MemberRead (any tenant member can see version/dates/counts).
/// FirstSeenTenantId and FirstSeenSessionId are only visible to Global Admins.
/// </summary>
public class GetImeVersionHistoryFunction
{
@@ -28,10 +30,28 @@ namespace AutopilotMonitor.Functions.Functions.Metrics
{
try
{
var requestCtx = req.GetRequestContext();
var versions = await _sessionRepo.GetImeVersionHistoryAsync();
var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync(versions);
if (requestCtx.IsGlobalAdmin)
{
await response.WriteAsJsonAsync(versions);
}
else
{
// Strip sensitive cross-tenant data for non-Global Admins
var redacted = versions.Select(v => new
{
v.Version,
v.FirstSeenAt,
v.LastSeenAt,
v.SessionCount
});
await response.WriteAsJsonAsync(redacted);
}
return response;
}
catch (Exception ex)