arns-lt-gemini/misfin.go
Arnas Udovic 812af32757
All checks were successful
continuous-integration/drone/push Build is passing
misfin send message #6
2025-03-28 20:54:09 +02:00

38 lines
811 B
Go

package main
import (
"fmt"
"os"
"gitlab.com/clseibold/misfin-server/gemmail"
"gitlab.com/clseibold/misfin-server/misfin_client"
)
const ZORDSDAVINI_MISFIN = "misfin://zordsdavini@arns.lt"
func SendMisfinMessage(body string, recipient string) error {
certFile, err := os.ReadFile("./identities/alkierios_misfin.pem")
if err != nil {
return fmt.Errorf("[Misfin-send] couldn't read misfin certificate: %s", err)
}
client := misfin_client.Client{}
message := gemmail.CreateGemMailFromBody(body)
resp, err := client.SendWithCert(
recipient,
certFile,
certFile,
message.String(),
)
if err != nil {
return fmt.Errorf("[Misfin-send] %s", err)
}
fmt.Printf(
"[Misfin-send] %d %s\n",
resp.Status,
resp.Meta,
) // Should print `20 <fingerprint>` if server is running
return nil
}