38 lines
811 B
Go
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
|
|
}
|