🗃️ 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>();
|
[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; }
|
public Guid? RealmId { get; set; }
|
||||||
[NotMapped] public SnRealm? Realm { get; set; }
|
[NotMapped] public SnRealm? Realm { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -182,8 +182,9 @@ public class ChatRoomController(
|
|||||||
[RequiredPermission("global", "chat.create")]
|
[RequiredPermission("global", "chat.create")]
|
||||||
public async Task<ActionResult<SnChatRoom>> CreateChatRoom(ChatRoomRequest request)
|
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.");
|
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
|
var chatRoom = new SnChatRoom
|
||||||
{
|
{
|
||||||
@@ -192,13 +193,14 @@ public class ChatRoomController(
|
|||||||
IsCommunity = request.IsCommunity ?? false,
|
IsCommunity = request.IsCommunity ?? false,
|
||||||
IsPublic = request.IsPublic ?? false,
|
IsPublic = request.IsPublic ?? false,
|
||||||
Type = ChatRoomType.Group,
|
Type = ChatRoomType.Group,
|
||||||
|
AccountId = accountId,
|
||||||
Members = new List<SnChatMember>
|
Members = new List<SnChatMember>
|
||||||
{
|
{
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Role = ChatMemberRole.Owner,
|
Role = ChatMemberRole.Owner,
|
||||||
AccountId = Guid.Parse(currentUser.Id),
|
AccountId = accountId,
|
||||||
JoinedAt = Instant.FromDateTimeUtc(DateTime.UtcNow)
|
JoinedAt = SystemClock.Instance.GetCurrentInstant()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -294,7 +296,7 @@ public class ChatRoomController(
|
|||||||
[HttpPatch("{id:guid}")]
|
[HttpPatch("{id:guid}")]
|
||||||
public async Task<ActionResult<SnChatRoom>> UpdateChatRoom(Guid id, [FromBody] ChatRoomRequest request)
|
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
|
var chatRoom = await db.ChatRooms
|
||||||
.Where(e => e.Id == id)
|
.Where(e => e.Id == id)
|
||||||
|
|||||||
@@ -247,6 +247,10 @@ namespace DysonNetwork.Sphere.Migrations
|
|||||||
.HasColumnType("uuid")
|
.HasColumnType("uuid")
|
||||||
.HasColumnName("id");
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<Guid?>("AccountId")
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("account_id");
|
||||||
|
|
||||||
b.Property<SnCloudFileReferenceObject>("Background")
|
b.Property<SnCloudFileReferenceObject>("Background")
|
||||||
.HasColumnType("jsonb")
|
.HasColumnType("jsonb")
|
||||||
.HasColumnName("background");
|
.HasColumnName("background");
|
||||||
|
|||||||
Reference in New Issue
Block a user