Bug fixes
This commit is contained in:
parent
1360753d15
commit
55223c3bb7
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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}";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user