Fixed: Fallback to Instance Name for Discord notifications

(cherry picked from commit b99e06acc0a3ecae2857d9225b35424c82c67a2b)
This commit is contained in:
Stevie Robinson 2025-02-19 04:23:43 +01:00 committed by Bogdan
commit be115da157

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using FluentValidation.Results; using FluentValidation.Results;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
@ -14,10 +15,12 @@ namespace NzbDrone.Core.Notifications.Discord
public class Discord : NotificationBase<DiscordSettings> public class Discord : NotificationBase<DiscordSettings>
{ {
private readonly IDiscordProxy _proxy; private readonly IDiscordProxy _proxy;
private readonly IConfigFileProvider _configFileProvider;
public Discord(IDiscordProxy proxy) public Discord(IDiscordProxy proxy, IConfigFileProvider configFileProvider)
{ {
_proxy = proxy; _proxy = proxy;
_configFileProvider = configFileProvider;
} }
public override string Name => "Discord"; public override string Name => "Discord";
@ -33,7 +36,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Url = $"https://musicbrainz.org/artist/{artist.ForeignArtistId}", Url = $"https://musicbrainz.org/artist/{artist.ForeignArtistId}",
@ -138,7 +141,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Url = $"https://musicbrainz.org/artist/{artist.ForeignArtistId}", Url = $"https://musicbrainz.org/artist/{artist.ForeignArtistId}",
@ -296,7 +299,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Title = healthCheck.Source.Name, Title = healthCheck.Source.Name,
@ -319,7 +322,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/Lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/Lidarr/Lidarr/develop/Logo/256.png"
}, },
Title = "Health Issue Resolved: " + previousCheck.Source.Name, Title = "Health Issue Resolved: " + previousCheck.Source.Name,
@ -342,7 +345,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Title = TRACK_RETAGGED_TITLE, Title = TRACK_RETAGGED_TITLE,
@ -363,7 +366,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Description = message.Message, Description = message.Message,
@ -385,7 +388,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Description = message.Message, Description = message.Message,
@ -407,7 +410,7 @@ namespace NzbDrone.Core.Notifications.Discord
{ {
Author = new DiscordAuthor Author = new DiscordAuthor
{ {
Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, Name = Settings.Author.IsNullOrWhiteSpace() ? _configFileProvider.InstanceName : Settings.Author,
IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png" IconUrl = "https://raw.githubusercontent.com/lidarr/Lidarr/develop/Logo/256.png"
}, },
Title = APPLICATION_UPDATE_TITLE, Title = APPLICATION_UPDATE_TITLE,