This can be improved in the future, to show some additional information about each mailbox like: - "how many users are in that room" - "which users are in that room" - "who is the owner of the mailbox" This can all be done later though.
42 lines
853 B
Go
42 lines
853 B
Go
package bot
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"maunium.net/go/mautrix/id"
|
|
|
|
"gitlab.com/etke.cc/postmoogle/utils"
|
|
)
|
|
|
|
type accessCheckerFunc func(id.UserID, id.RoomID) (bool, error)
|
|
|
|
func (b *Bot) allowAnyone(actorID id.UserID, targetRoomID id.RoomID) (bool, error) {
|
|
return true, nil
|
|
}
|
|
|
|
func (b *Bot) allowOwner(actorID id.UserID, targetRoomID id.RoomID) (bool, error) {
|
|
if !utils.Match(actorID.String(), b.allowedUsers) {
|
|
return false, nil
|
|
}
|
|
|
|
if b.noowner {
|
|
return true, nil
|
|
}
|
|
|
|
cfg, err := b.getSettings(targetRoomID)
|
|
if err != nil {
|
|
return false, fmt.Errorf("failed to retrieve settings: %v", err)
|
|
}
|
|
|
|
owner := cfg.Owner()
|
|
if owner == "" {
|
|
return true, nil
|
|
}
|
|
|
|
return owner == actorID.String(), nil
|
|
}
|
|
|
|
func (b *Bot) allowAdmin(actorID id.UserID, targetRoomID id.RoomID) (bool, error) {
|
|
return utils.Match(actorID.String(), b.allowedAdmins), nil
|
|
}
|