mirror of
https://github.com/studiokaiji/nostr-webhost.git
synced 2025-12-17 06:44:28 +01:00
通常イベントをneventでアクセスできるようにした
This commit is contained in:
@@ -24,14 +24,32 @@ func Start(port string) {
|
||||
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/e/:idHex", func(ctx *gin.Context) {
|
||||
// IDを取得
|
||||
id := ctx.Param("idHex")
|
||||
r.GET("/e/:hex_or_nevent", func(ctx *gin.Context) {
|
||||
hexOrNevent := ctx.Param("hex_or_nevent")
|
||||
|
||||
ids := []string{}
|
||||
|
||||
// neventからIDを取得
|
||||
if hexOrNevent[0:6] == "nevent" {
|
||||
_, res, err := nip19.Decode(hexOrNevent)
|
||||
if err != nil {
|
||||
ctx.String(http.StatusBadRequest, "Invalid nevent")
|
||||
return
|
||||
}
|
||||
|
||||
data, ok := res.(nostr.EventPointer)
|
||||
if !ok {
|
||||
ctx.String(http.StatusBadRequest, "Failed to decode nevent")
|
||||
return
|
||||
}
|
||||
|
||||
ids = append(ids, data.ID)
|
||||
}
|
||||
|
||||
// Poolからデータを取得する
|
||||
ev := pool.QuerySingle(ctx, allRelays, nostr.Filter{
|
||||
Kinds: []int{consts.KindWebhostHTML, consts.KindWebhostCSS, consts.KindWebhostJS, consts.KindWebhostPicture},
|
||||
IDs: []string{id},
|
||||
IDs: ids,
|
||||
})
|
||||
if ev != nil {
|
||||
switch ev.Kind {
|
||||
|
||||
Reference in New Issue
Block a user