forked from MirrorHub/mautrix-whatsapp
Add option to disable federation on portal rooms (#362)
This commit is contained in:
parent
79f51af06e
commit
96cf814848
4 changed files with 25 additions and 9 deletions
|
@ -70,6 +70,8 @@ type BridgeConfig struct {
|
|||
|
||||
AllowUserInvite bool `yaml:"allow_user_invite"`
|
||||
|
||||
FederateRooms bool `yaml:"federate_rooms"`
|
||||
|
||||
CommandPrefix string `yaml:"command_prefix"`
|
||||
|
||||
ManagementRoomText struct {
|
||||
|
|
|
@ -165,6 +165,10 @@ bridge:
|
|||
# The prefix for commands. Only required in non-management rooms.
|
||||
command_prefix: "!wa"
|
||||
|
||||
# Whether or not created rooms should have federation enabled.
|
||||
# If false, created portal rooms will never be federated.
|
||||
federate_rooms: true
|
||||
|
||||
# Messages sent upon joining a management room.
|
||||
# Markdown is supported. The defaults are listed below.
|
||||
management_room_text:
|
||||
|
|
19
portal.go
19
portal.go
|
@ -1311,14 +1311,19 @@ func (portal *Portal) CreateMatrixRoom(user *User, groupInfo *types.GroupInfo) e
|
|||
}
|
||||
}
|
||||
|
||||
creationContent := make(map[string]interface{})
|
||||
if !portal.bridge.Config.Bridge.FederateRooms {
|
||||
creationContent["m.federate"] = false
|
||||
}
|
||||
resp, err := intent.CreateRoom(&mautrix.ReqCreateRoom{
|
||||
Visibility: "private",
|
||||
Name: portal.Name,
|
||||
Topic: portal.Topic,
|
||||
Invite: invite,
|
||||
Preset: "private_chat",
|
||||
IsDirect: portal.IsPrivateChat(),
|
||||
InitialState: initialState,
|
||||
Visibility: "private",
|
||||
Name: portal.Name,
|
||||
Topic: portal.Topic,
|
||||
Invite: invite,
|
||||
Preset: "private_chat",
|
||||
IsDirect: portal.IsPrivateChat(),
|
||||
InitialState: initialState,
|
||||
CreationContent: creationContent,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
9
user.go
9
user.go
|
@ -181,9 +181,14 @@ func (user *User) GetManagementRoom() id.RoomID {
|
|||
if len(user.ManagementRoom) > 0 {
|
||||
return user.ManagementRoom
|
||||
}
|
||||
creationContent := make(map[string]interface{})
|
||||
if !user.bridge.Config.Bridge.FederateRooms {
|
||||
creationContent["m.federate"] = false
|
||||
}
|
||||
resp, err := user.bridge.Bot.CreateRoom(&mautrix.ReqCreateRoom{
|
||||
Topic: "WhatsApp bridge notices",
|
||||
IsDirect: true,
|
||||
Topic: "WhatsApp bridge notices",
|
||||
IsDirect: true,
|
||||
CreationContent: creationContent,
|
||||
})
|
||||
if err != nil {
|
||||
user.log.Errorln("Failed to auto-create management room:", err)
|
||||
|
|
Loading…
Reference in a new issue