feat(apiv2): GET endpoints except guilds
- ResolveT methods in ControllerBase - ContextFor methods in ControllerBase
This commit is contained in:
@@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using NodaTime;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
namespace PluralKit.API
|
||||
@@ -28,12 +30,25 @@ namespace PluralKit.API
|
||||
return Ok(o);
|
||||
}
|
||||
|
||||
[HttpGet("messages/{message_id}")]
|
||||
public async Task<IActionResult> MessageGet(ulong message_id)
|
||||
[HttpGet("messages/{messageId}")]
|
||||
public async Task<ActionResult<MessageReturn>> MessageGet(ulong messageId)
|
||||
{
|
||||
return new ObjectResult("Unimplemented")
|
||||
var msg = await _db.Execute(c => _repo.GetMessage(c, messageId));
|
||||
if (msg == null)
|
||||
throw APIErrors.MessageNotFound;
|
||||
|
||||
var ctx = this.ContextFor(msg.System);
|
||||
|
||||
// todo: don't rely on v1 stuff
|
||||
return new MessageReturn
|
||||
{
|
||||
StatusCode = 501
|
||||
Timestamp = Instant.FromUnixTimeMilliseconds((long)(msg.Message.Mid >> 22) + 1420070400000),
|
||||
Id = msg.Message.Mid.ToString(),
|
||||
Channel = msg.Message.Channel.ToString(),
|
||||
Sender = msg.Message.Sender.ToString(),
|
||||
System = msg.System.ToJson(ctx, v: APIVersion.V2),
|
||||
Member = msg.Member.ToJson(ctx, v: APIVersion.V2),
|
||||
Original = msg.Message.OriginalMid?.ToString()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user