Skip to content

Commit 44ddc49

Browse files
committed
capabilities: advertise supported state events and member actions
1 parent 1d320e9 commit 44ddc49

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
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.20251024094209-5d87d14b8858
18+
maunium.net/go/mautrix v0.25.3-0.20251027130059-9f2669025f28
1919
)
2020

2121
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
113113
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
114114
maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
115115
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
116-
maunium.net/go/mautrix v0.25.3-0.20251024094209-5d87d14b8858 h1:w4rgGYjb+lA/AIbyOaUAMDQ6KhxyrTxNxZMPljaXoYw=
117-
maunium.net/go/mautrix v0.25.3-0.20251024094209-5d87d14b8858/go.mod h1:EWgYyp2iFZP7pnSm+rufHlO8YVnA2KnoNBDpwekiAwI=
116+
maunium.net/go/mautrix v0.25.3-0.20251027130059-9f2669025f28 h1:BG0IPWqlVR2mxAQM8jhOhHa168si5iXKeTv11nCGj58=
117+
maunium.net/go/mautrix v0.25.3-0.20251027130059-9f2669025f28/go.mod h1:EWgYyp2iFZP7pnSm+rufHlO8YVnA2KnoNBDpwekiAwI=

pkg/connector/capabilities.go

Lines changed: 20 additions & 0 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"
@@ -161,6 +162,16 @@ var whatsappCaps = &event.RoomFeatures{
161162
MaxSize: WAMaxFileSize,
162163
},
163164
},
165+
State: event.StateFeatureMap{
166+
event.StateRoomName.Type: event.CapLevelFullySupported,
167+
event.StateRoomAvatar.Type: event.CapLevelFullySupported,
168+
event.StateTopic.Type: event.CapLevelFullySupported,
169+
},
170+
MemberActions: event.MemberFeatureMap{
171+
event.MemberActionInvite: event.CapLevelFullySupported,
172+
event.MemberActionKick: event.CapLevelFullySupported,
173+
event.MemberActionLeave: event.CapLevelFullySupported,
174+
},
164175
MaxTextLength: MaxTextLength,
165176
LocationMessage: event.CapLevelFullySupported,
166177
Poll: event.CapLevelFullySupported,
@@ -179,9 +190,16 @@ var whatsappCaps = &event.RoomFeatures{
179190
DeleteChat: true,
180191
}
181192

193+
var whatsappDMCaps *event.RoomFeatures
182194
var whatsappCAGCaps *event.RoomFeatures
183195

184196
func init() {
197+
whatsappDMCaps = ptr.Clone(whatsappCaps)
198+
whatsappDMCaps.ID = capID() + "+dm"
199+
whatsappDMCaps.State = event.StateFeatureMap{
200+
event.StateBeeperDisappearingTimer.Type: event.CapLevelFullySupported,
201+
}
202+
whatsappDMCaps.MemberActions = nil
185203
whatsappCAGCaps = ptr.Clone(whatsappCaps)
186204
whatsappCAGCaps.ID = capID() + "+cag"
187205
whatsappCAGCaps.Reply = event.CapLevelUnsupported
@@ -191,6 +209,8 @@ func init() {
191209
func (wa *WhatsAppClient) GetCapabilities(ctx context.Context, portal *bridgev2.Portal) *event.RoomFeatures {
192210
if portal.Metadata.(*waid.PortalMetadata).CommunityAnnouncementGroup {
193211
return whatsappCAGCaps
212+
} else if portal.RoomType == database.RoomTypeDM {
213+
return whatsappDMCaps
194214
}
195215
return whatsappCaps
196216
}

0 commit comments

Comments
 (0)