Replaces the plugin template with a working plugin that lets several users share one viewing account while keeping their individual watched lists accurate. Three pieces: - Auto-creating groups. Logging in as "alice+bob" with any named member's own password provisions the shared account and signs you in. Verified against 10.11.5: AuthenticateUser offers unmatched usernames to every enabled provider and re-queries afterwards, which is the hook this relies on. Gated on a real member password so knowing two usernames is not enough to create an account. - Multi-password authentication. IRequiresResolvedUser hands us the resolved shared account; each member's live stored hash is checked via ICryptoProvider.Verify. Deliberately avoids re-entering UserManager.AuthenticateUser, which would trip every member's failed-attempt counter whenever a different member's password matched. - One-way played-state sync. Shared account to members only, filtered to PlaybackFinished/TogglePlayed/Import so playback progress ticks are ignored. No loop guard needed: member writes carry a non-shared id. Membership is stored as user IDs rather than re-parsed from the username, so shared accounts can be renamed freely. The +/name collision resolves itself because Jellyfin only consults the plugin when no local user matches the typed name. Targets Jellyfin 10.11.x / net9.0. Adds Gitea CI (test, build, release), a builder image, and 34 tests covering the auth and sync rules.
51 lines
2.2 KiB
C#
51 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Jellyfin.Plugin.WatchedTogether.Configuration;
|
|
|
|
namespace Jellyfin.Plugin.WatchedTogether.Services;
|
|
|
|
/// <summary>
|
|
/// Creates, updates and removes shared accounts and their groups.
|
|
/// </summary>
|
|
public interface IProvisioningService
|
|
{
|
|
/// <summary>
|
|
/// Creates a shared account for the given members and records the group.
|
|
/// </summary>
|
|
/// <param name="memberIds">The members whose passwords will unlock the account. At least two.</param>
|
|
/// <param name="name">An explicit account name, or <c>null</c> to generate one from the member names.</param>
|
|
/// <param name="enableAllFolders">Whether the shared account may access all libraries.</param>
|
|
/// <param name="enabledFolders">Explicit library identifiers, used when <paramref name="enableAllFolders"/> is false.</param>
|
|
/// <returns>The created group.</returns>
|
|
Task<SharedGroup> CreateGroupAsync(
|
|
IReadOnlyList<Guid> memberIds,
|
|
string? name,
|
|
bool enableAllFolders,
|
|
IReadOnlyList<Guid>? enabledFolders);
|
|
|
|
/// <summary>
|
|
/// Replaces the membership and options of an existing group.
|
|
/// </summary>
|
|
/// <param name="sharedUserId">The shared account identifying the group.</param>
|
|
/// <param name="memberIds">The new member list. At least two.</param>
|
|
/// <param name="syncUnwatched">Whether unwatched state propagates too.</param>
|
|
/// <param name="syncPlayCount">Whether play counts are raised on watch.</param>
|
|
/// <param name="isDisabled">Whether the group is suspended.</param>
|
|
/// <returns>The updated group.</returns>
|
|
Task<SharedGroup> UpdateGroupAsync(
|
|
Guid sharedUserId,
|
|
IReadOnlyList<Guid> memberIds,
|
|
bool syncUnwatched,
|
|
bool syncPlayCount,
|
|
bool isDisabled);
|
|
|
|
/// <summary>
|
|
/// Removes a group, optionally deleting its shared account.
|
|
/// </summary>
|
|
/// <param name="sharedUserId">The shared account identifying the group.</param>
|
|
/// <param name="deleteSharedUser">Whether to delete the shared Jellyfin account as well.</param>
|
|
/// <returns>A task representing the removal.</returns>
|
|
Task DeleteGroupAsync(Guid sharedUserId, bool deleteSharedUser);
|
|
}
|