Share Stats about OIDC use

This commit is contained in:
Amelia 2025-07-06 14:39:05 +02:00
parent d2e1ca9078
commit b6bfc65bc4
4 changed files with 15 additions and 2 deletions

View file

@ -131,6 +131,10 @@ public sealed record ServerInfoV3Dto
/// Is this server using Kavita+ /// Is this server using Kavita+
/// </summary> /// </summary>
public bool ActiveKavitaPlusSubscription { get; set; } public bool ActiveKavitaPlusSubscription { get; set; }
/// <summary>
/// Is OIDC enabled
/// </summary>
public bool OidcEnabled { get; set; }
#endregion #endregion
#region Users #region Users

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using API.Data.Misc; using API.Data.Misc;
using API.Entities.Enums;
using API.Entities.Enums.Device; using API.Entities.Enums.Device;
namespace API.DTOs.Stats.V3; namespace API.DTOs.Stats.V3;
@ -76,6 +77,10 @@ public sealed record UserStatV3
/// Roles for this user /// Roles for this user
/// </summary> /// </summary>
public ICollection<string> Roles { get; set; } public ICollection<string> Roles { get; set; }
/// <summary>
/// Who manages the user (OIDC, Kavita)
/// </summary>
public AppUserOwner Owner { get; set; }
} }

View file

@ -96,8 +96,9 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
/// </summary> /// </summary>
public string? ExternalId { get; set; } public string? ExternalId { get; set; }
/// <summary> /// <summary>
/// Describes how the account was created /// Describes who manages the account (may further depend on other settings)
/// </summary> /// </summary>
/// <remarks>Always fallbacks to native</remarks>
public AppUserOwner Owner { get; set; } = AppUserOwner.Native; public AppUserOwner Owner { get; set; } = AppUserOwner.Native;

View file

@ -248,7 +248,8 @@ public class StatsService : IStatsService
DotnetVersion = Environment.Version.ToString(), DotnetVersion = Environment.Version.ToString(),
OpdsEnabled = serverSettings.EnableOpds, OpdsEnabled = serverSettings.EnableOpds,
EncodeMediaAs = serverSettings.EncodeMediaAs, EncodeMediaAs = serverSettings.EncodeMediaAs,
MatchedMetadataEnabled = mediaSettings.Enabled MatchedMetadataEnabled = mediaSettings.Enabled,
OidcEnabled = !string.IsNullOrEmpty(serverSettings.OidcConfig.Authority),
}; };
dto.OsLocale = CultureInfo.CurrentCulture.EnglishName; dto.OsLocale = CultureInfo.CurrentCulture.EnglishName;
@ -353,7 +354,9 @@ public class StatsService : IStatsService
userDto.DevicePlatforms = user.Devices.Select(d => d.Platform).ToList(); userDto.DevicePlatforms = user.Devices.Select(d => d.Platform).ToList();
userDto.SeriesBookmarksCreatedCount = user.Bookmarks.Count; userDto.SeriesBookmarksCreatedCount = user.Bookmarks.Count;
userDto.SmartFilterCreatedCount = user.SmartFilters.Count; userDto.SmartFilterCreatedCount = user.SmartFilters.Count;
userDto.IsSharingReviews = user.UserPreferences.ShareReviews;
userDto.WantToReadSeriesCount = user.WantToRead.Count; userDto.WantToReadSeriesCount = user.WantToRead.Count;
userDto.Owner = user.Owner;
if (allLibraries.Count > 0 && userLibraryAccess.TryGetValue(user.Id, out var accessibleLibraries)) if (allLibraries.Count > 0 && userLibraryAccess.TryGetValue(user.Id, out var accessibleLibraries))
{ {