52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
using System;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
|
|
namespace Knot.Modules.Messaging.Domain;
|
|
|
|
[BsonDiscriminator("TextMessage")]
|
|
public class TextMessage : Message
|
|
{
|
|
public override string Type => "text";
|
|
public override string? Content { get; protected set; }
|
|
public override string? Quote { get; protected set; }
|
|
|
|
private TextMessage() : base()
|
|
{
|
|
Content = string.Empty;
|
|
}
|
|
|
|
public TextMessage(
|
|
Guid id,
|
|
Guid chatId,
|
|
Guid senderId,
|
|
string content,
|
|
Guid? replyToId,
|
|
string? quote,
|
|
Guid? forwardedFromId,
|
|
DateTime createdAt,
|
|
bool isImported)
|
|
: base(id, chatId, senderId, replyToId, forwardedFromId, createdAt, isImported)
|
|
{
|
|
Content = content;
|
|
Quote = quote;
|
|
|
|
if (!isImported)
|
|
{
|
|
RaiseDomainEvent(new MessageSentDomainEvent(Id, ChatId, SenderId, Content));
|
|
}
|
|
}
|
|
|
|
public override void Edit(string newContent)
|
|
{
|
|
base.Edit(newContent);
|
|
}
|
|
|
|
public override void Delete()
|
|
{
|
|
Content = string.Empty;
|
|
base.Delete();
|
|
}
|
|
}
|
|
|
|
|