dタグをパス形式にした

This commit is contained in:
studiokaiji
2023-10-10 14:56:06 +09:00
parent e374e93644
commit a51cc487a1
2 changed files with 10 additions and 4 deletions

View File

@@ -52,8 +52,7 @@ func pathToKind(path string, replaceable bool) (int, error) {
// Replaceableにする場合のidentifier(dタグ)を取得
func getReplaceableIdentifier(indexHtmlIdentifier, filePath string) string {
encodedFilePath := strings.ReplaceAll(filePath, "/", "_")
return indexHtmlIdentifier + "-" + encodedFilePath
return indexHtmlIdentifier + "/" + filePath[1:]
}
var nostrEventsQueue []*nostr.Event

View File

@@ -3,6 +3,7 @@ package server
import (
"context"
"encoding/base64"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
@@ -98,7 +99,9 @@ func Start(port string) {
})
// Replaceable Event (NIP-33)
r.GET("/p/:pubKey/d/:dTag", func(ctx *gin.Context) {
r.GET("/p/:pubKey/d/*dTag", func(ctx *gin.Context) {
fmt.Println("hi")
// pubKeyを取得しFilterに追加
pubKey := ctx.Param("pubKey")
// npubから始まる場合はデコードする
@@ -113,10 +116,14 @@ func Start(port string) {
authors := []string{pubKey}
// dTagを取得しFilterに追加
dTag := ctx.Param("dTag")
// dTagの最初は`/`ではじまるのでそれをslice
dTag := ctx.Param("dTag")[1:]
tags := nostr.TagMap{}
tags["d"] = []string{dTag}
fmt.Println(dTag)
// Poolからデータを取得する
ev := pool.QuerySingle(ctx, allRelays, nostr.Filter{
Kinds: []int{