🗃️ Bring account id back to chat room
This commit is contained in:
@@ -25,6 +25,8 @@ public class SnChatRoom : ModelBase, IIdentifiedResource
|
||||
|
||||
[JsonIgnore] public ICollection<SnChatMember> Members { get; set; } = new List<SnChatMember>();
|
||||
|
||||
public Guid? AccountId { get; set; }
|
||||
[NotMapped] public SnAccount? Account { get; set; }
|
||||
public Guid? RealmId { get; set; }
|
||||
[NotMapped] public SnRealm? Realm { get; set; }
|
||||
|
||||
|
||||
@@ -182,8 +182,9 @@ public class ChatRoomController(
|
||||
[RequiredPermission("global", "chat.create")]
|
||||
public async Task<ActionResult<SnChatRoom>> CreateChatRoom(ChatRoomRequest request)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser) return Unauthorized();
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||
if (request.Name is null) return BadRequest("You cannot create a chat room without a name.");
|
||||
var accountId = Guid.Parse(currentUser.Id);
|
||||
|
||||
var chatRoom = new SnChatRoom
|
||||
{
|
||||
@@ -192,13 +193,14 @@ public class ChatRoomController(
|
||||
IsCommunity = request.IsCommunity ?? false,
|
||||
IsPublic = request.IsPublic ?? false,
|
||||
Type = ChatRoomType.Group,
|
||||
AccountId = accountId,
|
||||
Members = new List<SnChatMember>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Role = ChatMemberRole.Owner,
|
||||
AccountId = Guid.Parse(currentUser.Id),
|
||||
JoinedAt = Instant.FromDateTimeUtc(DateTime.UtcNow)
|
||||
AccountId = accountId,
|
||||
JoinedAt = SystemClock.Instance.GetCurrentInstant()
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -294,7 +296,7 @@ public class ChatRoomController(
|
||||
[HttpPatch("{id:guid}")]
|
||||
public async Task<ActionResult<SnChatRoom>> UpdateChatRoom(Guid id, [FromBody] ChatRoomRequest request)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Shared.Proto.Account currentUser) return Unauthorized();
|
||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||
|
||||
var chatRoom = await db.ChatRooms
|
||||
.Where(e => e.Id == id)
|
||||
|
||||
@@ -247,6 +247,10 @@ namespace DysonNetwork.Sphere.Migrations
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<Guid?>("AccountId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("account_id");
|
||||
|
||||
b.Property<SnCloudFileReferenceObject>("Background")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("background");
|
||||
|
||||
Reference in New Issue
Block a user