removed federation, closes #12

This commit is contained in:
Aine
2022-08-29 19:58:54 +03:00
parent e52de55e1a
commit 505a1b42d7
6 changed files with 4 additions and 14 deletions

View File

@@ -35,7 +35,6 @@ env vars
<summary>other optional config parameters</summary> <summary>other optional config parameters</summary>
* **POSTMOOGLE_NOOWNER** - allow change room settings by any room partisipant * **POSTMOOGLE_NOOWNER** - allow change room settings by any room partisipant
* **POSTMOOGLE_FEDERATION** - allow usage of Postmoogle by users from others homeservers
* **POSTMOOGLE_NOENCRYPTION** - disable encryption support * **POSTMOOGLE_NOENCRYPTION** - disable encryption support
* **POSTMOOGLE_STATUSMSG** - presence status message * **POSTMOOGLE_STATUSMSG** - presence status message
* **POSTMOOGLE_SENTRY_DSN** - sentry DSN * **POSTMOOGLE_SENTRY_DSN** - sentry DSN

View File

@@ -18,7 +18,6 @@ import (
// Bot represents matrix bot // Bot represents matrix bot
type Bot struct { type Bot struct {
noowner bool noowner bool
federation bool
prefix string prefix string
domain string domain string
allowedUsers []*regexp.Regexp allowedUsers []*regexp.Regexp
@@ -36,14 +35,14 @@ type Bot struct {
func New( func New(
lp *linkpearl.Linkpearl, lp *linkpearl.Linkpearl,
log *logger.Logger, log *logger.Logger,
prefix, domain string, prefix string,
noowner, federation bool, domain string,
noowner bool,
allowedUsers []*regexp.Regexp, allowedUsers []*regexp.Regexp,
allowedAdmins []*regexp.Regexp, allowedAdmins []*regexp.Regexp,
) *Bot { ) *Bot {
b := &Bot{ b := &Bot{
noowner: noowner, noowner: noowner,
federation: federation,
prefix: prefix, prefix: prefix,
domain: domain, domain: domain,
allowedUsers: allowedUsers, allowedUsers: allowedUsers,

View File

@@ -124,11 +124,6 @@ func (b *Bot) handleCommand(ctx context.Context, evt *event.Event, commandSlice
return return
} }
// ignore requests over federation if disabled
if !b.federation && evt.Sender.Homeserver() != b.lp.GetClient().UserID.Homeserver() {
return
}
if !cmd.allowed(evt.Sender, evt.RoomID) { if !cmd.allowed(evt.Sender, evt.RoomID) {
b.SendNotice(ctx, evt.RoomID, "not allowed to do that, kupo") b.SendNotice(ctx, evt.RoomID, "not allowed to do that, kupo")
return return

View File

@@ -87,7 +87,7 @@ func initBot(cfg *config.Config) {
// nolint // Fatal = panic, not os.Exit() // nolint // Fatal = panic, not os.Exit()
log.Fatal("cannot initialize matrix bot: %v", err) log.Fatal("cannot initialize matrix bot: %v", err)
} }
mxb = bot.New(lp, mxlog, cfg.Prefix, cfg.Domain, cfg.NoOwner, cfg.Federation, cfg.Users, cfg.Admins) mxb = bot.New(lp, mxlog, cfg.Prefix, cfg.Domain, cfg.NoOwner, cfg.Users, cfg.Admins)
log.Debug("bot has been created") log.Debug("bot has been created")
} }

View File

@@ -34,7 +34,6 @@ func New() (*Config, error) {
Port: env.String("port", defaultConfig.Port), Port: env.String("port", defaultConfig.Port),
NoEncryption: env.Bool("noencryption"), NoEncryption: env.Bool("noencryption"),
NoOwner: env.Bool("noowner"), NoOwner: env.Bool("noowner"),
Federation: env.Bool("federation"),
MaxSize: env.Int("maxsize", defaultConfig.MaxSize), MaxSize: env.Int("maxsize", defaultConfig.MaxSize),
StatusMsg: env.String("statusmsg", defaultConfig.StatusMsg), StatusMsg: env.String("statusmsg", defaultConfig.StatusMsg),
Users: userPatterns, Users: userPatterns,

View File

@@ -20,8 +20,6 @@ type Config struct {
NoEncryption bool NoEncryption bool
// NoOwner allows room settings change by any participant // NoOwner allows room settings change by any participant
NoOwner bool NoOwner bool
// Federation allows usage of Postmoogle by users from other homeservers
Federation bool
// Prefix for commands // Prefix for commands
Prefix string Prefix string
// MaxSize of an email (including attachments) // MaxSize of an email (including attachments)