add noreplies option
This commit is contained in:
@@ -104,6 +104,8 @@ If you want to change them - check available options in the help message (`!pm h
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
* **!pm nosend** - Get or set `nosend` of the room (`true` - disable email sending; `false` - enable email sending)
|
||||||
|
* **!pm noreplies** - Get or set `noreplies` of the room (`true` - ignore matrix replies; `false` - parse matrix replies)
|
||||||
* **!pm nosender** - Get or set `nosender` of the room (`true` - hide email sender; `false` - show email sender)
|
* **!pm nosender** - Get or set `nosender` of the room (`true` - hide email sender; `false` - show email sender)
|
||||||
* **!pm norecipient** - Get or set `norecipient` of the room (`true` - hide recipient; `false` - show recipient)
|
* **!pm norecipient** - Get or set `norecipient` of the room (`true` - hide recipient; `false` - show recipient)
|
||||||
* **!pm nocc** - Get or set `nocc` of the room (`true` - hide CC; `false` - show CC)
|
* **!pm nocc** - Get or set `nocc` of the room (`true` - hide CC; `false` - show CC)
|
||||||
|
|||||||
@@ -73,6 +73,20 @@ func (b *Bot) allowSend(actorID id.UserID, targetRoomID id.RoomID) bool {
|
|||||||
return !cfg.NoSend()
|
return !cfg.NoSend()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bot) allowReply(actorID id.UserID, targetRoomID id.RoomID) bool {
|
||||||
|
if !b.allowUsers(actorID) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg, err := b.cfg.GetRoom(targetRoomID)
|
||||||
|
if err != nil {
|
||||||
|
b.Error(sentry.SetHubOnContext(context.Background(), sentry.CurrentHub()), targetRoomID, "failed to retrieve settings: %v", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return !cfg.NoReplies()
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Bot) isReserved(mailbox string) bool {
|
func (b *Bot) isReserved(mailbox string) bool {
|
||||||
for _, reserved := range b.mbxc.Reserved {
|
for _, reserved := range b.mbxc.Reserved {
|
||||||
if mailbox == reserved {
|
if mailbox == reserved {
|
||||||
|
|||||||
@@ -104,6 +104,15 @@ func (b *Bot) initCommands() commandList {
|
|||||||
sanitizer: utils.SanitizeBoolString,
|
sanitizer: utils.SanitizeBoolString,
|
||||||
allowed: b.allowOwner,
|
allowed: b.allowOwner,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: config.RoomNoReplies,
|
||||||
|
description: fmt.Sprintf(
|
||||||
|
"Get or set `%s` of the room (`true` - ignore matrix replies; `false` - parse matrix replies)",
|
||||||
|
config.RoomNoReplies,
|
||||||
|
),
|
||||||
|
sanitizer: utils.SanitizeBoolString,
|
||||||
|
allowed: b.allowOwner,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: config.RoomNoSender,
|
key: config.RoomNoSender,
|
||||||
description: fmt.Sprintf(
|
description: fmt.Sprintf(
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const (
|
|||||||
RoomMailbox = "mailbox"
|
RoomMailbox = "mailbox"
|
||||||
RoomDomain = "domain"
|
RoomDomain = "domain"
|
||||||
RoomNoSend = "nosend"
|
RoomNoSend = "nosend"
|
||||||
|
RoomNoReplies = "noreplies"
|
||||||
RoomNoCC = "nocc"
|
RoomNoCC = "nocc"
|
||||||
RoomNoSender = "nosender"
|
RoomNoSender = "nosender"
|
||||||
RoomNoRecipient = "norecipient"
|
RoomNoRecipient = "norecipient"
|
||||||
@@ -69,6 +70,10 @@ func (s Room) NoSend() bool {
|
|||||||
return utils.Bool(s.Get(RoomNoSend))
|
return utils.Bool(s.Get(RoomNoSend))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s Room) NoReplies() bool {
|
||||||
|
return utils.Bool(s.Get(RoomNoReplies))
|
||||||
|
}
|
||||||
|
|
||||||
func (s Room) NoCC() bool {
|
func (s Room) NoCC() bool {
|
||||||
return utils.Bool(s.Get(RoomNoCC))
|
return utils.Bool(s.Get(RoomNoCC))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,9 @@ func (b *Bot) SendEmailReply(ctx context.Context) {
|
|||||||
if !b.allowSend(evt.Sender, evt.RoomID) {
|
if !b.allowSend(evt.Sender, evt.RoomID) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !b.allowReply(evt.Sender, evt.RoomID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
cfg, err := b.cfg.GetRoom(evt.RoomID)
|
cfg, err := b.cfg.GetRoom(evt.RoomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(ctx, evt.RoomID, "cannot retrieve room settings: %v", err)
|
b.Error(ctx, evt.RoomID, "cannot retrieve room settings: %v", err)
|
||||||
|
|||||||
@@ -145,11 +145,16 @@ func (m *Manager) Start() error {
|
|||||||
|
|
||||||
// Stop SMTP server
|
// Stop SMTP server
|
||||||
func (m *Manager) Stop() {
|
func (m *Manager) Stop() {
|
||||||
m.fsw.Stop()
|
err := m.fsw.Stop()
|
||||||
err := m.smtp.Close()
|
if err != nil {
|
||||||
|
m.log.Error("cannot stop filesystem watcher properly: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = m.smtp.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.log.Error("cannot stop SMTP server properly: %v", err)
|
m.log.Error("cannot stop SMTP server properly: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m.log.Info("SMTP server has been stopped")
|
m.log.Info("SMTP server has been stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user