public static async Task OnGETRequest(Microsoft.AspNetCore.Http.HttpContext e, DbServer s, DbUser u) { //Get cluster, if any DbCluster cluster = null; if (s.cluster_id != null) { cluster = await DbCluster.GetClusterById(Program.connection, MongoDB.Bson.ObjectId.Parse(s.cluster_id)); } //Get map entry string mapName = null; var mapEntry = await Program.connection.GetARKMapByInternalName(s.latest_server_map); if (mapEntry != null) { mapName = mapEntry.displayName; } //Get server status string status = "ONLINE"; string message = "Online"; if (s.CheckLockFlag(1)) { status = "ALERT"; message = "Locked"; } if (s.CheckLockFlag(0)) { status = "ALERT"; message = "Still Initializing..."; } if (s.CheckLockFlag(2)) { status = "OFFLINE"; message = "Locked by Admin"; } if (mapEntry == null) { status = "OFFLINE"; message = "Incompatible Map"; } //Check last connect time DateTime lastConnectTime = new DateTime(s.last_client_connect_time); if ((DateTime.UtcNow - lastConnectTime).TotalMinutes > 2.5f) { status = "OFFLINE"; message = $"Offline Since {lastConnectTime.ToShortDateString()}"; } //Look up all mods used and convert Dictionary <string, DbSteamModCache> mods = await s.GetAllServerMods(Program.connection, true); List <WebArkMod> modList = new List <WebArkMod>(); foreach (var mod in mods.Values) { if (mod == null) { modList.Add(null); } else { modList.Add(mod.GetWebVersion()); } } //Look up all admins List <ManagementData_User> admins = new List <ManagementData_User>(); admins.Add(await ManagementData_User.GetUser(u)); foreach (var id in s.admins) { admins.Add(await ManagementData_User.GetUser(await DbUser.GetUserByID(Program.connection, id))); } ManagementDataResponse m = new ManagementDataResponse { name = s.display_name, icon = s.image_url, is_user_locked = s.CheckLockFlag(1), permissions = s.GetPermissionFlagList(), settings = s.game_settings, cluster_id = s.cluster_id, cluster = cluster, status = status, alert = message, mods = modList, admins = admins, map_id = s.latest_server_map, map_name = mapName }; await Program.QuickWriteJsonToDoc(e, m); }