🐛 Fix chat backward comapbility
This commit is contained in:
@@ -8,27 +8,39 @@ namespace DysonNetwork.Shared.Models;
|
|||||||
public enum ChatRoomType
|
public enum ChatRoomType
|
||||||
{
|
{
|
||||||
Group,
|
Group,
|
||||||
DirectMessage
|
DirectMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SnChatRoom : ModelBase, IIdentifiedResource
|
public class SnChatRoom : ModelBase, IIdentifiedResource
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
[MaxLength(1024)] public string? Name { get; set; }
|
|
||||||
[MaxLength(4096)] public string? Description { get; set; }
|
[MaxLength(1024)]
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(4096)]
|
||||||
|
public string? Description { get; set; }
|
||||||
public ChatRoomType Type { get; set; }
|
public ChatRoomType Type { get; set; }
|
||||||
public bool IsCommunity { get; set; }
|
public bool IsCommunity { get; set; }
|
||||||
public bool IsPublic { get; set; }
|
public bool IsPublic { get; set; }
|
||||||
|
|
||||||
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Picture { get; set; }
|
[Column(TypeName = "jsonb")]
|
||||||
[Column(TypeName = "jsonb")] public SnCloudFileReferenceObject? Background { get; set; }
|
public SnCloudFileReferenceObject? Picture { get; set; }
|
||||||
|
|
||||||
[JsonIgnore] public ICollection<SnChatMember> Members { get; set; } = new List<SnChatMember>();
|
[Column(TypeName = "jsonb")]
|
||||||
|
public SnCloudFileReferenceObject? Background { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public ICollection<SnChatMember> Members { get; set; } = new List<SnChatMember>();
|
||||||
|
|
||||||
public Guid? AccountId { get; set; }
|
public Guid? AccountId { get; set; }
|
||||||
[NotMapped] public SnAccount? Account { get; set; }
|
|
||||||
|
[NotMapped]
|
||||||
|
public SnAccount? Account { get; set; }
|
||||||
public Guid? RealmId { get; set; }
|
public Guid? RealmId { get; set; }
|
||||||
[NotMapped] public SnRealm? Realm { get; set; }
|
|
||||||
|
[NotMapped]
|
||||||
|
public SnRealm? Realm { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[JsonPropertyName("members")]
|
[JsonPropertyName("members")]
|
||||||
@@ -42,7 +54,7 @@ public enum ChatMemberNotify
|
|||||||
{
|
{
|
||||||
All,
|
All,
|
||||||
Mentions,
|
Mentions,
|
||||||
None
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ChatTimeoutCauseType
|
public enum ChatTimeoutCauseType
|
||||||
@@ -53,7 +65,8 @@ public enum ChatTimeoutCauseType
|
|||||||
|
|
||||||
public class ChatTimeoutCause
|
public class ChatTimeoutCause
|
||||||
{
|
{
|
||||||
[MaxLength(4096)] public string? Reason { get; set; } = null;
|
[MaxLength(4096)]
|
||||||
|
public string? Reason { get; set; } = null;
|
||||||
public ChatTimeoutCauseType Type { get; set; }
|
public ChatTimeoutCauseType Type { get; set; }
|
||||||
public Guid? SenderId { get; set; }
|
public Guid? SenderId { get; set; }
|
||||||
public Instant? Since { get; set; }
|
public Instant? Since { get; set; }
|
||||||
@@ -65,10 +78,15 @@ public class SnChatMember : ModelBase
|
|||||||
public Guid ChatRoomId { get; set; }
|
public Guid ChatRoomId { get; set; }
|
||||||
public SnChatRoom ChatRoom { get; set; } = null!;
|
public SnChatRoom ChatRoom { get; set; } = null!;
|
||||||
public Guid AccountId { get; set; }
|
public Guid AccountId { get; set; }
|
||||||
[NotMapped] public SnAccount? Account { get; set; }
|
|
||||||
[NotMapped] public SnAccountStatus? Status { get; set; }
|
|
||||||
|
|
||||||
[MaxLength(1024)] public string? Nick { get; set; }
|
[NotMapped]
|
||||||
|
public SnAccount? Account { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public SnAccountStatus? Status { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(1024)]
|
||||||
|
public string? Nick { get; set; }
|
||||||
|
|
||||||
public ChatMemberNotify Notify { get; set; } = ChatMemberNotify.All;
|
public ChatMemberNotify Notify { get; set; } = ChatMemberNotify.All;
|
||||||
public Instant? LastReadAt { get; set; }
|
public Instant? LastReadAt { get; set; }
|
||||||
@@ -79,22 +97,29 @@ public class SnChatMember : ModelBase
|
|||||||
public SnChatMember? InvitedBy { get; set; }
|
public SnChatMember? InvitedBy { get; set; }
|
||||||
|
|
||||||
// Backwards support field
|
// Backwards support field
|
||||||
[NotMapped] public int Role = 0;
|
[NotMapped]
|
||||||
|
public int Role { get; } = 0;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public bool IsBot { get; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The break time is the user doesn't receive any message from this member for a while.
|
/// The break time is the user doesn't receive any message from this member for a while.
|
||||||
/// Expect mentioned him or her.
|
/// Expect mentioned him or her.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Instant? BreakUntil { get; set; }
|
public Instant? BreakUntil { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The timeout is the user can't send any message.
|
/// The timeout is the user can't send any message.
|
||||||
/// Set by the moderator of the chat room.
|
/// Set by the moderator of the chat room.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Instant? TimeoutUntil { get; set; }
|
public Instant? TimeoutUntil { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The timeout cause is the reason why the user is timeout.
|
/// The timeout cause is the reason why the user is timeout.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(TypeName = "jsonb")] public ChatTimeoutCause? TimeoutCause { get; set; }
|
[Column(TypeName = "jsonb")]
|
||||||
|
public ChatTimeoutCause? TimeoutCause { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ChatMemberTransmissionObject : ModelBase
|
public class ChatMemberTransmissionObject : ModelBase
|
||||||
@@ -102,9 +127,12 @@ public class ChatMemberTransmissionObject : ModelBase
|
|||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public Guid ChatRoomId { get; set; }
|
public Guid ChatRoomId { get; set; }
|
||||||
public Guid AccountId { get; set; }
|
public Guid AccountId { get; set; }
|
||||||
[NotMapped] public SnAccount Account { get; set; } = null!;
|
|
||||||
|
|
||||||
[MaxLength(1024)] public string? Nick { get; set; }
|
[NotMapped]
|
||||||
|
public SnAccount Account { get; set; } = null!;
|
||||||
|
|
||||||
|
[MaxLength(1024)]
|
||||||
|
public string? Nick { get; set; }
|
||||||
|
|
||||||
public ChatMemberNotify Notify { get; set; } = ChatMemberNotify.All;
|
public ChatMemberNotify Notify { get; set; } = ChatMemberNotify.All;
|
||||||
public Instant? JoinedAt { get; set; }
|
public Instant? JoinedAt { get; set; }
|
||||||
@@ -118,7 +146,11 @@ public class ChatMemberTransmissionObject : ModelBase
|
|||||||
public ChatTimeoutCause? TimeoutCause { get; set; }
|
public ChatTimeoutCause? TimeoutCause { get; set; }
|
||||||
|
|
||||||
// Backwards support field
|
// Backwards support field
|
||||||
[NotMapped] public int Role = 0;
|
[NotMapped]
|
||||||
|
public int Role { get; } = 0;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public bool IsBot { get; } = false;
|
||||||
|
|
||||||
public static ChatMemberTransmissionObject FromEntity(SnChatMember member)
|
public static ChatMemberTransmissionObject FromEntity(SnChatMember member)
|
||||||
{
|
{
|
||||||
@@ -139,7 +171,7 @@ public class ChatMemberTransmissionObject : ModelBase
|
|||||||
InvitedBy = member.InvitedBy,
|
InvitedBy = member.InvitedBy,
|
||||||
CreatedAt = member.CreatedAt,
|
CreatedAt = member.CreatedAt,
|
||||||
UpdatedAt = member.UpdatedAt,
|
UpdatedAt = member.UpdatedAt,
|
||||||
DeletedAt = member.DeletedAt
|
DeletedAt = member.DeletedAt,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user