Files
dtourolle 7be07d16a2
🏗️ Build Plugin / build (push) Has been cancelled
🧪 Test Plugin / test (push) Has been cancelled
Implement Watched Together shared viewing accounts
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.
2026-07-29 00:00:13 +02:00

50 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Jellyfin.Plugin.WatchedTogether.Configuration;
/// <summary>
/// The association between one shared account and the members who may unlock it.
/// </summary>
/// <remarks>
/// Membership is stored as GUIDs rather than being parsed out of the shared account's username.
/// The default separator ('+') is itself a legal username character, so a name like "alice+bob"
/// is ambiguous between the group [alice, bob] and a single user literally called "alice+bob".
/// GUIDs remove that ambiguity and support any number of members.
/// </remarks>
public class SharedGroup
{
/// <summary>
/// Gets or sets the identifier of the shared account that members log into collectively.
/// </summary>
public Guid SharedUserId { get; set; }
/// <summary>
/// Gets or sets the identifiers of the members whose passwords unlock the shared account,
/// and whose own accounts receive its watched state. A usable group has at least two.
/// </summary>
[SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Plugin configuration is round-tripped by the XML serializer, which requires a settable List<T>.")]
[SuppressMessage("Design", "CA1002:Do not expose generic lists", Justification = "Plugin configuration is round-tripped by the XML serializer, which requires a settable List<T>.")]
public List<Guid> MemberUserIds { get; set; } = new();
/// <summary>
/// Gets or sets a value indicating whether marking something unwatched on the shared account
/// also marks it unwatched for every member. When false, only the transition to watched
/// propagates.
/// </summary>
public bool SyncUnwatched { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether a member's play count is raised to at least one
/// when an item becomes watched. Play counts are never decremented.
/// </summary>
public bool SyncPlayCount { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this group is suspended. A group drops out of both
/// authentication and sync while disabled - set automatically if it falls below two members.
/// </summary>
public bool IsDisabled { get; set; }
}