Skip to content

Commit

Permalink
Jellyfin 10.10 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
shemanaev committed Dec 17, 2024
1 parent 95ea08b commit 773305c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 30 deletions.
11 changes: 11 additions & 0 deletions Jellyfin.Webhooks/Dto/SessionInfoDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ public class SessionInfoDto
public string ApplicationVersion { get; set; }
public PlayerStateInfo PlayState { get; set; }

public SessionInfoDto(MediaBrowser.Model.Dto.SessionInfoDto session)
{
Id = session.Id;
Client = session.Client;
DeviceId = session.DeviceId;
DeviceName = session.DeviceName;
RemoteEndPoint = session.RemoteEndPoint;
ApplicationVersion = session.ApplicationVersion;
PlayState = session.PlayState;
}

public SessionInfoDto(SessionInfo session)
{
Id = session.Id;
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Webhooks/Formats/DefaultFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class DefaultFormatPayload
public HookEvent Event { get; set; }
public BaseItemDto Item { get; set; }
public UserDto User { get; set; }
public SessionInfoDto Session { get; set; }
public Dto.SessionInfoDto Session { get; set; }
public ServerInfoDto Server { get; set; }
public object AdditionalData { get; set; }
public BaseItemDto Series { get; set; }
Expand Down
16 changes: 8 additions & 8 deletions Jellyfin.Webhooks/Jellyfin.Webhooks.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Jellyfin.Webhooks</RootNamespace>
<AssemblyVersion>3.7.0.0</AssemblyVersion>
<FileVersion>3.7.0.0</FileVersion>
<AssemblyVersion>3.8.0.0</AssemblyVersion>
<FileVersion>3.8.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.9.0" />
<PackageReference Include="Jellyfin.Data" Version="10.9.0" />
<PackageReference Include="Jellyfin.Model" Version="10.9.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Jellyfin.Controller" Version="10.10.3" />
<PackageReference Include="Jellyfin.Data" Version="10.10.3" />
<PackageReference Include="Jellyfin.Model" Version="10.10.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

Expand Down
11 changes: 5 additions & 6 deletions Jellyfin.Webhooks/Notifiers/AuthenticationFailureNotifier.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
using System.Threading.Tasks;
using Jellyfin.Data.Events;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Session;
using MediaBrowser.Controller;
using Jellyfin.Webhooks.Configuration;
using Jellyfin.Webhooks.Dto;
using MediaBrowser.Controller.Events.Authentication;

namespace Jellyfin.Webhooks.Notifiers;

public class AuthenticationFailureNotifier(
IServerApplicationHost applicationHost,
ISender sender
) : IEventConsumer<GenericEventArgs<AuthenticationRequest>>
) : IEventConsumer<AuthenticationRequestEventArgs>
{
public async Task OnEvent(GenericEventArgs<AuthenticationRequest> eventArgs)
public async Task OnEvent(AuthenticationRequestEventArgs eventArgs)
{
if (eventArgs.Argument is null)
if (eventArgs is null)
{
return;
}

await sender.Send(new EventInfo
{
Event = HookEvent.AuthenticationFailed,
AdditionalData = eventArgs.Argument,
AdditionalData = eventArgs,
Server = new ServerInfoDto
{
Id = applicationHost.SystemId,
Expand Down
13 changes: 6 additions & 7 deletions Jellyfin.Webhooks/Notifiers/AuthenticationSuccessNotifier.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
using System.Threading.Tasks;
using Jellyfin.Data.Events;
using Jellyfin.Webhooks.Configuration;
using Jellyfin.Webhooks.Dto;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Events.Authentication;

namespace Jellyfin.Webhooks.Notifiers;

public class AuthenticationSuccessNotifier(
IServerApplicationHost applicationHost,
IUserManager userManager,
ISender sender
) : IEventConsumer<GenericEventArgs<AuthenticationResult>>
) : IEventConsumer<AuthenticationResultEventArgs>
{
public async Task OnEvent(GenericEventArgs<AuthenticationResult> eventArgs)
public async Task OnEvent(AuthenticationResultEventArgs eventArgs)
{
if (eventArgs.Argument is null)
if (eventArgs is null)
{
return;
}

var user = userManager.GetUserById(eventArgs.Argument.User.Id);
var user = userManager.GetUserById(eventArgs.User.Id);
await sender.Send(new EventInfo
{
Event = HookEvent.AuthenticationSucceeded,
Session = new SessionInfoDto(eventArgs.Argument.SessionInfo),
Session = new SessionInfoDto(eventArgs.SessionInfo),
User = user,
Server = new ServerInfoDto
{
Expand Down
8 changes: 3 additions & 5 deletions Jellyfin.Webhooks/PluginServiceRegistrator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Jellyfin.Data.Events;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using Microsoft.Extensions.DependencyInjection;
using Jellyfin.Webhooks.Notifiers;
using MediaBrowser.Controller.Events.Authentication;

namespace Jellyfin.Webhooks;

Expand All @@ -17,7 +15,7 @@ public void RegisterServices(IServiceCollection serviceCollection, IServerApplic
serviceCollection.AddScoped<ISender, Sender>();

// Security consumers.
serviceCollection.AddScoped<IEventConsumer<GenericEventArgs<AuthenticationRequest>>, AuthenticationFailureNotifier>();
serviceCollection.AddScoped<IEventConsumer<GenericEventArgs<AuthenticationResult>>, AuthenticationSuccessNotifier>();
serviceCollection.AddScoped<IEventConsumer<AuthenticationRequestEventArgs>, AuthenticationFailureNotifier>();
serviceCollection.AddScoped<IEventConsumer<AuthenticationResultEventArgs>, AuthenticationSuccessNotifier>();
}
}
6 changes: 3 additions & 3 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: "Webhooks"
guid: "eb5d7894-8eef-4b36-aa6f-5d124e828ce1"
version: "3.7.0.0"
targetAbi: "10.9.0.0"
version: "3.8.0.0"
targetAbi: "10.10.3.0"
framework: "net8.0"
overview: "Webhooks. Flexible and robust"
description: >
Expand All @@ -12,4 +12,4 @@ owner: "shemanaev"
artifacts:
- "Jellyfin.Webhooks.dll"
changelog: >
Jellyfin 10.9 compatibility
Jellyfin 10.10 compatibility

0 comments on commit 773305c

Please sign in to comment.