♻️ 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.Sphere.Permission; | ||||
| using DysonNetwork.Shared.Permission; | ||||
| using DysonNetwork.Shared.Services; | ||||
| using DysonNetwork.Sphere.Realm; | ||||
| using DysonNetwork.Sphere.Storage; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| @@ -16,7 +17,9 @@ public class PublisherController( | ||||
|     AppDatabase db, | ||||
|     PublisherService ps, | ||||
|     FileReferenceService fileRefService, | ||||
|     DysonNetwork.Shared.Services.IActionLogService als) | ||||
|     IAccountService accounts, | ||||
|     IActionLogService als | ||||
| ) | ||||
|     : ControllerBase | ||||
| { | ||||
|     [HttpGet("{name}")] | ||||
| @@ -28,10 +31,7 @@ public class PublisherController( | ||||
|         if (publisher is null) return NotFound(); | ||||
|         if (publisher.AccountId is null) return Ok(publisher); | ||||
|  | ||||
|         var account = await db.Accounts | ||||
|             .Where(a => a.Id == publisher.AccountId) | ||||
|             .Include(a => a.Profile) | ||||
|             .FirstOrDefaultAsync(); | ||||
|         var account = await accounts.GetAccountById(publisher.AccountId.Value, true); | ||||
|         publisher.Account = account; | ||||
|  | ||||
|         return Ok(publisher); | ||||
| @@ -79,7 +79,7 @@ public class PublisherController( | ||||
|  | ||||
|     public class PublisherMemberRequest | ||||
|     { | ||||
|         [Required] public long RelatedUserId { get; set; } | ||||
|         [Required] public Guid RelatedUserId { get; set; } | ||||
|         [Required] public PublisherMemberRole Role { get; set; } | ||||
|     } | ||||
|  | ||||
| @@ -91,7 +91,7 @@ public class PublisherController( | ||||
|         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"); | ||||
|  | ||||
|         var publisher = await db.Publishers | ||||
| @@ -112,13 +112,16 @@ public class PublisherController( | ||||
|         db.PublisherMembers.Add(newMember); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherMemberInvite, | ||||
|             new Dictionary<string, object> | ||||
|             { | ||||
|                 { "publisher_id", publisher.Id }, | ||||
|                 { "account_id", relatedUser.Id } | ||||
|             }, Request | ||||
|             }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return Ok(newMember); | ||||
| @@ -142,9 +145,12 @@ public class PublisherController( | ||||
|         db.Update(member); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherMemberJoin, | ||||
|             new Dictionary<string, object> { { "account_id", member.AccountId } }, Request | ||||
|             new Dictionary<string, object> { { "account_id", member.AccountId } }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return Ok(member); | ||||
| @@ -167,9 +173,12 @@ public class PublisherController( | ||||
|         db.PublisherMembers.Remove(member); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherMemberLeave, | ||||
|             new Dictionary<string, object> { { "account_id", member.AccountId } }, Request | ||||
|             new Dictionary<string, object> { { "account_id", member.AccountId } }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return NoContent(); | ||||
| @@ -197,13 +206,16 @@ public class PublisherController( | ||||
|         db.PublisherMembers.Remove(member); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherMemberKick, | ||||
|             new Dictionary<string, object> | ||||
|             { | ||||
|                 { "publisher_id", publisher.Id }, | ||||
|                 { "account_id", memberId } | ||||
|             }, Request | ||||
|             }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return NoContent(); | ||||
| @@ -221,8 +233,9 @@ public class PublisherController( | ||||
|  | ||||
|     [HttpPost("individual")] | ||||
|     [Authorize] | ||||
|     [RequiredPermission("global", "publishers.create")] | ||||
|     public async Task<ActionResult<Shared.Models.Publisher>> CreatePublisherIndividual([FromBody] PublisherRequest request) | ||||
|     [DysonNetwork.Shared.Permission.RequiredPermission("global", "publishers.create")] | ||||
|     public async Task<ActionResult<Shared.Models.Publisher>> CreatePublisherIndividual( | ||||
|         [FromBody] PublisherRequest request) | ||||
|     { | ||||
|         if (HttpContext.Items["CurrentUser"] is not Shared.Models.Account currentUser) return Unauthorized(); | ||||
|  | ||||
| @@ -260,9 +273,12 @@ public class PublisherController( | ||||
|             background | ||||
|         ); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherCreate, | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, Request | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return Ok(publisher); | ||||
| @@ -270,7 +286,7 @@ public class PublisherController( | ||||
|  | ||||
|     [HttpPost("organization/{realmSlug}")] | ||||
|     [Authorize] | ||||
|     [RequiredPermission("global", "publishers.create")] | ||||
|     [DysonNetwork.Shared.Permission.RequiredPermission("global", "publishers.create")] | ||||
|     public async Task<ActionResult<Shared.Models.Publisher>> CreatePublisherOrganization(string realmSlug, | ||||
|         [FromBody] PublisherRequest request) | ||||
|     { | ||||
| @@ -315,9 +331,12 @@ public class PublisherController( | ||||
|             background | ||||
|         ); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherCreate, | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, Request | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return Ok(publisher); | ||||
| @@ -393,9 +412,12 @@ public class PublisherController( | ||||
|         db.Update(publisher); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherUpdate, | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, Request | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return Ok(publisher); | ||||
| @@ -431,9 +453,12 @@ public class PublisherController( | ||||
|         db.Publishers.Remove(publisher); | ||||
|         await db.SaveChangesAsync(); | ||||
|  | ||||
|         als.CreateActionLogFromRequest( | ||||
|         await als.CreateActionLogFromRequest( | ||||
|             ActionLogType.PublisherDelete, | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, Request | ||||
|             new Dictionary<string, object> { { "publisher_id", publisher.Id } }, | ||||
|             Request.HttpContext.Connection.RemoteIpAddress?.ToString(), | ||||
|             Request.Headers.UserAgent.ToString(), | ||||
|             currentUser | ||||
|         ); | ||||
|  | ||||
|         return NoContent(); | ||||
| @@ -530,7 +555,7 @@ public class PublisherController( | ||||
|  | ||||
|     [HttpPost("{name}/features")] | ||||
|     [Authorize] | ||||
|     [RequiredPermissionAttribute("maintenance", "publishers.features")] | ||||
|     [DysonNetwork.Shared.Permission.RequiredPermission("maintenance", "publishers.features")] | ||||
|     public async Task<ActionResult<PublisherFeature>> AddPublisherFeature(string name, | ||||
|         [FromBody] PublisherFeatureRequest request) | ||||
|     { | ||||
| @@ -554,7 +579,7 @@ public class PublisherController( | ||||
|  | ||||
|     [HttpDelete("{name}/features/{flag}")] | ||||
|     [Authorize] | ||||
|     [RequiredPermissionAttribute("maintenance", "publishers.features")] | ||||
|     [RequiredPermission("maintenance", "publishers.features")] | ||||
|     public async Task<ActionResult> RemovePublisherFeature(string name, string flag) | ||||
|     { | ||||
|         var publisher = await db.Publishers | ||||
|   | ||||
		Reference in New Issue
	
	Block a user