♻️ No idea, but errors all gone
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Pass.Account;
|
||||
using DysonNetwork.Shared.Services;
|
||||
using DysonNetwork.Sphere.Storage;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -15,9 +16,10 @@ public class RealmController(
|
||||
AppDatabase db,
|
||||
RealmService rs,
|
||||
FileReferenceService fileRefService,
|
||||
RelationshipService rels,
|
||||
ActionLogService als,
|
||||
AccountEventService aes
|
||||
IRelationshipService rels,
|
||||
IActionLogService als,
|
||||
IAccountEventService aes,
|
||||
IAccountService accounts
|
||||
) : Controller
|
||||
{
|
||||
[HttpGet("{slug}")]
|
||||
@@ -79,7 +81,7 @@ public class RealmController(
|
||||
if (HttpContext.Items["CurrentUser"] is not Shared.Models.Account currentUser) return Unauthorized();
|
||||
var userId = currentUser.Id;
|
||||
|
||||
var relatedUser = await db.Accounts.FindAsync(request.RelatedUserId);
|
||||
var relatedUser = await accounts.GetAccountById(request.RelatedUserId);
|
||||
if (relatedUser is null) return BadRequest("Related user was not found");
|
||||
|
||||
if (await rels.HasRelationshipWithStatus(currentUser.Id, relatedUser.Id, RelationshipStatus.Blocked))
|
||||
@@ -111,9 +113,12 @@ public class RealmController(
|
||||
db.RealmMembers.Add(member);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmInvite,
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id }, { "account_id", member.AccountId } }, Request
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id }, { "account_id", member.AccountId } },
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
member.Account = relatedUser;
|
||||
@@ -141,10 +146,12 @@ public class RealmController(
|
||||
db.Update(member);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmJoin,
|
||||
new Dictionary<string, object> { { "realm_id", member.RealmId }, { "account_id", member.AccountId } },
|
||||
Request
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return Ok(member);
|
||||
@@ -167,10 +174,12 @@ public class RealmController(
|
||||
member.LeaveAt = SystemClock.Instance.GetCurrentInstant();
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmLeave,
|
||||
new Dictionary<string, object> { { "realm_id", member.RealmId }, { "account_id", member.AccountId } },
|
||||
Request
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return NoContent();
|
||||
@@ -245,7 +254,6 @@ public class RealmController(
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("{slug}/members/me")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<RealmMember>> GetCurrentIdentity(string slug)
|
||||
@@ -284,10 +292,12 @@ public class RealmController(
|
||||
member.LeaveAt = SystemClock.Instance.GetCurrentInstant();
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmLeave,
|
||||
new Dictionary<string, object> { { "realm_id", member.RealmId }, { "account_id", member.AccountId } },
|
||||
Request
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return NoContent();
|
||||
@@ -349,9 +359,12 @@ public class RealmController(
|
||||
db.Realms.Add(realm);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmCreate,
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id } }, Request
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id } },
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
var realmResourceId = $"realm:{realm.Id}";
|
||||
@@ -455,9 +468,12 @@ public class RealmController(
|
||||
db.Realms.Update(realm);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmUpdate,
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id } }, Request
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id } },
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return Ok(realm);
|
||||
@@ -494,10 +510,12 @@ public class RealmController(
|
||||
db.RealmMembers.Add(member);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmJoin,
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id }, { "account_id", currentUser.Id } },
|
||||
Request
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return Ok(member);
|
||||
@@ -525,10 +543,12 @@ public class RealmController(
|
||||
member.LeaveAt = SystemClock.Instance.GetCurrentInstant();
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.ChatroomKick,
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id }, { "account_id", memberId } },
|
||||
Request
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return NoContent();
|
||||
@@ -559,11 +579,13 @@ public class RealmController(
|
||||
db.RealmMembers.Update(member);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmAdjustRole,
|
||||
new Dictionary<string, object>
|
||||
{ { "realm_id", realm.Id }, { "account_id", memberId }, { "new_role", newRole } },
|
||||
Request
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
return Ok(member);
|
||||
@@ -588,9 +610,12 @@ public class RealmController(
|
||||
db.Realms.Remove(realm);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
als.CreateActionLogFromRequest(
|
||||
await als.CreateActionLogFromRequest(
|
||||
ActionLogType.RealmDelete,
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id } }, Request
|
||||
new Dictionary<string, object> { { "realm_id", realm.Id } },
|
||||
Request.HttpContext.Connection.RemoteIpAddress?.ToString(),
|
||||
Request.Headers.UserAgent.ToString(),
|
||||
currentUser
|
||||
);
|
||||
|
||||
// Delete all file references for this realm
|
||||
@@ -599,4 +624,4 @@ public class RealmController(
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Sphere.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using DysonNetwork.Shared.Localization;
|
||||
|
||||
namespace DysonNetwork.Sphere.Realm;
|
||||
|
||||
@@ -9,7 +10,7 @@ public class RealmService(AppDatabase db, DysonNetwork.Shared.Services.INoti
|
||||
{
|
||||
public async Task SendInviteNotify(RealmMember member)
|
||||
{
|
||||
AccountService.SetCultureInfo(member.Account);
|
||||
CultureInfoService.SetCultureInfo(member.Account);
|
||||
await nty.SendNotification(
|
||||
member.Account,
|
||||
"invites.realms",
|
||||
|
||||
Reference in New Issue
Block a user