From 40715028544fcc9e260131bee53d9a0136fcfbac Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Fri, 23 Jan 2026 16:45:27 +0100 Subject: [PATCH] handletelegram: assign beeper action message content for incoming calls (#132) --- go.mod | 4 ++-- go.sum | 7 ++++--- pkg/connector/handletelegram.go | 25 +++++++++++++++++++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f2932f47..d2558380 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( golang.org/x/sync v0.19.0 golang.org/x/tools v0.41.0 gopkg.in/yaml.v3 v3.0.1 - maunium.net/go/mautrix v0.26.3-0.20260120100901-a55693bbd7c6 + maunium.net/go/mautrix v0.26.3-0.20260123143817-d057f1c6732e rsc.io/qr v0.2.0 ) @@ -65,7 +65,7 @@ require ( github.com/segmentio/asm v1.2.1 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect - github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/match v1.2.0 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect github.com/yuin/goldmark v1.7.16 // indirect diff --git a/go.sum b/go.sum index 9919810a..67a85b30 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,9 @@ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM= +github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -240,7 +241,7 @@ 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.26.3-0.20260120100901-a55693bbd7c6 h1:Xi2JR5xkAs1tdvL/qNYK/koLaPwi8/ZbWAKXOe3q2tI= -maunium.net/go/mautrix v0.26.3-0.20260120100901-a55693bbd7c6/go.mod h1:CUxSZcjPtQNxsZLRQqETAxg2hiz7bjWT+L1HCYoMMKo= +maunium.net/go/mautrix v0.26.3-0.20260123143817-d057f1c6732e h1:lV73mGcvK73DWiAjZY4HBCo/Wr9R5Q8OgQ7U2Giraww= +maunium.net/go/mautrix v0.26.3-0.20260123143817-d057f1c6732e/go.mod h1:CUxSZcjPtQNxsZLRQqETAxg2hiz7bjWT+L1HCYoMMKo= rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= diff --git a/pkg/connector/handletelegram.go b/pkg/connector/handletelegram.go index 4408d487..bccf7cc6 100644 --- a/pkg/connector/handletelegram.go +++ b/pkg/connector/handletelegram.go @@ -471,8 +471,15 @@ func (t *TelegramClient) handleServiceMessage(ctx context.Context, msg *tg.Messa ConvertMessageFunc: func(ctx context.Context, portal *bridgev2.Portal, intent bridgev2.MatrixAPI, data any) (*bridgev2.ConvertedMessage, error) { return &bridgev2.ConvertedMessage{ Parts: []*bridgev2.ConvertedMessagePart{{ - Type: event.EventMessage, - Content: &event.MessageEventContent{MsgType: event.MsgNotice, Body: body}, + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: body, + BeeperActionMessage: &event.BeeperActionMessage{ + Type: event.BeeperActionMessageCall, + CallType: event.BeeperActionMessageCallTypeVideo, + }, + }, }}, }, nil }, @@ -1335,11 +1342,14 @@ func (t *TelegramClient) onPhoneCall(ctx context.Context, e tg.Entities, update return nil } + var callType event.BeeperActionMessageCallType var body strings.Builder body.WriteString("Started a ") if call.Video { + callType = event.BeeperActionMessageCallTypeVideo body.WriteString("video call") } else { + callType = event.BeeperActionMessageCallTypeVoice body.WriteString("call") } res := t.main.Bridge.QueueRemoteEvent(t.userLogin, &simplevent.Message[any]{ @@ -1354,8 +1364,15 @@ func (t *TelegramClient) onPhoneCall(ctx context.Context, e tg.Entities, update return &bridgev2.ConvertedMessage{ Parts: []*bridgev2.ConvertedMessagePart{ { - Type: event.EventMessage, - Content: &event.MessageEventContent{MsgType: event.MsgNotice, Body: body.String()}, + Type: event.EventMessage, + Content: &event.MessageEventContent{ + MsgType: event.MsgNotice, + Body: body.String(), + BeeperActionMessage: &event.BeeperActionMessage{ + Type: event.BeeperActionMessageCall, + CallType: callType, + }, + }, }, }, }, nil