Fix issues with chat send commands

This commit is contained in:
Jordan Brown
2018-11-24 14:57:39 -05:00
parent 3b3a449537
commit 5f1b807541
8 changed files with 17 additions and 17 deletions
@@ -38,12 +38,12 @@ namespace Tgstation.Server.Host.Components.Chat
/// <summary>
/// If this is considered a channel for admin commands
/// </summary>
public bool IsAdmin { get; set; }
public bool IsAdminChannel { get; set; }
/// <summary>
/// If this is a 1-to-1 chat channel
/// </summary>
public bool IsPrivate { get; set; }
public bool IsPrivateChannel { get; set; }
/// <summary>
/// For user use
@@ -195,7 +195,7 @@ namespace Tgstation.Server.Host.Components.Chat
{
var providerId = providers.Where(x => x.Value == provider).Select(x => x.Key).First();
var enumerable = mappedChannels.Where(x => x.Value.ProviderId == providerId && x.Value.ProviderChannelId == message.User.Channel.RealId);
if (message.User.Channel.IsPrivate)
if (message.User.Channel.IsPrivateChannel)
lock (mappedChannels)
{
if (!provider.Connected)
@@ -223,7 +223,7 @@ namespace Tgstation.Server.Host.Components.Chat
var mapping = enumerable.First().Value;
message.User.Channel.Id = mapping.Channel.Id;
message.User.Channel.Tag = mapping.Channel.Tag;
message.User.Channel.IsAdmin = mapping.Channel.IsAdmin;
message.User.Channel.IsAdminChannel = mapping.Channel.IsAdminChannel;
}
}
@@ -236,7 +236,7 @@ namespace Tgstation.Server.Host.Components.Chat
var addressed = address == CommonMention.ToUpperInvariant() || address == provider.BotMention.ToUpperInvariant();
if (!addressed && !message.User.Channel.IsPrivate)
if (!addressed && !message.User.Channel.IsPrivateChannel)
//no mention
return;
@@ -302,7 +302,7 @@ namespace Tgstation.Server.Host.Components.Chat
return;
}
if (commandHandler.AdminOnly && !message.User.Channel.IsAdmin)
if (commandHandler.AdminOnly && !message.User.Channel.IsAdminChannel)
{
await SendMessage("Use this command in an admin channel!", new List<ulong> { message.User.Channel.RealId }, cancellationToken).ConfigureAwait(false);
return;
@@ -19,7 +19,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
string HelpText { get; }
/// <summary>
/// If the command should only be available to <see cref="User"/>s who's <see cref="User.Channel"/> has <see cref="Channel.IsAdmin"/> set
/// If the command should only be available to <see cref="User"/>s who's <see cref="User.Channel"/> has <see cref="Channel.IsAdminChannel"/> set
/// </summary>
bool AdminOnly { get; }
@@ -97,7 +97,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
Channel = new Channel
{
RealId = e.Channel.Id,
IsPrivate = pm,
IsPrivateChannel = pm,
ConnectionName = pm ? e.Author.Username : (e.Channel as ITextChannel)?.Guild.Name ?? "UNKNOWN",
FriendlyName = e.Channel.Name
//isAdmin and Tag populated by manager
@@ -188,10 +188,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
return new Channel
{
RealId = discordChannel.Id,
IsAdmin = channel.IsAdminChannel == true,
IsAdminChannel = channel.IsAdminChannel == true,
ConnectionName = discordChannel.Guild.Name,
FriendlyName = discordChannel.Name,
IsPrivate = false,
IsPrivateChannel = false,
Tag = channel.Tag
};
};
@@ -204,7 +204,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
ConnectionName = address,
FriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName,
RealId = channelId,
IsPrivate = isPrivate
IsPrivateChannel = isPrivate
//isAdmin and Tag populated by manager
},
FriendlyName = username,
@@ -393,10 +393,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
return new Channel
{
RealId = id.Value,
IsAdmin = x.IsAdminChannel == true,
IsAdminChannel = x.IsAdminChannel == true,
ConnectionName = address,
FriendlyName = channelIdMap[id.Value],
IsPrivate = false,
IsPrivateChannel = false,
Tag = x.Tag
};
}).ToList();
@@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Components.Interop
/// <summary>
/// The dictionary of the <see cref="CommCommand"/>
/// </summary>
public IReadOnlyDictionary<string, string> Parameters { get; set; }
public IReadOnlyDictionary<string, object> Parameters { get; set; }
/// <summary>
/// The raw JSON of the <see cref="CommCommand"/>
@@ -109,7 +109,7 @@ namespace Tgstation.Server.Host.Components.Interop
{
command = new CommCommand
{
Parameters = JsonConvert.DeserializeObject<IReadOnlyDictionary<string, string>>(file),
Parameters = JsonConvert.DeserializeObject<IReadOnlyDictionary<string, object>>(file),
RawJson = file
};
}
@@ -316,7 +316,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
case Constants.DMCommandNewPort:
lock (this)
{
if (!query.TryGetValue(Constants.DMParameterData, out var stringPort) || !UInt16.TryParse(stringPort, out var currentPort))
if (!query.TryGetValue(Constants.DMParameterData, out var stringPortObject) || !UInt16.TryParse(stringPortObject as string, out var currentPort))
{
/////UHHHH
logger.LogWarning("DreamDaemon sent new port command without providing it's own!");
@@ -354,7 +354,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
content = new ErrorMessage { Message = "Invalid API validation request!" };
break;
}
if (!query.TryGetValue(Constants.DMParameterData, out var stringMinimumSecurityLevel) || !Enum.TryParse<DreamDaemonSecurity>(stringMinimumSecurityLevel, out var minimumSecurityLevel))
if (!query.TryGetValue(Constants.DMParameterData, out var stringMinimumSecurityLevelObject) || !Enum.TryParse<DreamDaemonSecurity>(stringMinimumSecurityLevelObject as string, out var minimumSecurityLevel))
apiValidationStatus = ApiValidationStatus.BadValidationRequest;
else
switch (minimumSecurityLevel)