Skip to content

Commit

Permalink
Expose RemoteEndPoint & SessionInfo Variables (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragkrishna authored Sep 6, 2024
1 parent f4b40c6 commit eeb067a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public async Task OnEvent(AuthenticationRequestEventArgs eventArgs)
dataObject[nameof(eventArgs.AppVersion)] = eventArgs.AppVersion ?? string.Empty;
dataObject[nameof(eventArgs.DeviceId)] = eventArgs.DeviceId ?? string.Empty;
dataObject[nameof(eventArgs.DeviceName)] = eventArgs.DeviceName ?? string.Empty;
dataObject[nameof(eventArgs.RemoteEndPoint)] = eventArgs.RemoteEndPoint ?? string.Empty;

await _webhookSender.SendNotification(NotificationType.AuthenticationFailure, dataObject)
.ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ public AuthenticationSuccessNotifier(
/// <inheritdoc />
public async Task OnEvent(AuthenticationResultEventArgs eventArgs)
{
if (eventArgs is null)
if (eventArgs is null || eventArgs.User == null || eventArgs.SessionInfo == null)
{
return;
}

var dataObject = DataObjectHelpers
.GetBaseDataObject(_applicationHost, NotificationType.AuthenticationSuccess)
.AddUserData(eventArgs.User);
dataObject = dataObject.AddSessionInfoData(eventArgs.SessionInfo);

await _webhookSender.SendNotification(NotificationType.AuthenticationSuccess, dataObject)
.ConfigureAwait(false);
Expand Down
5 changes: 5 additions & 0 deletions Jellyfin.Plugin.Webhook/Notifiers/PlaybackProgressNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public async Task OnEvent(PlaybackProgressEventArgs eventArgs)
.AddBaseItemData(eventArgs.Item)
.AddPlaybackProgressData(eventArgs);

if (eventArgs.Session != null)
{
dataObject = dataObject.AddSessionInfoData(eventArgs.Session);
}

foreach (var user in eventArgs.Users)
{
var userDataObject = new Dictionary<string, object>(dataObject)
Expand Down
5 changes: 5 additions & 0 deletions Jellyfin.Plugin.Webhook/Notifiers/PlaybackStartNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public async Task OnEvent(PlaybackStartEventArgs eventArgs)
.AddBaseItemData(eventArgs.Item)
.AddPlaybackProgressData(eventArgs);

if (eventArgs.Session != null)
{
dataObject = dataObject.AddSessionInfoData(eventArgs.Session);
}

foreach (var user in eventArgs.Users)
{
var userDataObject = new Dictionary<string, object>(dataObject)
Expand Down
5 changes: 5 additions & 0 deletions Jellyfin.Plugin.Webhook/Notifiers/PlaybackStopNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public async Task OnEvent(PlaybackStopEventArgs eventArgs)
.AddPlaybackProgressData(eventArgs);
dataObject[nameof(eventArgs.PlayedToCompletion)] = eventArgs.PlayedToCompletion;

if (eventArgs.Session != null)
{
dataObject = dataObject.AddSessionInfoData(eventArgs.Session);
}

foreach (var user in eventArgs.Users)
{
var userDataObject = new Dictionary<string, object>(dataObject)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ See [Templates](Jellyfin.Plugin.Webhook/Templates) for sample templates.
- Playback client name
- Client
- Playback client name
- App
- client name in Authentication Failure
- RemoteEndPoint
- IP Address of client

Expand Down

0 comments on commit eeb067a

Please sign in to comment.