🐛 Bug fixes and fixes
This commit is contained in:
parent
bf5ae17741
commit
88f9157ff8
@ -223,7 +223,6 @@ public partial class ChatController(AppDatabase db, ChatService cs, ChatRoomServ
|
||||
.Include(m => m.Sender)
|
||||
.Include(m => m.Sender.Account)
|
||||
.Include(m => m.Sender.Account.Profile)
|
||||
.Include(message => message.Attachments)
|
||||
.Include(message => message.ChatRoom)
|
||||
.FirstOrDefaultAsync(m => m.Id == messageId && m.ChatRoomId == roomId);
|
||||
|
||||
|
@ -15,7 +15,7 @@ public enum PublisherType
|
||||
}
|
||||
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Publisher : ModelBase
|
||||
public class Publisher : ModelBase, IIdentifiedResource
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public PublisherType Type { get; set; }
|
||||
@ -41,6 +41,8 @@ public class Publisher : ModelBase
|
||||
public Account.Account? Account { get; set; }
|
||||
public Guid? RealmId { get; set; }
|
||||
[JsonIgnore] public Realm.Realm? Realm { get; set; }
|
||||
|
||||
public string ResourceIdentifier => $"publisher/{Id}";
|
||||
}
|
||||
|
||||
public enum PublisherMemberRole
|
||||
|
@ -13,7 +13,12 @@ namespace DysonNetwork.Sphere.Publisher;
|
||||
|
||||
[ApiController]
|
||||
[Route("/publishers")]
|
||||
public class PublisherController(AppDatabase db, PublisherService ps, FileService fs, FileReferenceService fileRefService, ActionLogService als)
|
||||
public class PublisherController(
|
||||
AppDatabase db,
|
||||
PublisherService ps,
|
||||
FileService fs,
|
||||
FileReferenceService fileRefService,
|
||||
ActionLogService als)
|
||||
: ControllerBase
|
||||
{
|
||||
[HttpGet("{name}")]
|
||||
@ -24,7 +29,7 @@ namespace DysonNetwork.Sphere.Publisher;
|
||||
.FirstOrDefaultAsync();
|
||||
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)
|
||||
@ -349,24 +354,24 @@ namespace DysonNetwork.Sphere.Publisher;
|
||||
var picture = await db.Files.Where(f => f.Id == request.PictureId).FirstOrDefaultAsync();
|
||||
if (picture is null) return BadRequest("Invalid picture id.");
|
||||
|
||||
var publisherResourceId = $"publisher:{publisher.Id}";
|
||||
|
||||
// Remove old references for the publisher picture
|
||||
if (publisher.Picture is not null) {
|
||||
var oldPictureRefs = await fileRefService.GetResourceReferencesAsync(publisherResourceId, "publisher.picture");
|
||||
if (publisher.Picture is not null)
|
||||
{
|
||||
var oldPictureRefs = await fileRefService.GetResourceReferencesAsync(
|
||||
publisher.ResourceIdentifier,
|
||||
"publisher.picture"
|
||||
);
|
||||
foreach (var oldRef in oldPictureRefs)
|
||||
{
|
||||
await fileRefService.DeleteReferenceAsync(oldRef.Id);
|
||||
}
|
||||
}
|
||||
|
||||
publisher.Picture = picture.ToReferenceObject();
|
||||
|
||||
// Create a new reference
|
||||
await fileRefService.CreateReferenceAsync(
|
||||
picture.Id,
|
||||
"publisher.picture",
|
||||
publisherResourceId
|
||||
picture.Id,
|
||||
"publisher.picture",
|
||||
publisher.ResourceIdentifier
|
||||
);
|
||||
}
|
||||
|
||||
@ -378,8 +383,10 @@ namespace DysonNetwork.Sphere.Publisher;
|
||||
var publisherResourceId = $"publisher:{publisher.Id}";
|
||||
|
||||
// Remove old references for the publisher background
|
||||
if (publisher.Background is not null) {
|
||||
var oldBackgroundRefs = await fileRefService.GetResourceReferencesAsync(publisherResourceId, "publisher.background");
|
||||
if (publisher.Background is not null)
|
||||
{
|
||||
var oldBackgroundRefs =
|
||||
await fileRefService.GetResourceReferencesAsync(publisherResourceId, "publisher.background");
|
||||
foreach (var oldRef in oldBackgroundRefs)
|
||||
{
|
||||
await fileRefService.DeleteReferenceAsync(oldRef.Id);
|
||||
@ -390,8 +397,8 @@ namespace DysonNetwork.Sphere.Publisher;
|
||||
|
||||
// Create a new reference
|
||||
await fileRefService.CreateReferenceAsync(
|
||||
background.Id,
|
||||
"publisher.background",
|
||||
background.Id,
|
||||
"publisher.background",
|
||||
publisherResourceId
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user