diff --git a/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs b/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs index 1e450ae21..38ce954f3 100644 --- a/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs +++ b/NzbDrone.Common.Test/EventingTests/MessageAggregatorCommandTests.cs @@ -76,17 +76,23 @@ namespace NzbDrone.Common.Test.EventingTests public class CommandA : ICommand { + public String CommandId { get; set; } // ReSharper disable UnusedParameter.Local public CommandA(int id = 0) // ReSharper restore UnusedParameter.Local { - + CommandId = HashUtil.GenerateCommandId(); } } public class CommandB : ICommand { + public String CommandId { get; set; } + public CommandB() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Common/HashUtil.cs b/NzbDrone.Common/HashUtil.cs index 0a127ee63..5777cc724 100644 --- a/NzbDrone.Common/HashUtil.cs +++ b/NzbDrone.Common/HashUtil.cs @@ -34,31 +34,9 @@ namespace NzbDrone.Common return String.Format("{0:x8}", mCrc); } - public static string GenerateUserId() + public static string GenerateCommandId() { - return GenerateId("u"); - } - - public static string GenerateAppId() - { - return GenerateId("a"); - } - - public static string GenerateApiToken() - { - return Guid.NewGuid().ToString().Replace("-", ""); - } - - public static string GenerateSecurityToken(int length) - { - var byteSize = (length / 4) * 3; - - var linkBytes = new byte[byteSize]; - var rngCrypto = new RNGCryptoServiceProvider(); - rngCrypto.GetBytes(linkBytes); - var base64String = Convert.ToBase64String(linkBytes); - - return base64String; + return GenerateId("c"); } private static string GenerateId(string prefix) diff --git a/NzbDrone.Common/Messaging/ICommand.cs b/NzbDrone.Common/Messaging/ICommand.cs index d9f8049ba..005a84a68 100644 --- a/NzbDrone.Common/Messaging/ICommand.cs +++ b/NzbDrone.Common/Messaging/ICommand.cs @@ -1,6 +1,9 @@ +using System; + namespace NzbDrone.Common.Messaging { public interface ICommand : IMessage { + String CommandId { get; } } } \ No newline at end of file diff --git a/NzbDrone.Common/Messaging/TestCommand.cs b/NzbDrone.Common/Messaging/TestCommand.cs index 1a54d5764..3ede823e7 100644 --- a/NzbDrone.Common/Messaging/TestCommand.cs +++ b/NzbDrone.Common/Messaging/TestCommand.cs @@ -1,13 +1,15 @@ -namespace NzbDrone.Common.Messaging +using System; + +namespace NzbDrone.Common.Messaging { public class TestCommand : ICommand { + public int Duration { get; set; } + public String CommandId { get; set; } + public TestCommand() { Duration = 4000; } - - public int Duration { get; set; } - } } \ No newline at end of file diff --git a/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs b/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs index 68356ab6e..965121626 100644 --- a/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs +++ b/NzbDrone.Core/DataAugmentation/Scene/UpdateSceneMappingCommand.cs @@ -1,8 +1,16 @@ +using System; +using NzbDrone.Common; using NzbDrone.Common.Messaging; namespace NzbDrone.Core.DataAugmentation.Scene { public class UpdateSceneMappingCommand : ICommand { + public String CommandId { get; set; } + + public UpdateSceneMappingCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs b/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs index b0dce2fd1..08d47672d 100644 --- a/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs +++ b/NzbDrone.Core/IndexerSearch/EpisodeSearchCommand.cs @@ -1,9 +1,17 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.IndexerSearch { public class EpisodeSearchCommand : ICommand { + public String CommandId { get; set; } public int EpisodeId { get; set; } + + public EpisodeSearchCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs b/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs index cf9a8ba3e..a27d98306 100644 --- a/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs +++ b/NzbDrone.Core/IndexerSearch/SeasonSearchCommand.cs @@ -1,10 +1,18 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.IndexerSearch { public class SeasonSearchCommand : ICommand { + public String CommandId { get; set; } public int SeriesId { get; set; } public int SeasonNumber { get; set; } + + public SeasonSearchCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs b/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs index 4e309fde8..e9ade1e45 100644 --- a/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs +++ b/NzbDrone.Core/IndexerSearch/SeriesSearchCommand.cs @@ -1,9 +1,17 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.IndexerSearch { public class SeriesSearchCommand : ICommand { + public String CommandId { get; set; } public int SeriesId { get; set; } + + public SeriesSearchCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/RssSyncCommand.cs b/NzbDrone.Core/Indexers/RssSyncCommand.cs index 04a7a123b..467a7b030 100644 --- a/NzbDrone.Core/Indexers/RssSyncCommand.cs +++ b/NzbDrone.Core/Indexers/RssSyncCommand.cs @@ -1,9 +1,16 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Indexers { public class RssSyncCommand : ICommand { + public String CommandId { get; set; } + public RssSyncCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Instrumentation/Commands/ClearLogCommand.cs b/NzbDrone.Core/Instrumentation/Commands/ClearLogCommand.cs index 19776e76d..34e2812ba 100644 --- a/NzbDrone.Core/Instrumentation/Commands/ClearLogCommand.cs +++ b/NzbDrone.Core/Instrumentation/Commands/ClearLogCommand.cs @@ -1,8 +1,16 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Instrumentation.Commands { public class ClearLogCommand : ICommand { + public String CommandId { get; set; } + + public ClearLogCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Instrumentation/Commands/DeleteLogFilesCommand.cs b/NzbDrone.Core/Instrumentation/Commands/DeleteLogFilesCommand.cs index 5d3228afb..ea16c67d0 100644 --- a/NzbDrone.Core/Instrumentation/Commands/DeleteLogFilesCommand.cs +++ b/NzbDrone.Core/Instrumentation/Commands/DeleteLogFilesCommand.cs @@ -1,8 +1,16 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Instrumentation.Commands { public class DeleteLogFilesCommand : ICommand { + public String CommandId { get; set; } + + public DeleteLogFilesCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Instrumentation/Commands/TrimLogCommand.cs b/NzbDrone.Core/Instrumentation/Commands/TrimLogCommand.cs index c00b27020..8221814ba 100644 --- a/NzbDrone.Core/Instrumentation/Commands/TrimLogCommand.cs +++ b/NzbDrone.Core/Instrumentation/Commands/TrimLogCommand.cs @@ -1,8 +1,16 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Instrumentation.Commands { public class TrimLogCommand : ICommand { + public String CommandId { get; set; } + + public TrimLogCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaFiles/Commands/CleanMediaFileDb.cs b/NzbDrone.Core/MediaFiles/Commands/CleanMediaFileDb.cs index b873dcc5f..42822aae6 100644 --- a/NzbDrone.Core/MediaFiles/Commands/CleanMediaFileDb.cs +++ b/NzbDrone.Core/MediaFiles/Commands/CleanMediaFileDb.cs @@ -1,13 +1,22 @@ +using System; +using NzbDrone.Common; using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Commands { public class CleanMediaFileDb : ICommand { + public String CommandId { get; set; } public int SeriesId { get; private set; } + public CleanMediaFileDb() + { + CommandId = HashUtil.GenerateCommandId(); + } + public CleanMediaFileDb(int seriesId) { + CommandId = HashUtil.GenerateCommandId(); SeriesId = seriesId; } } diff --git a/NzbDrone.Core/MediaFiles/Commands/CleanUpRecycleBinCommand.cs b/NzbDrone.Core/MediaFiles/Commands/CleanUpRecycleBinCommand.cs index b2d16f231..66cbc07a9 100644 --- a/NzbDrone.Core/MediaFiles/Commands/CleanUpRecycleBinCommand.cs +++ b/NzbDrone.Core/MediaFiles/Commands/CleanUpRecycleBinCommand.cs @@ -1,8 +1,16 @@ +using System; +using NzbDrone.Common; using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Commands { public class CleanUpRecycleBinCommand : ICommand { + public String CommandId { get; set; } + + public CleanUpRecycleBinCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs b/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs index 0f03f2083..b0e52126a 100644 --- a/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs +++ b/NzbDrone.Core/MediaFiles/Commands/DownloadedEpisodesScanCommand.cs @@ -1,11 +1,16 @@ +using System; +using NzbDrone.Common; using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Commands { public class DownloadedEpisodesScanCommand : ICommand { + public String CommandId { get; set; } + public DownloadedEpisodesScanCommand() { + CommandId = HashUtil.GenerateCommandId(); } } } \ No newline at end of file diff --git a/NzbDrone.Core/MediaFiles/Commands/RenameSeasonCommand.cs b/NzbDrone.Core/MediaFiles/Commands/RenameSeasonCommand.cs index 723c5d74b..894a1eb86 100644 --- a/NzbDrone.Core/MediaFiles/Commands/RenameSeasonCommand.cs +++ b/NzbDrone.Core/MediaFiles/Commands/RenameSeasonCommand.cs @@ -1,3 +1,5 @@ +using System; +using NzbDrone.Common; using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Commands @@ -7,8 +9,16 @@ namespace NzbDrone.Core.MediaFiles.Commands public int SeriesId { get; private set; } public int SeasonNumber { get; private set; } + public String CommandId { get; set; } + + public RenameSeasonCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } + public RenameSeasonCommand(int seriesId, int seasonNumber) { + CommandId = HashUtil.GenerateCommandId(); SeriesId = seriesId; SeasonNumber = seasonNumber; } diff --git a/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs b/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs index 7716c43c0..954d92ff1 100644 --- a/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs +++ b/NzbDrone.Core/MediaFiles/Commands/RenameSeriesCommand.cs @@ -1,13 +1,22 @@ +using System; +using NzbDrone.Common; using NzbDrone.Common.Messaging; namespace NzbDrone.Core.MediaFiles.Commands { public class RenameSeriesCommand : ICommand { + public String CommandId { get; set; } public int SeriesId { get; private set; } + public RenameSeriesCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } + public RenameSeriesCommand(int seriesId) { + CommandId = HashUtil.GenerateCommandId(); SeriesId = seriesId; } } diff --git a/NzbDrone.Core/Notifications/Email/TestEmailCommand.cs b/NzbDrone.Core/Notifications/Email/TestEmailCommand.cs index 258884788..4ee1133ed 100644 --- a/NzbDrone.Core/Notifications/Email/TestEmailCommand.cs +++ b/NzbDrone.Core/Notifications/Email/TestEmailCommand.cs @@ -1,9 +1,12 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Email { public class TestEmailCommand : ICommand { + public String CommandId { get; set; } public string Server { get; set; } public int Port { get; set; } public bool Ssl { get; set; } @@ -11,5 +14,10 @@ namespace NzbDrone.Core.Notifications.Email public string Password { get; set; } public string From { get; set; } public string To { get; set; } + + public TestEmailCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Notifications/Growl/TestGrowlCommand.cs b/NzbDrone.Core/Notifications/Growl/TestGrowlCommand.cs index 35890fff9..71453e252 100644 --- a/NzbDrone.Core/Notifications/Growl/TestGrowlCommand.cs +++ b/NzbDrone.Core/Notifications/Growl/TestGrowlCommand.cs @@ -1,11 +1,19 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Growl { public class TestGrowlCommand : ICommand { + public String CommandId { get; set; } public string Host { get; set; } public int Port { get; set; } public string Password { get; set; } + + public TestGrowlCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Notifications/Plex/TestPlexClientCommand.cs b/NzbDrone.Core/Notifications/Plex/TestPlexClientCommand.cs index 6df162ab4..bf456754e 100644 --- a/NzbDrone.Core/Notifications/Plex/TestPlexClientCommand.cs +++ b/NzbDrone.Core/Notifications/Plex/TestPlexClientCommand.cs @@ -1,12 +1,20 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Plex { public class TestPlexClientCommand : ICommand { + public String CommandId { get; set; } public string Host { get; set; } public int Port { get; set; } public string Username { get; set; } public string Password { get; set; } + + public TestPlexClientCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Notifications/Plex/TestPlexServerCommand.cs b/NzbDrone.Core/Notifications/Plex/TestPlexServerCommand.cs index 49089afea..3921890bb 100644 --- a/NzbDrone.Core/Notifications/Plex/TestPlexServerCommand.cs +++ b/NzbDrone.Core/Notifications/Plex/TestPlexServerCommand.cs @@ -1,10 +1,18 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Plex { public class TestPlexServerCommand : ICommand { + public String CommandId { get; set; } public string Host { get; set; } public int Port { get; set; } + + public TestPlexServerCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Notifications/Prowl/TestProwlCommand.cs b/NzbDrone.Core/Notifications/Prowl/TestProwlCommand.cs index e58bf5a9c..e30fa4c6b 100644 --- a/NzbDrone.Core/Notifications/Prowl/TestProwlCommand.cs +++ b/NzbDrone.Core/Notifications/Prowl/TestProwlCommand.cs @@ -1,10 +1,18 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Prowl { public class TestProwlCommand : ICommand { + public String CommandId { get; set; } public string ApiKey { get; set; } public int Priority { get; set; } + + public TestProwlCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Notifications/Pushover/TestPushoverCommand.cs b/NzbDrone.Core/Notifications/Pushover/TestPushoverCommand.cs index 31bc034f9..55c6aad8f 100644 --- a/NzbDrone.Core/Notifications/Pushover/TestPushoverCommand.cs +++ b/NzbDrone.Core/Notifications/Pushover/TestPushoverCommand.cs @@ -1,10 +1,18 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Pushover { public class TestPushoverCommand : ICommand { + public String CommandId { get; set; } public string UserKey { get; set; } public int Priority { get; set; } + + public TestPushoverCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs b/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs index 56eb75ee8..17b9d1f72 100644 --- a/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs +++ b/NzbDrone.Core/Notifications/Xbmc/TestXbmcCommand.cs @@ -1,13 +1,21 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Notifications.Xbmc { public class TestXbmcCommand : ICommand { + public String CommandId { get; set; } public string Host { get; set; } public int Port { get; set; } public string Username { get; set; } public string Password { get; set; } public int DisplayTime { get; set; } + + public TestXbmcCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } diff --git a/NzbDrone.Core/Providers/UpdateXemMappingsCommand.cs b/NzbDrone.Core/Providers/UpdateXemMappingsCommand.cs index da4b4b53f..0660cff7b 100644 --- a/NzbDrone.Core/Providers/UpdateXemMappingsCommand.cs +++ b/NzbDrone.Core/Providers/UpdateXemMappingsCommand.cs @@ -1,13 +1,18 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Providers { public class UpdateXemMappingsCommand : ICommand { + public String CommandId { get; set; } public int? SeriesId { get; private set; } public UpdateXemMappingsCommand(int? seriesId) { + CommandId = HashUtil.GenerateCommandId(); + SeriesId = seriesId; } } diff --git a/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs b/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs index f38af963c..941ce42dd 100644 --- a/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs +++ b/NzbDrone.Core/Tv/Commands/RefreshSeriesCommand.cs @@ -1,13 +1,23 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Tv.Commands { public class RefreshSeriesCommand : ICommand { + public String CommandId { get; set; } public int? SeriesId { get; private set; } + public RefreshSeriesCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } + public RefreshSeriesCommand(int? seriesId) { + CommandId = HashUtil.GenerateCommandId(); + SeriesId = seriesId; } } diff --git a/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs b/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs index bbbf6a1f3..e7cfa0a9d 100644 --- a/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs +++ b/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs @@ -1,8 +1,16 @@ -using NzbDrone.Common.Messaging; +using System; +using NzbDrone.Common; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Update.Commands { public class ApplicationUpdateCommand : ICommand { + public String CommandId { get; set; } + + public ApplicationUpdateCommand() + { + CommandId = HashUtil.GenerateCommandId(); + } } } \ No newline at end of file