readme, nix fixes

This commit is contained in:
41666 2025-03-26 01:03:26 -07:00
parent aafe3e2d21
commit 64bd10915b
12 changed files with 102 additions and 23 deletions

View file

@ -4,7 +4,6 @@ import (
"crypto/ed25519"
"log"
"net/http"
"os"
"github.com/gofiber/fiber/v3"
@ -22,10 +21,6 @@ type Interactions struct {
}
func NewInteractions(publicKey string, guildsService discord.IGuildService) *Interactions {
if publicKey == "" {
publicKey = os.Getenv("DISCORD_PUBLIC_KEY")
}
return &Interactions{
PublicKey: ed25519.PublicKey(publicKey),
Guilds: guildsService,
@ -73,7 +68,6 @@ func (i *Interactions) PostHandler(c fiber.Ctx) error {
return types.NewAPIError(http.StatusNotImplemented, "not implemented").Send(c)
}
func (i *Interactions) Respond(ix Interaction, ir InteractionResponse) error {
// TODO: make request to /webhooks/appid/{ix.Token}
return nil
}
// func (i *Interactions) Respond(ix Interaction, ir InteractionResponse) error {
// i.Guilds
// }

View file

@ -18,15 +18,10 @@ import (
func TestNewInteractions(t *testing.T) {
pub, _, _ := ed25519.GenerateKey(nil)
key := hex.EncodeToString(pub)
t.Setenv("DISCORD_PUBLIC_KEY", key)
gsm := &discord.GuildServiceMock{}
i := interactions.NewInteractions("", gsm)
assert.True(t, i.OK, "interactions OK")
assert.Equal(t, string(i.PublicKey), key, "public key fetched from environment")
i = interactions.NewInteractions(key, gsm)
i := interactions.NewInteractions(key, gsm)
assert.True(t, i.OK, "interactions OK")
assert.Equal(t, string(i.PublicKey), key, "public key accepted from args")
}