using MongoDB.Entities; using System.Security.Cryptography; using System.Text; namespace PrivaPub.Models.Group { public class DmGroup : Entity { public string Description { get; set; } public List Members { get; set; } = new(); public string ConversationURI { get; set; }//context of the federated thread public string ParticipantsKey { get; set; } public DateTime CreationDate { get; set; } = DateTime.UtcNow; public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; public DateTime? DeletionAt { get; set; } public static string KeyOf(IEnumerable members) => Convert.ToHexStringLower(SHA256.HashData(Encoding.UTF8.GetBytes(string.Join("\n", members.Select(m => (m.IsForeign ? "remote:" : "local:") + m.AvatarId).Distinct().Order(StringComparer.Ordinal))))); } }