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: def is_direct(cls, value: Union["KnownChannelType", str]) -> bool:
return value in [cls.DirectChat, cls.MemoChat] 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 ChannelType = Union[KnownChannelType, str] # Substitute for ChannelType = "name1" | ... | "nameN" | str

View File

@ -40,6 +40,8 @@ from mautrix.types import (
EventType, EventType,
FileInfo, FileInfo,
ImageInfo, ImageInfo,
JoinRule,
JoinRulesStateEventContent,
LocationMessageEventContent, LocationMessageEventContent,
MediaInfo, MediaInfo,
MediaMessageEventContent, MediaMessageEventContent,
@ -630,6 +632,17 @@ class Portal(DBPortal, BasePortal):
"content": self.bridge_info, "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 = [] invites = []
if self.config["bridge.encryption.default"] and self.matrix.e2ee: if self.config["bridge.encryption.default"] and self.matrix.e2ee:
self.encrypted = True self.encrypted = True