Exemplo n.º 1
0
func fixNick(nick string, c adapter.Responder) string {
	uniq := shortuuid.UUID()

	newNick := fmt.Sprintf("%s_%s", nick, uniq)
	logger.Log.Debugf("Fixing nick to %s", nick)

	return newNick[:9] // minimum max length in 9
}
Exemplo n.º 2
0
func uploadFile(fileHeader *multipart.FileHeader, fileUploadPath string) (*File, error) {
	fileName := utils.PrettyFilename(fileHeader.Filename)
	file := &File{}
	file.Name = fileName
	file.UID = shortuuid.UUID()
	folderPath, filePath := file.getPath(fileUploadPath + "original")
	prago.Must(loadFile(folderPath, filePath, fileHeader))
	prago.Must(file.update(fileUploadPath))
	return file, nil
}
Exemplo n.º 3
0
func TestSend(t *testing.T) {
	var cfg SmtpConfig
	_, err := toml.DecodeFile("mailer_test.secret.toml", &cfg)

	if assert.Nil(t, err) {
		mail := Mail{
			From:    randomMailinatorAddress(),
			To:      []string{randomMailinatorAddress()},
			Subject: strings.Join([]string{"Test", shortuuid.UUID()}, "-"),
			Body:    strings.Join([]string{"<h1>", shortuuid.UUID(), "</h1>"}, ""),
		}
		mailer := NewMailer(cfg)
		err = mailer.Send(mail)

		if assert.Nil(t, err) {
			log.Printf("Sent mail %+v", mail)
			// https://api.mailinator.com/api/[email protected]
			// https://api.mailinator.com/api/email?msgid=1448108946-77611349-kquawg
		}
	}
}
Exemplo n.º 4
0
func randomMailinatorAddress() string {
	return strings.Join([]string{shortuuid.UUID(), "@mailinator.com"}, "")
}