|
|
|
@ -15,9 +15,9 @@ import (
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/mattn/go-xmpp"
|
|
|
|
|
"github.com/pborman/getopt/v2"
|
|
|
|
|
"mellium.im/xmpp/jid"
|
|
|
|
|
"github.com/mattn/go-xmpp" // BSD-3-Clause
|
|
|
|
|
"github.com/pborman/getopt/v2" // BSD-3-Clause
|
|
|
|
|
"salsa.debian.org/mdosch-guest/gopkg/jid" // BSD-2-Clause
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type configuration struct {
|
|
|
|
@ -27,21 +27,6 @@ type configuration struct {
|
|
|
|
|
password string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check that JIDs include localpart and serverpart
|
|
|
|
|
// and return it marshalled.
|
|
|
|
|
func marshalJID(input string) (string, error) {
|
|
|
|
|
parsedJid, err := jid.Parse(input)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return input, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if parsedJid.Localpart() == "" || parsedJid.Domainpart() == "" {
|
|
|
|
|
return input, errors.New("Invalid JID: " + input)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parsedJid.String(), err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Opens the config file and returns the specified values
|
|
|
|
|
// for username, server and port.
|
|
|
|
|
func parseConfig(configPath string) (configuration, error) {
|
|
|
|
@ -213,7 +198,7 @@ func main() {
|
|
|
|
|
|
|
|
|
|
// Check that all recipient JIDs are valid.
|
|
|
|
|
for i, recipient := range recipients {
|
|
|
|
|
validatedJid, err := marshalJID(recipient)
|
|
|
|
|
validatedJid, err := jid.MarshalJID(recipient)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|