Bug fixes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Kieran 2024-01-10 11:18:53 +00:00
parent 1360753d15
commit 55223c3bb7
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
3 changed files with 18 additions and 5 deletions

View File

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Nostr.Client.Json;
using Nostr.Client.Messages;
using NostrServices.Services;
@ -14,13 +16,24 @@ public class ImportController : Controller
_redisStore = redisStore;
}
/// <summary>
/// Import events in ND-JSON format
/// </summary>
/// <returns></returns>
[HttpPost]
[Consumes("text/json", "application/json")]
public async Task<IActionResult> ImportEvent([FromBody] NostrEvent ev)
public async Task<IActionResult> ImportEvent()
{
if (await _redisStore.StoreEvent(CompactEvent.FromNostrEvent(ev)))
var cts = HttpContext.RequestAborted;
using var sr = new StreamReader(Request.Body);
while (await sr.ReadLineAsync(cts) is { } line)
{
return Accepted();
var ev = JsonConvert.DeserializeObject<NostrEvent>(line, NostrSerializer.Settings);
if (ev != default)
{
await _redisStore.StoreEvent(CompactEvent.FromNostrEvent(ev));
}
}
return Ok();

View File

@ -55,7 +55,7 @@ public class OpenGraphController : Controller
{
try
{
if (nid!.Hrp is "nevent" or "note")
if (nid!.Hrp is "nevent" or "note" or "naddr")
{
var ev = await _redisStore.GetEvent(nid);
if (ev != default)

View File

@ -39,7 +39,7 @@ public class RedisStore
return await _database.GetAsync<CompactProfile>(ProfileKey(id));
}
private string EventKey(NostrIdentifier id) => $"event:{id}";
private string EventKey(NostrIdentifier id) => $"event:{id.ToBech32()}";
private string ProfileKey(string id) => $"profile:{id}";
}