rename local to incoming
This commit is contained in:
16
smtp/msa.go
16
smtp/msa.go
@@ -19,15 +19,15 @@ type msa struct {
|
||||
mta utils.MTA
|
||||
}
|
||||
|
||||
func (m *msa) newSession(from string, local bool) *msasession {
|
||||
func (m *msa) newSession(from string, incoming bool) *msasession {
|
||||
return &msasession{
|
||||
ctx: sentry.SetHubOnContext(context.Background(), sentry.CurrentHub().Clone()),
|
||||
mta: m.mta,
|
||||
from: from,
|
||||
local: local,
|
||||
log: m.log,
|
||||
bot: m.bot,
|
||||
domain: m.domain,
|
||||
ctx: sentry.SetHubOnContext(context.Background(), sentry.CurrentHub().Clone()),
|
||||
mta: m.mta,
|
||||
from: from,
|
||||
incoming: incoming,
|
||||
log: m.log,
|
||||
bot: m.bot,
|
||||
domain: m.domain,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ type msasession struct {
|
||||
mta utils.MTA
|
||||
domain string
|
||||
|
||||
ctx context.Context
|
||||
local bool
|
||||
to string
|
||||
from string
|
||||
ctx context.Context
|
||||
incoming bool
|
||||
to string
|
||||
from string
|
||||
}
|
||||
|
||||
func (s *msasession) Mail(from string, opts smtp.MailOptions) error {
|
||||
@@ -30,7 +30,7 @@ func (s *msasession) Mail(from string, opts smtp.MailOptions) error {
|
||||
if !utils.AddressValid(from) {
|
||||
return errors.New("please, provide email address")
|
||||
}
|
||||
if s.local {
|
||||
if s.incoming {
|
||||
s.from = from
|
||||
s.log.Debug("mail from %s, options: %+v", from, opts)
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func (s *msasession) Mail(from string, opts smtp.MailOptions) error {
|
||||
func (s *msasession) Rcpt(to string) error {
|
||||
sentry.GetHubFromContext(s.ctx).Scope().SetTag("to", to)
|
||||
|
||||
if s.local {
|
||||
if s.incoming {
|
||||
if utils.Hostname(to) != s.domain {
|
||||
s.log.Debug("wrong domain of %s", to)
|
||||
return smtp.ErrAuthRequired
|
||||
@@ -90,7 +90,7 @@ func (s *msasession) Data(r io.Reader) error {
|
||||
eml.HTML,
|
||||
files)
|
||||
|
||||
return s.bot.Send2Matrix(s.ctx, email, s.local)
|
||||
return s.bot.Send2Matrix(s.ctx, email, s.incoming)
|
||||
}
|
||||
|
||||
func (s *msasession) Reset() {}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
type Bot interface {
|
||||
AllowAuth(string, string) bool
|
||||
GetMapping(string) (id.RoomID, bool)
|
||||
Send2Matrix(ctx context.Context, email *utils.Email, local bool) error
|
||||
Send2Matrix(ctx context.Context, email *utils.Email, incoming bool) error
|
||||
SetMTA(mta utils.MTA)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user