private (string ClientName, string ClientVersion) GetRequestInformation() { var clientName = ClaimHelpers.GetClient(HttpContext.User) ?? "unknown-client"; var clientVersion = ClaimHelpers.GetIsApiKey(HttpContext.User) ? "apikey" : ClaimHelpers.GetVersion(HttpContext.User) ?? "unknown-version"; return(clientName, clientVersion); }
/// <summary> /// Add additional fields depending on client. /// </summary> /// <remarks> /// Use in place of GetDtoOptions. /// Legacy order: 2. /// </remarks> /// <param name="dtoOptions">DtoOptions object.</param> /// <param name="request">Current request.</param> /// <returns>Modified DtoOptions object.</returns> internal static DtoOptions AddClientFields( this DtoOptions dtoOptions, HttpRequest request) { dtoOptions.Fields ??= Array.Empty <ItemFields>(); string?client = ClaimHelpers.GetClient(request.HttpContext.User); // No client in claim if (string.IsNullOrEmpty(client)) { return(dtoOptions); } if (!dtoOptions.ContainsField(ItemFields.RecursiveItemCount)) { if (client.IndexOf("kodi", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("wmc", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("media center", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("classic", StringComparison.OrdinalIgnoreCase) != -1) { int oldLen = dtoOptions.Fields.Count; var arr = new ItemFields[oldLen + 1]; dtoOptions.Fields.CopyTo(arr, 0); arr[oldLen] = ItemFields.RecursiveItemCount; dtoOptions.Fields = arr; } } if (!dtoOptions.ContainsField(ItemFields.ChildCount)) { if (client.IndexOf("kodi", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("wmc", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("media center", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("classic", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("roku", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("samsung", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("androidtv", StringComparison.OrdinalIgnoreCase) != -1) { int oldLen = dtoOptions.Fields.Count; var arr = new ItemFields[oldLen + 1]; dtoOptions.Fields.CopyTo(arr, 0); arr[oldLen] = ItemFields.ChildCount; dtoOptions.Fields = arr; } } return(dtoOptions); }