Set history & join rules to match KakaoTalk behaviour

This commit is contained in:
Andrew Ferrazzutti 2022-04-11 23:45:00 -04:00
parent 2be6a761b6
commit 73f8792b75
2 changed files with 17 additions and 0 deletions

View File

@ -30,6 +30,10 @@ class KnownChannelType(str, Enum):
def is_direct(cls, value: Union["KnownChannelType", str]) -> bool:
return value in [cls.DirectChat, cls.MemoChat]
@classmethod
def is_open(cls, value: Union["KnownChannelType", str]) -> bool:
return value in [cls.OM, cls.OD]
ChannelType = Union[KnownChannelType, str] # Substitute for ChannelType = "name1" | ... | "nameN" | str

View File

@ -40,6 +40,8 @@ from mautrix.types import (
EventType,
FileInfo,
ImageInfo,
JoinRule,
JoinRulesStateEventContent,
LocationMessageEventContent,
MediaInfo,
MediaMessageEventContent,
@ -630,6 +632,17 @@ class Portal(DBPortal, BasePortal):
"content": self.bridge_info,
},
]
if KnownChannelType.is_open(info.channel_info.type):
initial_state.extend((
{
"type": str(EventType.ROOM_JOIN_RULES),
"content": JoinRulesStateEventContent(join_rule=JoinRule.PUBLIC).serialize(),
},
{
"type": "m.room.guest_access",
"content": {"guest_access": "forbidden"},
},
))
invites = []
if self.config["bridge.encryption.default"] and self.matrix.e2ee:
self.encrypted = True