diff --git a/config/bridge.go b/config/bridge.go index 073c68c..32260c8 100644 --- a/config/bridge.go +++ b/config/bridge.go @@ -193,10 +193,10 @@ type PermissionConfig map[string]PermissionLevel type PermissionLevel int const ( - PermissionLevelDefault PermissionLevel = 0 - PermissionLevelRelaybot PermissionLevel = 5 - PermissionLevelUser PermissionLevel = 10 - PermissionLevelAdmin PermissionLevel = 100 + PermissionLevelDefault PermissionLevel = 0 + PermissionLevelRelay PermissionLevel = 5 + PermissionLevelUser PermissionLevel = 10 + PermissionLevelAdmin PermissionLevel = 100 ) func (pc *PermissionConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { @@ -211,8 +211,8 @@ func (pc *PermissionConfig) UnmarshalYAML(unmarshal func(interface{}) error) err } for key, value := range rawPC { switch strings.ToLower(value) { - case "relaybot": - (*pc)[key] = PermissionLevelRelaybot + case "relaybot", "relay": + (*pc)[key] = PermissionLevelRelay case "user": (*pc)[key] = PermissionLevelUser case "admin": @@ -236,8 +236,8 @@ func (pc *PermissionConfig) MarshalYAML() (interface{}, error) { rawPC := make(map[string]string) for key, value := range *pc { switch value { - case PermissionLevelRelaybot: - rawPC[key] = "relaybot" + case PermissionLevelRelay: + rawPC[key] = "relay" case PermissionLevelUser: rawPC[key] = "user" case PermissionLevelAdmin: @@ -249,8 +249,8 @@ func (pc *PermissionConfig) MarshalYAML() (interface{}, error) { return rawPC, nil } -func (pc PermissionConfig) IsRelaybotWhitelisted(userID id.UserID) bool { - return pc.GetPermissionLevel(userID) >= PermissionLevelRelaybot +func (pc PermissionConfig) IsRelayWhitelisted(userID id.UserID) bool { + return pc.GetPermissionLevel(userID) >= PermissionLevelRelay } func (pc PermissionConfig) IsWhitelisted(userID id.UserID) bool { diff --git a/example-config.yaml b/example-config.yaml index 1eed183..52c20b9 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -204,7 +204,7 @@ bridge: # Permissions for using the bridge. # Permitted values: - # relaybot - Talk through the relaybot (if enabled), no access otherwise + # relay - Talk through the relaybot (if enabled), no access otherwise # user - Access to use the bridge to chat with a WhatsApp account. # admin - User level and some additional administration tools # Permitted keys: @@ -212,7 +212,7 @@ bridge: # domain - All users on that homeserver # mxid - Specific user permissions: - "*": relaybot + "*": relay "example.com": user "@admin:example.com": admin diff --git a/matrix.go b/matrix.go index 971d998..92869bd 100644 --- a/matrix.go +++ b/matrix.go @@ -320,7 +320,7 @@ func (mx *MatrixHandler) shouldIgnoreEvent(evt *event.Event) bool { return true } user := mx.bridge.GetUserByMXID(evt.Sender) - if !user.RelaybotWhitelisted { + if !user.RelayWhitelisted { return true } return false diff --git a/provisioning.go b/provisioning.go index 15be72c..eadb10b 100644 --- a/provisioning.go +++ b/provisioning.go @@ -185,11 +185,11 @@ func (prov *ProvisioningAPI) Ping(w http.ResponseWriter, r *http.Request) { } } resp := map[string]interface{}{ - "mxid": user.MXID, - "admin": user.Admin, - "whitelisted": user.Whitelisted, - "relaybot_whitelisted": user.RelaybotWhitelisted, - "whatsapp": wa, + "mxid": user.MXID, + "admin": user.Admin, + "whitelisted": user.Whitelisted, + "relay_whitelisted": user.RelayWhitelisted, + "whatsapp": wa, } jsonResponse(w, http.StatusOK, resp) } diff --git a/user.go b/user.go index 9ed813e..6584f2e 100644 --- a/user.go +++ b/user.go @@ -54,9 +54,9 @@ type User struct { bridge *Bridge log log.Logger - Admin bool - Whitelisted bool - RelaybotWhitelisted bool + Admin bool + Whitelisted bool + RelayWhitelisted bool mgmtCreateLock sync.Mutex connLock sync.Mutex @@ -178,7 +178,7 @@ func (bridge *Bridge) NewUser(dbUser *database.User) *User { historySyncs: make(chan *events.HistorySync, 32), } - user.RelaybotWhitelisted = user.bridge.Config.Bridge.Permissions.IsRelaybotWhitelisted(user.MXID) + user.RelayWhitelisted = user.bridge.Config.Bridge.Permissions.IsRelayWhitelisted(user.MXID) user.Whitelisted = user.bridge.Config.Bridge.Permissions.IsWhitelisted(user.MXID) user.Admin = user.bridge.Config.Bridge.Permissions.IsAdmin(user.MXID) go func() {