RT
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using AipsCore.Application.Abstract;
|
||||
using AipsCore.Application.Models.Whiteboard.Query.GetMembershipStatus;
|
||||
using AipsCore.Application.Models.Whiteboard.Query.GetWhiteboardInfoRT;
|
||||
using AipsCore.Domain.Models.Shape.Enums;
|
||||
using AipsCore.Domain.Models.WhiteboardMembership.Enums;
|
||||
using AipsRT.Model.Whiteboard.Shapes.Map;
|
||||
|
||||
namespace AipsRT.Model.Whiteboard;
|
||||
|
||||
@@ -7,6 +7,9 @@ public class Whiteboard
|
||||
public Guid WhiteboardId { get; set; }
|
||||
|
||||
public Guid OwnerId { get; set; }
|
||||
|
||||
public HashSet<Guid> AcceptedUsers { get; } = new();
|
||||
public HashSet<Guid> PendingUsers { get; } = new();
|
||||
|
||||
public List<Shape> Shapes { get; } = [];
|
||||
|
||||
@@ -38,4 +41,16 @@ public class Whiteboard
|
||||
Shapes.Add(shape);
|
||||
TextShapes.Add(shape);
|
||||
}
|
||||
|
||||
public void AddPendingUser(Guid userId) => PendingUsers.Add(userId);
|
||||
|
||||
public void AcceptUser(Guid userId)
|
||||
{
|
||||
PendingUsers.Remove(userId);
|
||||
AcceptedUsers.Add(userId);
|
||||
}
|
||||
|
||||
public void RejectUser(Guid userId) => PendingUsers.Remove(userId);
|
||||
|
||||
public bool IsAccepted(Guid userId) => AcceptedUsers.Contains(userId);
|
||||
}
|
||||
@@ -47,13 +47,42 @@ public class WhiteboardManager
|
||||
return _userInWhiteboards[userId];
|
||||
}
|
||||
|
||||
public void RemoveUserFromWhiteboard(Guid userId, Guid whiteboardId)
|
||||
public void RemoveUserFromWhiteboard(Guid userId)
|
||||
{
|
||||
_userInWhiteboards.TryRemove(whiteboardId, out _);
|
||||
_userInWhiteboards.TryRemove(userId, out _);
|
||||
}
|
||||
|
||||
public Whiteboard? GetWhiteboardForUser(Guid userId)
|
||||
{
|
||||
return GetWhiteboard(GetUserWhiteboard(userId));
|
||||
}
|
||||
|
||||
public void AddPendingUser(Guid userId, Guid whiteboardId)
|
||||
{
|
||||
var wb = GetWhiteboard(whiteboardId)!;
|
||||
wb.AddPendingUser(userId);
|
||||
_userInWhiteboards[userId] = whiteboardId;
|
||||
}
|
||||
|
||||
public void MovePendingToAccepted(Guid userId, Guid whiteboardId)
|
||||
{
|
||||
var wb = GetWhiteboard(whiteboardId)!;
|
||||
wb.AcceptUser(userId);
|
||||
}
|
||||
|
||||
public void RemovePendingUser(Guid userId, Guid whiteboardId)
|
||||
{
|
||||
var whiteboard = GetWhiteboard(whiteboardId)!;
|
||||
whiteboard.RejectUser(userId);
|
||||
_userInWhiteboards.TryRemove(userId, out _);
|
||||
}
|
||||
|
||||
public bool IsAccepted(Guid userId)
|
||||
{
|
||||
if (!_userInWhiteboards.TryGetValue(userId, out var wbId))
|
||||
return false;
|
||||
|
||||
var whiteboard = GetWhiteboard(wbId);
|
||||
return whiteboard?.IsAccepted(userId) ?? false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user