From 143fc96cf579b31f2a8d82cf3f76673dbb6c6232 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 5 Nov 2021 19:05:45 -0400 Subject: [PATCH] Photo retrieval semi-working (only on LBP1?) --- .../Controllers/PhotosController.cs | 12 ++++++++++++ ProjectLighthouse/Controllers/SlotsController.cs | 3 +++ ProjectLighthouse/Helpers/EulaHelper.cs | 2 +- ProjectLighthouse/Types/Photo.cs | 16 ++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse/Controllers/PhotosController.cs b/ProjectLighthouse/Controllers/PhotosController.cs index 5f10e3e5..71a80042 100644 --- a/ProjectLighthouse/Controllers/PhotosController.cs +++ b/ProjectLighthouse/Controllers/PhotosController.cs @@ -1,7 +1,9 @@ +using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -53,5 +55,15 @@ namespace LBPUnion.ProjectLighthouse.Controllers return this.Ok(); } + + [HttpGet("photos/user/{id:int}")] + public async Task SlotPhotos(int id) + { + List photos = await this.database.Photos.Take(50).ToListAsync(); + + string response = photos.Aggregate(string.Empty, (s, photo) => s + photo.Serialize(id)); + + return this.Ok(LbpSerializer.StringElement("photos", response)); + } } } \ No newline at end of file diff --git a/ProjectLighthouse/Controllers/SlotsController.cs b/ProjectLighthouse/Controllers/SlotsController.cs index b74800c5..231967d7 100644 --- a/ProjectLighthouse/Controllers/SlotsController.cs +++ b/ProjectLighthouse/Controllers/SlotsController.cs @@ -42,6 +42,9 @@ namespace LBPUnion.ProjectLighthouse.Controllers return this.Ok(slot.Serialize()); } + [HttpGet("slots/cool")] + public IActionResult CoolSlots([FromQuery] int page) => NewestSlots(30 * page, 30); + [HttpGet("slots")] public IActionResult NewestSlots([FromQuery] int pageStart, [FromQuery] int pageSize) { diff --git a/ProjectLighthouse/Helpers/EulaHelper.cs b/ProjectLighthouse/Helpers/EulaHelper.cs index 8bc167e7..195963c5 100644 --- a/ProjectLighthouse/Helpers/EulaHelper.cs +++ b/ProjectLighthouse/Helpers/EulaHelper.cs @@ -22,6 +22,6 @@ Please do not make anything public for now, and keep in mind security isn't as t // ReSharper disable once UnreachableCode public const string PrivateInstanceNoticeOrBlank = ShowPrivateInstanceNotice ? PrivateInstanceNotice : ""; - public const bool ShowPrivateInstanceNotice = true; + public const bool ShowPrivateInstanceNotice = false; } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/Photo.cs b/ProjectLighthouse/Types/Photo.cs index bd742c2e..8f76675d 100644 --- a/ProjectLighthouse/Types/Photo.cs +++ b/ProjectLighthouse/Types/Photo.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Serialization; namespace LBPUnion.ProjectLighthouse.Types { @@ -51,5 +52,20 @@ namespace LBPUnion.ProjectLighthouse.Types } public string PhotoSubjectCollection { get; set; } + + public string Serialize(int slotId) + { + string slot = LbpSerializer.TaggedStringElement("slot", LbpSerializer.StringElement("id", slotId), "type", "user"); + + string photo = LbpSerializer.StringElement("id", this.PhotoId) + + LbpSerializer.StringElement("small", this.SmallHash) + + LbpSerializer.StringElement("medium", this.MediumHash) + + LbpSerializer.StringElement("large", this.LargeHash) + + LbpSerializer.StringElement("plan", this.PlanHash) + + LbpSerializer.StringElement("author", "a43243221") + + slot; + + return LbpSerializer.TaggedStringElement("photo", photo, "timestamp", Timestamp * 1000); + } } } \ No newline at end of file