Photo retrieval semi-working (only on LBP1?)

This commit is contained in:
jvyden 2021-11-05 19:05:45 -04:00
commit 143fc96cf5
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
4 changed files with 32 additions and 1 deletions

View file

@ -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<IActionResult> SlotPhotos(int id)
{
List<Photo> 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));
}
}
}

View file

@ -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)
{

View file

@ -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;
}
}

View file

@ -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);
}
}
}