Skip to content

Commit e1c3d50

Browse files
committed
capabilities: advertise supported state events and member actions
Closes #858 Closes #856
1 parent 11bd416 commit e1c3d50

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
golang.org/x/sync v0.17.0
1616
google.golang.org/protobuf v1.36.10
1717
gopkg.in/yaml.v3 v3.0.1
18-
maunium.net/go/mautrix v0.25.3-0.20251025135936-d486dba9271c
18+
maunium.net/go/mautrix v0.25.3-0.20251027163910-adc035b6a555
1919
)
2020

2121
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
111111
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
112112
maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
113113
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
114-
maunium.net/go/mautrix v0.25.3-0.20251025135936-d486dba9271c h1:3mRJUCCMc9QDpXVZToqKuQNoCFABldGae0HFxiuCBzE=
115-
maunium.net/go/mautrix v0.25.3-0.20251025135936-d486dba9271c/go.mod h1:EWgYyp2iFZP7pnSm+rufHlO8YVnA2KnoNBDpwekiAwI=
114+
maunium.net/go/mautrix v0.25.3-0.20251027163910-adc035b6a555 h1:6D/kRJyT+5+RRnJErNNglVwDMYU6EwQN0bRYqcdkfZw=
115+
maunium.net/go/mautrix v0.25.3-0.20251027163910-adc035b6a555/go.mod h1:EWgYyp2iFZP7pnSm+rufHlO8YVnA2KnoNBDpwekiAwI=

pkg/connector/capabilities.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"go.mau.fi/util/jsontime"
99
"go.mau.fi/util/ptr"
1010
"maunium.net/go/mautrix/bridgev2"
11+
"maunium.net/go/mautrix/bridgev2/database"
1112
"maunium.net/go/mautrix/event"
1213

1314
"go.mau.fi/mautrix-whatsapp/pkg/waid"
@@ -50,7 +51,7 @@ func (wa *WhatsAppConnector) GetCapabilities() *bridgev2.NetworkGeneralCapabilit
5051
}
5152

5253
func (wa *WhatsAppConnector) GetBridgeInfoVersion() (info, caps int) {
53-
return 1, 5
54+
return 1, 6
5455
}
5556

5657
const WAMaxFileSize = 2000 * 1024 * 1024
@@ -65,7 +66,7 @@ func supportedIfFFmpeg() event.CapabilitySupportLevel {
6566
}
6667

6768
func capID() string {
68-
base := "fi.mau.whatsapp.capabilities.2025_10_07"
69+
base := "fi.mau.whatsapp.capabilities.2025_10_27"
6970
if ffmpeg.Supported() {
7071
return base + "+ffmpeg"
7172
}
@@ -161,6 +162,17 @@ var whatsappCaps = &event.RoomFeatures{
161162
MaxSize: WAMaxFileSize,
162163
},
163164
},
165+
State: event.StateFeatureMap{
166+
event.StateRoomName.Type: {Level: event.CapLevelFullySupported},
167+
event.StateRoomAvatar.Type: {Level: event.CapLevelFullySupported},
168+
event.StateTopic.Type: {Level: event.CapLevelFullySupported},
169+
event.StateBeeperDisappearingTimer.Type: {Level: event.CapLevelFullySupported},
170+
},
171+
MemberActions: event.MemberFeatureMap{
172+
event.MemberActionInvite: event.CapLevelFullySupported,
173+
event.MemberActionKick: event.CapLevelFullySupported,
174+
event.MemberActionLeave: event.CapLevelFullySupported,
175+
},
164176
MaxTextLength: MaxTextLength,
165177
LocationMessage: event.CapLevelFullySupported,
166178
Poll: event.CapLevelFullySupported,
@@ -179,9 +191,16 @@ var whatsappCaps = &event.RoomFeatures{
179191
DeleteChat: true,
180192
}
181193

194+
var whatsappDMCaps *event.RoomFeatures
182195
var whatsappCAGCaps *event.RoomFeatures
183196

184197
func init() {
198+
whatsappDMCaps = ptr.Clone(whatsappCaps)
199+
whatsappDMCaps.ID = capID() + "+dm"
200+
whatsappDMCaps.State = event.StateFeatureMap{
201+
event.StateBeeperDisappearingTimer.Type: {Level: event.CapLevelFullySupported},
202+
}
203+
whatsappDMCaps.MemberActions = nil
185204
whatsappCAGCaps = ptr.Clone(whatsappCaps)
186205
whatsappCAGCaps.ID = capID() + "+cag"
187206
whatsappCAGCaps.Reply = event.CapLevelUnsupported
@@ -191,6 +210,8 @@ func init() {
191210
func (wa *WhatsAppClient) GetCapabilities(ctx context.Context, portal *bridgev2.Portal) *event.RoomFeatures {
192211
if portal.Metadata.(*waid.PortalMetadata).CommunityAnnouncementGroup {
193212
return whatsappCAGCaps
213+
} else if portal.RoomType == database.RoomTypeDM {
214+
return whatsappDMCaps
194215
}
195216
return whatsappCaps
196217
}

0 commit comments

Comments
 (0)