diff --git a/build/Version.props b/build/Version.props index 1b16b06328..2cab724f17 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 5.2.1 + 5.2.2 4.4.0 9.7.0 10.1.0 diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index a1f1e425f2..be208c68be 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -211,14 +211,14 @@ namespace Tgstation.Server.Host.Components.Chat .ToList(); } - var newMappings = Enumerable.Zip(newChannels, results, (x, y) => new ChannelMapping + var newMappings = results.Select(tuple => new ChannelMapping { - IsWatchdogChannel = x.IsWatchdogChannel == true, - IsUpdatesChannel = x.IsUpdatesChannel == true, - IsAdminChannel = x.IsAdminChannel == true, - ProviderChannelId = y.RealId, + IsWatchdogChannel = tuple.Item1.IsWatchdogChannel == true, + IsUpdatesChannel = tuple.Item1.IsUpdatesChannel == true, + IsAdminChannel = tuple.Item1.IsAdminChannel == true, + ProviderChannelId = tuple.Item2.RealId, ProviderId = connectionId, - Channel = y, + Channel = tuple.Item2, }); ulong baseId; diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 8613aacb86..658dfdc3a0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -592,14 +592,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - protected override async Task> MapChannelsImpl(IEnumerable channels, CancellationToken cancellationToken) + protected override async Task>> MapChannelsImpl(IEnumerable channels, CancellationToken cancellationToken) { if (channels == null) throw new ArgumentNullException(nameof(channels)); bool remapRequired = false; - async Task GetModelChannelFromDBChannel(Api.Models.ChatChannel channelFromDB) + async Task> GetModelChannelFromDBChannel(Api.Models.ChatChannel channelFromDB) { if (!channelFromDB.DiscordChannelId.HasValue) throw new InvalidOperationException("ChatChannel missing DiscordChannelId!"); @@ -623,7 +623,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers return null; } - if (discordChannelResponse.Entity.Type != ChannelType.GuildText) + var channelType = discordChannelResponse.Entity.Type; + if (channelType != ChannelType.GuildText && channelType != ChannelType.GuildAnnouncement) { Logger.LogWarning("Cound not map channel {0}! Incorrect type: {1}", channelId, discordChannelResponse.Entity.Type); return null; @@ -660,7 +661,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers }; Logger.LogTrace("Mapped channel {0}: {1}", channelModel.RealId, channelModel.FriendlyName); - return channelModel; + return Tuple.Create(channelFromDB, channelModel); } var tasks = channels @@ -677,7 +678,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers lock (mappedChannels) { mappedChannels.Clear(); - mappedChannels.AddRange(enumerator.Select(x => x.RealId)); + mappedChannels.AddRange(enumerator.Select(x => x.Item2.RealId)); } if (remapRequired) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs index 9ea1d46757..5ec71c169e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs @@ -57,8 +57,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The s to map. /// The for the operation. - /// A resulting in a of the s representing . - Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken); + /// A resulting in a of the 's s representing . + Task>> MapChannels(IEnumerable channels, CancellationToken cancellationToken); /// /// Send a message to the . diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index 846d746f6a..1a3d22f682 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -252,7 +252,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - protected override Task> MapChannelsImpl( + protected override Task>> MapChannelsImpl( IEnumerable channels, CancellationToken cancellationToken) => Task.Factory.StartNew( @@ -285,10 +285,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers else client.RfcJoin(channelToJoin); - return (IReadOnlyCollection)channels - .Select(x => + return (IReadOnlyCollection>)channels + .Select(apiChannel => { - var channelName = x.GetIrcChannelName(); + var channelName = apiChannel.GetIrcChannelName(); ulong? id = null; if (!channelIdMap.Any(y => { @@ -302,15 +302,17 @@ namespace Tgstation.Server.Host.Components.Chat.Providers channelIdMap.Add(id.Value, channelName); } - return new ChannelRepresentation - { - RealId = id.Value, - IsAdminChannel = x.IsAdminChannel == true, - ConnectionName = address, - FriendlyName = channelIdMap[id.Value], - IsPrivateChannel = false, - Tag = x.Tag, - }; + return Tuple.Create( + apiChannel, + new ChannelRepresentation + { + RealId = id.Value, + IsAdminChannel = apiChannel.IsAdminChannel == true, + ConnectionName = address, + FriendlyName = channelIdMap[id.Value], + IsPrivateChannel = false, + Tag = apiChannel.Tag, + }); }) .ToList(); } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index de21ae2dce..a9468d603a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -117,7 +117,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers public void InitialMappingComplete() => initialConnectionTcs.TrySetResult(null); /// - public async Task> MapChannels(IEnumerable channels, CancellationToken cancellationToken) + public async Task>> MapChannels(IEnumerable channels, CancellationToken cancellationToken) { try { @@ -197,8 +197,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The s to map. /// The for the operation. - /// A resulting in a of the s representing . - protected abstract Task> MapChannelsImpl(IEnumerable channels, CancellationToken cancellationToken); + /// A resulting in a of the 's s representing . + protected abstract Task>> MapChannelsImpl( + IEnumerable channels, + CancellationToken cancellationToken); /// /// Queues a for .