using ActivityPub.Utils;
using Microsoft.AspNetCore.Mvc;
namespace ActivityPub.Controllers;
///
/// API endpoint(s) for retrieving objects
///
[Route("")]
[ApiController]
public class ObjectController : ControllerBase
{
///
/// TODO: Temporary Object data store (until I work out the data layer)
///
public static Dictionary> _objects = new();
private readonly ILogger _logger;
///
/// Default constructor
///
/// The logger
public ObjectController(ILogger logger)
{
_logger = logger;
}
///
/// Gets a single object by id
///
/// The type of Object to retrieve (see https://www.w3.org/TR/activitystreams-vocabulary/#object-types)
/// The identifier of the object
/// The requested object, or else 404
[HttpGet("{type}/{id}", Name = "GetObject")]
public IActionResult Get(string type, string id)
{
string properType = Types.Normalize(type);
if (Types.IsObjectOrLink(properType) && _objects.ContainsKey(properType) && _objects[properType].ContainsKey(id.ToLower()))
return this.Ok(_objects[properType][id.ToLower()]);
return NotFound();
}
}