Merge pull request #57 from jellyfin/bot-username

Update Username parameter to be NotificationUsername
This commit is contained in:
Cody Robibero 2021-09-13 18:16:21 -06:00 committed by GitHub
commit f21ee45828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 14 deletions

View File

@ -64,6 +64,7 @@ namespace Jellyfin.Plugin.Webhook.Destinations.Discord
if (!string.IsNullOrEmpty(options.Username))
{
data["Username"] = options.Username;
data["BotUsername"] = options.Username;
}
var body = options.GetMessageBody(data);

View File

@ -49,6 +49,7 @@ namespace Jellyfin.Plugin.Webhook.Destinations.Slack
}
data["SlackUsername"] = options.Username;
data["BotUsername"] = options.Username;
data["SlackIconUrl"] = options.IconUrl;
var body = options.GetMessageBody(data);

View File

@ -248,7 +248,7 @@ namespace Jellyfin.Plugin.Webhook.Helpers
/// <returns>The modified data object.</returns>
public static Dictionary<string, object> AddUserData(this Dictionary<string, object> dataObject, UserDto user)
{
dataObject["Username"] = user.Name.Escape();
dataObject["NotificationUsername"] = user.Name.Escape();
dataObject["UserId"] = user.Id;
dataObject[nameof(user.LastLoginDate)] = user.LastLoginDate ?? DateTime.UtcNow;
dataObject[nameof(user.LastActivityDate)] = user.LastActivityDate ?? DateTime.MinValue;
@ -264,7 +264,7 @@ namespace Jellyfin.Plugin.Webhook.Helpers
/// <returns>The modified data object.</returns>
public static Dictionary<string, object> AddUserData(this Dictionary<string, object> dataObject, User user)
{
dataObject["Username"] = user.Username.Escape();
dataObject["NotificationUsername"] = user.Username.Escape();
dataObject["UserId"] = user.Id;
dataObject[nameof(user.LastLoginDate)] = user.LastLoginDate ?? DateTime.UtcNow;
dataObject[nameof(user.LastActivityDate)] = user.LastActivityDate ?? DateTime.MinValue;
@ -282,7 +282,7 @@ namespace Jellyfin.Plugin.Webhook.Helpers
{
dataObject[nameof(sessionInfo.Id)] = sessionInfo.Id;
dataObject[nameof(sessionInfo.UserId)] = sessionInfo.UserId;
dataObject[nameof(sessionInfo.UserName)] = sessionInfo.UserName.Escape();
dataObject["NotificationUsername"] = sessionInfo.UserName.Escape();
dataObject[nameof(sessionInfo.Client)] = sessionInfo.Client.Escape();
dataObject[nameof(sessionInfo.LastActivityDate)] = sessionInfo.LastActivityDate;
dataObject[nameof(sessionInfo.LastPlaybackCheckIn)] = sessionInfo.LastPlaybackCheckIn;

View File

@ -1,7 +1,7 @@
{
"content": "{{MentionType}}",
"avatar_url": "{{AvatarUrl}}",
"username": "{{{Username}}}",
"username": "{{{BotUsername}}}",
"embeds": [
{
"color": "{{EmbedColor}}",
@ -58,4 +58,4 @@
[Jellyfin]({{ServerUrl}}/web/index.html#!/details?id={{ItemId}}&serverId={{ServerId}})"
}
]
}
}

View File

@ -6,4 +6,4 @@
"Url": "{{Url}}",
"Username": "{{{Username}}}",
"UserId": "{{UserId}}"
}
}

View File

@ -41,4 +41,4 @@
"title": "{{{Name}}} ({{Year}}) has been added to {{{ServerName}}}"
{{/if_equals}}
{{/if_equals}}
}
}

View File

@ -17,4 +17,4 @@
"body": "{{{Name}}} ({{Year}}) has been added to {{{ServerName}}}"
{{/if_equals}}
{{/if_equals}}
}
}

View File

@ -16,4 +16,4 @@
"message": "{{{Name}}} ({{Year}}) has been added to {{{ServerName}}}"
{{/if_equals}}
{{/if_equals}}
}
}

View File

@ -1,6 +1,6 @@
{
{{#if_exist SlackUsername}}
"username": "{{SlackUsername}}",
"username": "{{BotUsername}}",
{{/if_exist}}
{{#if_exist SlackIconUrl}}
"icon_url": "{{SlackIconUrl}}",
@ -14,4 +14,4 @@
"text": "{{{Name}}} ({{Year}}) has been added to {{{ServerName}}}",
{{/if_equals}}
{{/if_equals}}
}
}

View File

@ -96,7 +96,7 @@ See [Templates](Jellyfin.Plugin.Webhook/Templates) for sample templates.
- Playback device name
- ClientName
- Playback client name
- Username
- NotificationUsername
- User playing item. Note: multiple notifications will be sent if there are multiple users in a session
- UserId
- The user Id
@ -109,7 +109,7 @@ See [Templates](Jellyfin.Plugin.Webhook/Templates) for sample templates.
- MentionType
- EmbedColor
- AvatarUrl
- Username
- BotUsername
- Gotify
- Priority
- Pushbullet
@ -123,6 +123,9 @@ See [Templates](Jellyfin.Plugin.Webhook/Templates) for sample templates.
- MessagePriority
- NotificationSound
- SMTP
- Slack
- BotUsername
- SlackIconUrl
Future events can be created
from https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Server.Implementations/Events/EventingServiceCollectionExtensions.cs
from https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Server.Implementations/Events/EventingServiceCollectionExtensions.cs