Stream forwarding

This commit is contained in:
2023-12-07 22:46:36 +00:00
parent 1ad5186aff
commit cef1b845bc
17 changed files with 594 additions and 10 deletions

View File

@ -72,7 +72,12 @@ public class NostrController : Controller
{
Accepted = user.TosAccepted >= _config.TosDate,
Link = new Uri(_config.ApiHost, "/tos")
}
},
Forwards = user.Forwards.Select(a => new ForwardDest()
{
Id = a.Id,
Name = a.Name
}).ToList()
};
return Content(JsonConvert.SerializeObject(account, NostrSerializer.Settings), "application/json");
@ -128,6 +133,34 @@ public class NostrController : Controller
return Accepted();
}
[HttpPost("account/forward")]
public async Task<IActionResult> AddForward([FromBody] NewForwardRequest req)
{
var user = await GetUser();
if (user == default)
{
return NotFound();
}
await _userService.AddForward(user.PubKey, req.Name, req.Target);
return Accepted();
}
[HttpDelete("account/forward/{id:guid}")]
public async Task<IActionResult> DeleteForward([FromRoute] Guid id)
{
var user = await GetUser();
if (user == default)
{
return NotFound();
}
await _userService.RemoveForward(user.PubKey, id);
return Ok();
}
private async Task<User?> GetUser()
{
var pk = GetPubKey();