7.3 KiB
7.3 KiB
Decisions
One line per decision, with the reason.
Target and build
- Target Jellyfin 10.11.11 (
Jellyfin.Controller/Jellyfin.Model10.11.11,net9.0): it is the last 10.11 release on NuGet; the nuspec of that package listsnet9.0as its only framework. Versions live inDirectory.Build.props. targetAbiis10.11.0.0: the plugin only uses APIs that exist across 10.11, so it should not be pinned to the patch release it was compiled against.- Removed the template's
.githubworkflows and Renovate preset: they call reusable workflows and secrets of the Jellyfin organisation and cannot run elsewhere. Replaced by one self-contained workflow for Gitea Actions in.gitea/workflows; it talks to the Gitea API withcurl, so it needs no forge-specific CLI on the runner. - Releases are driven by the version, not by hand-made tags: a push to
mainwhosebuild.yamlversion has nov<version>tag is tagged and released by the workflow. The plugin repository manifest is a release asset carried forward from release to release, so nothing has to be committed back by CI. - Removed the template's
.vscodefolder: it assumes a local checkout of the Jellyfin server and web client next to the repo. - No analyzer warnings are suppressed project-wide. The only suppressions are three
CA2100pragmas inStorage/where a command text is assigned from a constant string, which the analyzer cannot see through a helper. - The test project does not reference the StyleCop/
AllEnabledByDefaultanalyzer set: XML docs and naming rules on test methods add noise without value. It still builds with warnings as errors.
Storage
- SQLite via
Microsoft.Data.Sqlite, not JSON files. Jellyfin 10.11.11 shipsMicrosoft.Data.Sqlite9.0.11 itself; the plugin references exactly that version withExcludeAssets="runtime;native", so no SQLite DLL (managed or native) ends up in the plugin folder and the host's copy is used. Verified in the 10.11.11 container: the plugin zip contains onlyJellyfin.Plugin.Herald.dll, and the database is created and migrated on first use. - Database path is
<data dir>/herald/herald.db(IApplicationPaths.DataPath), notBasePlugin.DataFolderPath: the latter resolves to a folder insideplugins/whose name can include the plugin version, so data would be left behind on every update. - Writes go through one lock and one transaction each; the file runs in WAL mode so reads are not blocked. Schema changes are numbered scripts tracked in
PRAGMA user_version. - A database newer than the plugin (downgrade) fails loudly instead of being opened.
Notices
Targetis an object{ AllUsers, UserIds }: clearer than "empty list means everyone", which would turn a notice for one deleted user into a notice for all.- Editing a notice does not show it again. Only "Re-show to everyone" bumps
Revision: fixing a typo should not interrupt everybody. - The first response of a user to a revision is kept; later ones for the same revision are ignored. This keeps the record of what the user actually did.
Ackwith an outdated revision returns409, for a missing, disabled or not-addressed notice404, andDismissedon a must-accept notice400.- The acknowledgement report covers the current revision only. Older rounds stay in the database but are not exposed; nobody asked for history.
- The pending-users list in the report only contains users that still exist. Responses of deleted users are kept and shown without a name.
GET /Herald/Notices/Pendingwith an API key (no user) returns an empty list rather than an error.- Body format is the Markdown subset from the task (bold, italic, links, lists) rendered in the browser with DOM nodes; the server stores the text as typed. Links are limited to
http,httpsandmailto. - Notice titles and ids are logged. Bodies and user names are not.
Client injection
- Registration with File Transformation is done purely by reflection, including building the payload: the
JObjectis created by callingParseon the parameter type ofRegisterTransformation, so the plugin has no Newtonsoft reference of its own. - The file pattern is the literal
index.html, the same string every other plugin registers. File Transformation groups callbacks by pattern string and, for a request, runs only the group whose key equals the requested path; a regex fallback is used only when no key matches exactly. The earlier anchored^index\.html$was therefore never called once MediaBar (or any plugin usingindex.html) was installed. Found by reproducing a server with MediaBar and Jellyfin Enhanced. - As a regular expression
index.htmlalso matches script chunks such assession-login-index-html.<hash>.chunk.js, so those are handed to the callback too. The transformer returns anything that is not an HTML page (<htmland</body>present) unchanged. - The script tag uses the relative URL
../Herald/client.jsso it keeps working behind a base URL. GET /Herald/client.jsis anonymous: a<script>tag cannot send Jellyfin's auth header, and the file holds nothing secret.- Jellyfin 10.11 has no "Custom HTML" setting (branding only offers custom CSS, a login disclaimer and the splash screen; checked against
BrandingOptions). The documented manual fallbacks are therefore the JavaScript Injector plugin and editingindex.html. - Login and user switches are detected by comparing
ApiClient.getCurrentUserId()on a 3 s local timer. That costs no request; the server is only asked after a change of user and then at most every 10 minutes. jellyfin-web's own login events are not reachable from an injected script in a stable way. - The modal reuses jellyfin-web's
dialog,raised,button-submitandemby-buttonclasses so the active theme colours it; own CSS only handles layout.
Admin UI
- The config page is flagged
EnableInMainMenu, so it has its own entry in the dashboard sidebar under "Plugins". Jellyfin 10.11 draws a fixed icon there;MenuIconis set for versions that honour it.
Watch-time stats
- Time is measured on the server clock between two reports of the same playback, not from playback positions: a seek changes the position by minutes without anyone watching, and position deltas also break with playback speed.
- Each delta is capped at 60 s; a playback without a report for 5 minutes counts as closed and the gap adds nothing.
- Progress events flagged
IsAutomatedare ignored. The server generates those itself on a timer while a client is silent, so they say nothing about someone still watching. - A playback is keyed by session id plus item id. Switching items without a stop report simply lets the old entry time out.
PlayCountcounts playback start events. A progress report for an unknown playback (server restarted mid-film) is tracked but not counted as a play.- A delta that crosses local midnight is split between both days.
- Stats for deleted users stay until they age out and are returned with
UserName: null. GET /Herald/StatsreturnsWatchedSecondsnext to the requested hours: rounded hours are useless for short sessions.- No chart. A hairline under the 30-day value shows each user's share of the busiest user's time; that is all the table needs.
- The cleanup task is discovered by Jellyfin as an
IScheduledTask(daily at 03:30) and is not registered in DI, which is how Jellyfin 10.11 finds tasks.