Skip to content

Commit

Permalink
Use new forbidden default value system in mautrix-python. Fixes #388
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Nov 30, 2019
1 parent 792ed00 commit 578af19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ appservice:
# the HS database.
public:
# Whether or not the public-facing endpoints should be enabled.
enabled: true
enabled: false
# The prefix to use in the public-facing endpoints.
prefix: /public
# The base URL where the public-facing endpoints are available. The prefix is not added
Expand Down
14 changes: 13 additions & 1 deletion mautrix_telegram/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

from mautrix.types import UserID
from mautrix.client import Client
from mautrix.bridge.config import BaseBridgeConfig, ConfigUpdateHelper
from mautrix.bridge.config import (BaseBridgeConfig, ConfigUpdateHelper, ForbiddenKey,
ForbiddenDefault)

Permissions = NamedTuple("Permissions", relaybot=bool, user=bool, puppeting=bool,
matrix_puppeting=bool, admin=bool, level=str)
Expand All @@ -32,6 +33,17 @@ def __getitem__(self, key: str) -> Any:
except KeyError:
return super().__getitem__(key)

@property
def forbidden_defaults(self) -> List[ForbiddenDefault]:
return [
*super().forbidden_defaults,
ForbiddenDefault("appservice.public.external", "https://example.com/public",
condition="appservice.public.enabled"),
ForbiddenDefault("bridge.permissions", ForbiddenKey("example.com")),
ForbiddenDefault("telegram.api_id", 12345),
ForbiddenDefault("telegram.api_hash", "tjyd5yge35lbodk1xwzw2jstp90k55qz"),
]

def do_update(self, helper: ConfigUpdateHelper) -> None:
copy, copy_dict, base = helper

Expand Down

0 comments on commit 578af19

Please sign in to comment.