mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Nullify Message
This commit is contained in:
@@ -12,5 +12,19 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// The <see cref="IMessageReference"/> of the source <see cref="Message"/>.
|
||||
/// </summary>
|
||||
public Optional<IMessageReference> MessageReference { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DiscordMessage"/> class.
|
||||
/// </summary>
|
||||
/// <param name="user">The value of <see cref="Message.User"/>.</param>
|
||||
/// <param name="content">The value of <see cref="Message.Content"/>.</param>
|
||||
/// <param name="messageReference">The value of <see cref="MessageReference"/>.</param>
|
||||
public DiscordMessage(ChatUser user, string content, Optional<IMessageReference> messageReference)
|
||||
: base(
|
||||
user,
|
||||
content)
|
||||
{
|
||||
MessageReference = messageReference;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,11 +534,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
messageGuildResponse.LogFormat());
|
||||
}
|
||||
|
||||
var result = new DiscordMessage
|
||||
{
|
||||
MessageReference = messageReference,
|
||||
Content = content,
|
||||
User = new ChatUser
|
||||
var result = new DiscordMessage(
|
||||
new ChatUser
|
||||
{
|
||||
RealId = messageCreateEvent.Author.ID.Value,
|
||||
Channel = new ChannelRepresentation(
|
||||
@@ -554,7 +551,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
FriendlyName = messageCreateEvent.Author.Username,
|
||||
Mention = NormalizeMentions($"<@{messageCreateEvent.Author.ID}>"),
|
||||
},
|
||||
};
|
||||
content,
|
||||
messageReference);
|
||||
|
||||
EnqueueMessage(result);
|
||||
return Result.FromSuccess();
|
||||
|
||||
@@ -530,10 +530,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
}
|
||||
|
||||
var channelFriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName;
|
||||
var message = new Message
|
||||
{
|
||||
Content = e.Data.Message,
|
||||
User = new ChatUser
|
||||
var message = new Message(
|
||||
new ChatUser
|
||||
{
|
||||
Channel = new ChannelRepresentation(address, channelFriendlyName, channelId)
|
||||
{
|
||||
@@ -546,7 +544,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
RealId = userId,
|
||||
Mention = username,
|
||||
},
|
||||
};
|
||||
e.Data.Message);
|
||||
|
||||
EnqueueMessage(message);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable disable
|
||||
using System;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
{
|
||||
@@ -10,11 +10,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// <summary>
|
||||
/// The text of the message.
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
public string Content { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ChatUser"/> who sent the <see cref="Message"/>.
|
||||
/// </summary>
|
||||
public ChatUser User { get; set; }
|
||||
public ChatUser User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Message"/> class.
|
||||
/// </summary>
|
||||
/// <param name="user">The value of <see cref="User"/>.</param>
|
||||
/// <param name="content">The value of <see cref="Content"/>.</param>
|
||||
public Message(ChatUser user, string content)
|
||||
{
|
||||
User = user ?? throw new ArgumentNullException(nameof(user));
|
||||
Content = content ?? throw new ArgumentNullException(nameof(content));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,13 +315,8 @@ namespace Tgstation.Server.Tests.Live
|
||||
else
|
||||
content = $"{content} embeds_test"; // NEVER send the response_overload_test, it causes so much havoc in CI and we test it manually
|
||||
|
||||
EnqueueMessage(new Message
|
||||
{
|
||||
Content = content,
|
||||
User = sender,
|
||||
});
|
||||
EnqueueMessage(new Message(sender, content));
|
||||
}
|
||||
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user