Files
SocialPub/PrivaPub/Models/Group/DmGroup.cs
T

23 lines
822 B
C#
Raw Normal View History

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<GroupMember> 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<GroupMember> members) =>
Convert.ToHexStringLower(SHA256.HashData(Encoding.UTF8.GetBytes(string.Join("\n",
members.Select(m => (m.IsForeign ? "remote:" : "local:") + m.AvatarId).Distinct().Order(StringComparer.Ordinal)))));
}
}