<commit_before>package mmail

import (
	"fmt"
	"net/mail"
	"time"
	"unicode/utf8"

	"github.com/rodcorsi/mattermail/model"
)

const maxMattermostAttachments = 5
const maxMattermostPostSize = 4000

// MatterMail struct with configurations, loggers and Mattemost user
type MatterMail struct {
	cfg          *model.Profile
	log          Logger
	mmProvider   MattermostProvider
	mailProvider MailProvider
}

// PostNetMail parse net/mail.Message and post in Mattermost
func (m *MatterMail) PostNetMail(msg *mail.Message) error {
	mMsg, err := ParseMailMessage(msg)
	if err != nil {
		return err
	}

	return m.PostMailMessage(mMsg)
}

// PostMailMessage MailMessage in Mattermost
func (m *MatterMail) PostMailMessage(msg *MailMessage) error {
	if err := m.mmProvider.Login(); err != nil {
		return err
	}

	defer func() {
		if err := m.mmProvider.Logout(); err != nil {
			m.log.Error("Logout error err:", err.Error())
		}
	}()

	m.log.Info("Post new message")

	mP, err := createMattermostPost(msg, m.cfg, m.log, m.mmProvider.GetChannelID)

	if err != nil {
		return err
	}

	for name, id := range mP.channelMap {<commit_msg>remove mattermost logout error message<commit_after>package mmail

import (
	"fmt"
	"net/mail"
	"time"
	"unicode/utf8"

	"github.com/rodcorsi/mattermail/model"
)

const maxMattermostAttachments = 5
const maxMattermostPostSize = 4000

// MatterMail struct with configurations, loggers and Mattemost user
type MatterMail struct {
	cfg          *model.Profile
	log          Logger
	mmProvider   MattermostProvider
	mailProvider MailProvider
}

// PostNetMail parse net/mail.Message and post in Mattermost
func (m *MatterMail) PostNetMail(msg *mail.Message) error {
	mMsg, err := ParseMailMessage(msg)
	if err != nil {
		return err
	}

	return m.PostMailMessage(mMsg)
}

// PostMailMessage MailMessage in Mattermost
func (m *MatterMail) PostMailMessage(msg *MailMessage) error {
	if err := m.mmProvider.Login(); err != nil {
		return err
	}

	defer func() {
		if err := m.mmProvider.Logout(); err != nil {
			m.log.Error("Logout error err:", err)
		}
	}()

	m.log.Info("Post new message")

	mP, err := createMattermostPost(msg, m.cfg, m.log, m.mmProvider.GetChannelID)

	if err != nil {
		return err
	}

	for name, id := range mP.channelMap {
{'fraction_non_alphanumeric': 0.11376715360779106, 'fraction_numerical': 0.005312084993359893, 'mean_word_length': 3.8290598290598292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5679828', 'n_tokens_mistral': 825, 'n_tokens_neox': 776, 'n_words': 210}