Skip to content

Commit

Permalink
Add support for mautrix-gvoice
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 25, 2024
1 parent 304cf80 commit 1569456
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/gitlab/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func getRefFromBridge(bridge string) (string, error) {
switch bridge {
case "imessage":
return "master", nil
case "whatsapp", "discord", "slack", "gmessages", "signal", "imessagego", "meta":
case "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta":
return "main", nil
default:
return "", fmt.Errorf("unknown bridge %s", bridge)
Expand Down Expand Up @@ -165,7 +165,7 @@ func downloadFile(ctx context.Context, artifactURL, path string) error {

func needsLibolmDylib(bridge string) bool {
switch bridge {
case "imessage", "whatsapp", "discord", "slack", "gmessages", "signal", "imessagego", "meta":
case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta":
return runtime.GOOS == "darwin"
default:
return false
Expand Down
3 changes: 3 additions & 0 deletions bridgeconfig/bridgeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type BridgeV2Name struct {
BridgeTypeName string
BridgeTypeIcon string
DefaultPickleKey string

MaxInitialMessages int
MaxBackwardMessages int
}

type Params struct {
Expand Down
4 changes: 2 additions & 2 deletions bridgeconfig/bridgev2.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ backfill:
# Whether to do backfilling at all.
enabled: true
# Maximum number of messages to backfill in empty rooms.
max_initial_messages: 50
max_initial_messages: {{ or .MaxInitialMessages 50 }}
# Maximum number of missed messages to backfill after bridge restarts.
max_catchup_messages: 500
# If a backfilled chat is older than this number of hours,
Expand All @@ -237,7 +237,7 @@ backfill:
# Should the backfill queue be enabled?
enabled: true
# Number of messages to backfill in one batch.
batch_size: 50
batch_size: {{ or .MaxBackwardMessages 50 }}
# Delay between batches in seconds.
batch_delay: 20
# Maximum number of batches to backfill per portal.
Expand Down
15 changes: 15 additions & 0 deletions bridgeconfig/gvoice.tpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Network-specific config options
network:
# Displayname template for SMS users. Available variables:
# .Name (same as phone number in most cases)
# .PhoneNumber
displayname_template: {{ `"{{.Name}}"` }}

{{ setfield . "CommandPrefix" "!gv" -}}
{{ setfield . "DatabaseFileName" "mautrix-gvoice" -}}
{{ setfield . "BridgeTypeName" "Google Voice" -}}
{{ setfield . "BridgeTypeIcon" "mxc://maunium.net/VOPtYGBzHLRfPTEzGgNMpeKo" -}}
{{ setfield . "DefaultPickleKey" "go.mau.fi/mautrix-gvoice" -}}
{{ setfield . "MaxInitialMessages" 10 -}}
{{ setfield . "MaxBackwardMessages" 100 -}}
{{ template "bridgev2.tpl.yaml" . }}
2 changes: 2 additions & 0 deletions cmd/bbctl/bridgeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ var officialBridges = []bridgeTypeToNames{
{"whatsapp", []string{"whatsapp"}},
{"heisenbridge", []string{"irc", "heisenbridge"}},
{"gmessages", []string{"gmessages", "googlemessages", "rcs", "sms"}},
{"gvoice", []string{"gvoice", "googlevoice"}},
}

var websocketBridges = map[string]bool{
"discord": true,
"slack": true,
"whatsapp": true,
"gmessages": true,
"gvoice": true,
"heisenbridge": true,
"imessage": true,
"imessagego": true,
Expand Down
3 changes: 2 additions & 1 deletion cmd/bbctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ var bridgeIPSuffix = map[string]string{
"slack": "35",
"gmessages": "36",
"imessagego": "37",
"gvoice": "38",
}

func doGenerateBridgeConfig(ctx *cli.Context, bridge string) (*generatedBridgeConfig, error) {
Expand Down Expand Up @@ -343,7 +344,7 @@ func generateBridgeConfig(ctx *cli.Context) error {
}
var startupCommand, installInstructions string
switch cfg.BridgeType {
case "imessage", "whatsapp", "discord", "slack", "gmessages", "signal", "meta":
case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "meta":
startupCommand = fmt.Sprintf("mautrix-%s", cfg.BridgeType)
if outputPath != "config.yaml" && outputPath != "<config file>" {
startupCommand += " -c " + outputPath
Expand Down
2 changes: 1 addition & 1 deletion cmd/bbctl/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func runBridge(ctx *cli.Context) error {
var bridgeArgs []string
var needsWebsocketProxy bool
switch cfg.BridgeType {
case "imessage", "imessagego", "whatsapp", "discord", "slack", "gmessages", "signal", "meta":
case "imessage", "imessagego", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "meta":
binaryName := fmt.Sprintf("mautrix-%s", cfg.BridgeType)
ciV2 := false
switch cfg.BridgeType {
Expand Down

0 comments on commit 1569456

Please sign in to comment.