From 5945ddc8a010b72adbdd3621cc4b3a16ead78794 Mon Sep 17 00:00:00 2001 From: Aine Date: Tue, 6 Sep 2022 22:16:28 +0300 Subject: [PATCH] rename internal thigs of smtp/ --- smtp/msa.go | 22 +++++++++++----------- smtp/msasession.go | 6 +++--- smtp/mta.go | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/smtp/msa.go b/smtp/msa.go index 887ed66..94922ba 100644 --- a/smtp/msa.go +++ b/smtp/msa.go @@ -14,35 +14,35 @@ import ( type msa struct { log *logger.Logger domain string - client Client + bot Bot } -func (b *msa) newSession() *msasession { +func (m *msa) newSession() *msasession { return &msasession{ ctx: sentry.SetHubOnContext(context.Background(), sentry.CurrentHub().Clone()), - log: b.log, - domain: b.domain, - client: b.client, + log: m.log, + bot: m.bot, + domain: m.domain, } } -func (b *msa) Login(state *smtp.ConnectionState, username, password string) (smtp.Session, error) { +func (m *msa) Login(state *smtp.ConnectionState, username, password string) (smtp.Session, error) { return nil, smtp.ErrAuthUnsupported } -func (b *msa) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) { - return b.newSession(), nil +func (m *msa) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, error) { + return m.newSession(), nil } -func Start(domain, port, loglevel string, maxSize int, client Client) error { +func Start(domain, port, loglevel string, maxSize int, bot Bot) error { log := logger.New("smtp.", loglevel) sender := NewMTA(loglevel) receiver := &msa{ log: log, + bot: bot, domain: domain, - client: client, } - receiver.client.SetMTA(sender) + receiver.bot.SetMTA(sender) s := smtp.NewServer(receiver) s.Addr = ":" + port s.Domain = domain diff --git a/smtp/msasession.go b/smtp/msasession.go index 76e652f..4003717 100644 --- a/smtp/msasession.go +++ b/smtp/msasession.go @@ -14,8 +14,8 @@ import ( type msasession struct { log *logger.Logger + bot Bot domain string - client Client ctx context.Context to string @@ -37,7 +37,7 @@ func (s *msasession) Rcpt(to string) error { return smtp.ErrAuthRequired } - _, ok := s.client.GetMapping(utils.Mailbox(to)) + _, ok := s.bot.GetMapping(utils.Mailbox(to)) if !ok { s.log.Debug("mapping for %s not found", to) return smtp.ErrAuthRequired @@ -84,7 +84,7 @@ func (s *msasession) Data(r io.Reader) error { eml.HTML, files) - return s.client.Send2Matrix(s.ctx, email) + return s.bot.Send2Matrix(s.ctx, email) } func (s *msasession) Reset() {} diff --git a/smtp/mta.go b/smtp/mta.go index 54de3b6..b29ed66 100644 --- a/smtp/mta.go +++ b/smtp/mta.go @@ -15,8 +15,8 @@ import ( "gitlab.com/etke.cc/postmoogle/utils" ) -// Client interface to send emails into matrix -type Client interface { +// Bot interface to send emails into matrix +type Bot interface { GetMapping(string) (id.RoomID, bool) Send2Matrix(ctx context.Context, email *utils.Email) error SetMTA(mta utils.MTA)