Accept tags to patch event
This commit is contained in:
@ -12,4 +12,7 @@ public class PatchEvent
|
|||||||
|
|
||||||
[JsonProperty("image")]
|
[JsonProperty("image")]
|
||||||
public string Image { get; init; } = null!;
|
public string Image { get; init; } = null!;
|
||||||
|
|
||||||
|
[JsonProperty("tags")]
|
||||||
|
public string[] Tags { get; init; } = Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class NostrController : Controller
|
|||||||
var pubkey = GetPubKey();
|
var pubkey = GetPubKey();
|
||||||
if (string.IsNullOrEmpty(pubkey)) return Unauthorized();
|
if (string.IsNullOrEmpty(pubkey)) return Unauthorized();
|
||||||
|
|
||||||
await _streamManager.PatchEvent(pubkey, req.Title, req.Summary, req.Image);
|
await _streamManager.PatchEvent(pubkey, req.Title, req.Summary, req.Image, req.Tags);
|
||||||
return Accepted();
|
return Accepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ public class StreamManager
|
|||||||
_logger.LogInformation("Stream consumed {n} seconds for {pubkey} costing {cost} sats", duration, user.PubKey, cost);
|
_logger.LogInformation("Stream consumed {n} seconds for {pubkey} costing {cost} sats", duration, user.PubKey, cost);
|
||||||
if (user.Balance >= balanceAlertThreshold && user.Balance - cost < balanceAlertThreshold)
|
if (user.Balance >= balanceAlertThreshold && user.Balance - cost < balanceAlertThreshold)
|
||||||
{
|
{
|
||||||
_nostr.Send(new NostrEventRequest(CreateStreamChat(user, $"Your balance is below {balanceAlertThreshold} sats, please topup")));
|
_nostr.Send(new NostrEventRequest(CreateStreamChat(user,
|
||||||
|
$"Your balance is below {balanceAlertThreshold} sats, please topup")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Balance <= 0)
|
if (user.Balance <= 0)
|
||||||
@ -81,7 +82,7 @@ public class StreamManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PatchEvent(string pubkey, string? title, string? summary, string? image)
|
public async Task PatchEvent(string pubkey, string? title, string? summary, string? image, string[]? tags)
|
||||||
{
|
{
|
||||||
var user = await _db.Users.SingleOrDefaultAsync(a => a.PubKey == pubkey);
|
var user = await _db.Users.SingleOrDefaultAsync(a => a.PubKey == pubkey);
|
||||||
if (user == default) throw new Exception("User not found");
|
if (user == default) throw new Exception("User not found");
|
||||||
@ -89,6 +90,7 @@ public class StreamManager
|
|||||||
user.Title = title;
|
user.Title = title;
|
||||||
user.Summary = summary;
|
user.Summary = summary;
|
||||||
user.Image = image;
|
user.Image = image;
|
||||||
|
user.Tags = string.Join(",", tags ?? Array.Empty<string>());
|
||||||
|
|
||||||
var existingEvent = user.Event != default ? JsonConvert.DeserializeObject<NostrEvent>(user.Event, NostrSerializer.Settings) : null;
|
var existingEvent = user.Event != default ? JsonConvert.DeserializeObject<NostrEvent>(user.Event, NostrSerializer.Settings) : null;
|
||||||
var ev = CreateStreamEvent(user, existingEvent?.Tags?.FindFirstTagValue("status") ?? "ended");
|
var ev = CreateStreamEvent(user, existingEvent?.Tags?.FindFirstTagValue("status") ?? "ended");
|
||||||
|
Reference in New Issue
Block a user