mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-07 20:38:38 +00:00
Show proper author for photos
This commit is contained in:
parent
322c043a51
commit
084dcf1f75
2 changed files with 6 additions and 4 deletions
|
@ -71,7 +71,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpGet("photos/user/{id:int}")]
|
||||
public async Task<IActionResult> SlotPhotos(int id)
|
||||
{
|
||||
List<Photo> photos = await this.database.Photos.Take(10).ToListAsync();
|
||||
List<Photo> photos = await this.database.Photos.Include(p => p.Creator).Take(10).ToListAsync();
|
||||
string response = photos.Aggregate(string.Empty, (s, photo) => s + photo.Serialize(id));
|
||||
return this.Ok(LbpSerializer.StringElement("photos", response));
|
||||
}
|
||||
|
@ -83,7 +83,9 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
if (user == null) return this.NotFound();
|
||||
|
||||
List<Photo> photos = await this.database.Photos.Where(p => p.CreatorId == userFromQuery.UserId)
|
||||
List<Photo> photos = await this.database.Photos.Include
|
||||
(p => p.Creator)
|
||||
.Where(p => p.CreatorId == userFromQuery.UserId)
|
||||
.OrderByDescending(s => s.Timestamp)
|
||||
.Skip(pageStart - 1)
|
||||
.Take(Math.Min(pageSize, 30))
|
||||
|
@ -100,7 +102,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
if (user == null) return this.NotFound();
|
||||
|
||||
List<Photo> photos = new();
|
||||
foreach (Photo photo in this.database.Photos)
|
||||
foreach (Photo photo in this.database.Photos.Include(p => p.Creator))
|
||||
{
|
||||
photos.AddRange(photo.Subjects.Where(subject => subject.User.UserId == userFromQuery.UserId).Select(_ => photo));
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace LBPUnion.ProjectLighthouse.Types
|
|||
LbpSerializer.StringElement("medium", this.MediumHash) +
|
||||
LbpSerializer.StringElement("large", this.LargeHash) +
|
||||
LbpSerializer.StringElement("plan", this.PlanHash) +
|
||||
LbpSerializer.StringElement("author", this.CreatorId) +
|
||||
LbpSerializer.StringElement("author", this.Creator.Username) +
|
||||
LbpSerializer.StringElement("subjects", subjectsAggregate) +
|
||||
slot;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue