Add beeper room type to m.bridge info

This commit is contained in:
Tulir Asokan
2023-01-13 19:35:17 +02:00
parent 70dd119faa
commit 3350692eb0

View File

@@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"reflect"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@@ -253,7 +254,17 @@ func (portal *Portal) MainIntent() *appservice.IntentAPI {
return portal.bridge.Bot return portal.bridge.Bot
} }
func (portal *Portal) getBridgeInfo() (string, event.BridgeEventContent) { type CustomBridgeInfoContent struct {
event.BridgeEventContent
RoomType string `json:"com.beeper.room_type,omitempty"`
}
func init() {
event.TypeMap[event.StateBridge] = reflect.TypeOf(CustomBridgeInfoContent{})
event.TypeMap[event.StateHalfShotBridge] = reflect.TypeOf(CustomBridgeInfoContent{})
}
func (portal *Portal) getBridgeInfo() (string, CustomBridgeInfoContent) {
bridgeInfo := event.BridgeEventContent{ bridgeInfo := event.BridgeEventContent{
BridgeBot: portal.bridge.Bot.UserID, BridgeBot: portal.bridge.Bot.UserID,
Creator: portal.MainIntent().UserID, Creator: portal.MainIntent().UserID,
@@ -284,7 +295,11 @@ func (portal *Portal) getBridgeInfo() (string, event.BridgeEventContent) {
bridgeInfoStateKey = fmt.Sprintf("fi.mau.discord://discord/%s/%s", portal.GuildID, portal.Key.ChannelID) bridgeInfoStateKey = fmt.Sprintf("fi.mau.discord://discord/%s/%s", portal.GuildID, portal.Key.ChannelID)
bridgeInfo.Channel.ExternalURL = fmt.Sprintf("https://discord.com/channels/%s/%s", portal.GuildID, portal.Key.ChannelID) bridgeInfo.Channel.ExternalURL = fmt.Sprintf("https://discord.com/channels/%s/%s", portal.GuildID, portal.Key.ChannelID)
} }
return bridgeInfoStateKey, bridgeInfo var roomType string
if portal.Type == discordgo.ChannelTypeDM || portal.Type == discordgo.ChannelTypeGroupDM {
roomType = "dm"
}
return bridgeInfoStateKey, CustomBridgeInfoContent{bridgeInfo, roomType}
} }
func (portal *Portal) UpdateBridgeInfo() { func (portal *Portal) UpdateBridgeInfo() {