readme, nix fixes
This commit is contained in:
parent
aafe3e2d21
commit
64bd10915b
12 changed files with 102 additions and 23 deletions
|
@ -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
|
||||
// }
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue