Skip to content

Commit

Permalink
capabilities: add text length limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jan 10, 2025
1 parent d205154 commit 305d849
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
golang.org/x/net v0.34.0
google.golang.org/protobuf v1.36.2
maunium.net/go/mautrix v0.22.2-0.20250110145518-285106586976
maunium.net/go/mautrix v0.22.2-0.20250110154103-bbcb1904e268
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/mautrix v0.22.2-0.20250110145518-285106586976 h1:I06GGTFPiwWTMuLoZCtTg2y9Oc3Qi85MzvS+9fgyCtg=
maunium.net/go/mautrix v0.22.2-0.20250110145518-285106586976/go.mod h1:07i96D7BALyuAqxFhRzvaId8FC9NABgRQBPY5HWndf4=
maunium.net/go/mautrix v0.22.2-0.20250110154103-bbcb1904e268 h1:p+3TofdhqiVYIkLjgzidayg2XriGUEbj+nbWs3/UQbk=
maunium.net/go/mautrix v0.22.2-0.20250110154103-bbcb1904e268/go.mod h1:07i96D7BALyuAqxFhRzvaId8FC9NABgRQBPY5HWndf4=
22 changes: 15 additions & 7 deletions pkg/connector/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ func supportedIfFFmpeg() event.CapabilitySupportLevel {
}

func capID() string {
base := "fi.mau.signal.capabilities.2025_01_10"
base := "fi.mau.signal.capabilities.2025_01_10-2"
if ffmpeg.Supported() {
return base + "+ffmpeg"
}
return base
}

const MaxFileSize = 100 * 1024 * 1024
const MaxTextLength = 2000

var signalCaps = &event.RoomFeatures{
ID: capID(),
Expand Down Expand Up @@ -74,17 +75,21 @@ var signalCaps = &event.RoomFeatures{
"image/png": event.CapLevelFullySupported,
"image/jpeg": event.CapLevelFullySupported,
},
MaxWidth: 4096,
MaxHeight: 4096,
MaxSize: MaxFileSize,
MaxWidth: 4096,
MaxHeight: 4096,
MaxSize: MaxFileSize,
Caption: event.CapLevelFullySupported,
MaxCaptionLength: MaxTextLength,
},
event.MsgVideo: {
MimeTypes: map[string]event.CapabilitySupportLevel{
"video/mp4": event.CapLevelFullySupported,
"video/ogg": event.CapLevelFullySupported,
"video/webm": event.CapLevelFullySupported,
},
MaxSize: MaxFileSize,
MaxSize: MaxFileSize,
Caption: event.CapLevelFullySupported,
MaxCaptionLength: MaxTextLength,
},
event.MsgAudio: {
MimeTypes: map[string]event.CapabilitySupportLevel{
Expand All @@ -97,7 +102,9 @@ var signalCaps = &event.RoomFeatures{
MimeTypes: map[string]event.CapabilitySupportLevel{
"*/*": event.CapLevelFullySupported,
},
MaxSize: MaxFileSize,
MaxSize: MaxFileSize,
Caption: event.CapLevelFullySupported,
MaxCaptionLength: MaxTextLength,
},
event.CapMsgSticker: {
MimeTypes: map[string]event.CapabilitySupportLevel{
Expand All @@ -119,6 +126,7 @@ var signalCaps = &event.RoomFeatures{
MaxDuration: ptr.Ptr(jsontime.S(1 * time.Hour)),
},
},
MaxTextLength: MaxTextLength, // TODO support arbitrary sized text messages with files
LocationMessage: event.CapLevelPartialSupport,
Poll: event.CapLevelRejected,
Thread: event.CapLevelUnsupported,
Expand Down Expand Up @@ -162,5 +170,5 @@ func (s *SignalConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilities
}

func (s *SignalConnector) GetBridgeInfoVersion() (info, capabilities int) {
return 1, 1
return 1, 2
}

0 comments on commit 305d849

Please sign in to comment.