send emails

This commit is contained in:
Aine
2022-09-04 22:09:53 +03:00
parent a92b4c64ae
commit fda0d62087
12 changed files with 489 additions and 42 deletions

View File

@@ -17,17 +17,24 @@ func parseMXIDpatterns(patterns []string, defaultPattern string) ([]*regexp.Rege
return utils.WildcardMXIDsToRegexes(patterns)
}
func (b *Bot) allowAnyone(actorID id.UserID, targetRoomID id.RoomID) bool {
return true
}
func (b *Bot) allowOwner(actorID id.UserID, targetRoomID id.RoomID) bool {
func (b *Bot) allowUsers(actorID id.UserID) bool {
if len(b.allowedUsers) != 0 {
if !utils.Match(actorID.String(), b.allowedUsers) {
return false
}
}
return true
}
func (b *Bot) allowAnyone(actorID id.UserID, targetRoomID id.RoomID) bool {
return true
}
func (b *Bot) allowOwner(actorID id.UserID, targetRoomID id.RoomID) bool {
if !b.allowUsers(actorID) {
return false
}
cfg, err := b.getRoomSettings(targetRoomID)
if err != nil {
b.Error(context.Background(), targetRoomID, "failed to retrieve settings: %v", err)
@@ -45,3 +52,17 @@ func (b *Bot) allowOwner(actorID id.UserID, targetRoomID id.RoomID) bool {
func (b *Bot) allowAdmin(actorID id.UserID, targetRoomID id.RoomID) bool {
return utils.Match(actorID.String(), b.allowedAdmins)
}
func (b *Bot) allowSend(actorID id.UserID, targetRoomID id.RoomID) bool {
if !b.allowUsers(actorID) {
return false
}
cfg, err := b.getRoomSettings(targetRoomID)
if err != nil {
b.Error(context.Background(), targetRoomID, "failed to retrieve settings: %v", err)
return false
}
return !cfg.NoSend()
}