From 7eb47907370dffd9ab83f97f01b1f9e0b86a6cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Wed, 25 Sep 2024 12:40:06 +0200 Subject: [PATCH 1/2] Adapt FFI bindings --- internal/api/rust/rust.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/internal/api/rust/rust.go b/internal/api/rust/rust.go index 13228fe..5c099d5 100644 --- a/internal/api/rust/rust.go +++ b/internal/api/rust/rust.go @@ -909,20 +909,17 @@ func timelineItemToEvent(item *matrix_sdk_ffi.TimelineItem) *api.Event { return eventTimelineItemToEvent(*ev) } -func eventTimelineItemToEvent(item *matrix_sdk_ffi.EventTimelineItem) *api.Event { - if item == nil { - return nil - } +func eventTimelineItemToEvent(item matrix_sdk_ffi.EventTimelineItem) *api.Event { eventID := "" - if item.EventId() != nil { - eventID = *item.EventId() + if item.EventId != nil { + eventID = *item.EventId } complementEvent := api.Event{ ID: eventID, - Sender: item.Sender(), + Sender: item.Sender, } - switch k := item.Content().Kind().(type) { - case matrix_sdk_ffi.TimelineItemContentKindRoomMembership: + switch k := item.Content.(type) { + case matrix_sdk_ffi.TimelineItemContentRoomMembership: complementEvent.Target = k.UserId change := *k.Change switch change { @@ -949,16 +946,16 @@ func eventTimelineItemToEvent(item *matrix_sdk_ffi.EventTimelineItem) *api.Event default: fmt.Printf("%s unhandled membership %d\n", k.UserId, change) } - case matrix_sdk_ffi.TimelineItemContentKindUnableToDecrypt: + case matrix_sdk_ffi.TimelineItemContentUnableToDecrypt: complementEvent.FailedToDecrypt = true } - content := item.Content() + content := item.Content if content != nil { - msg := content.AsMessage() - if msg != nil { - msgg := *msg - complementEvent.Text = msgg.Body() + switch msg := content.(type) { + case matrix_sdk_ffi.TimelineItemContentMessage: + + complementEvent.Text = msg.Content.Body } } return &complementEvent From 99febd0f43c4cd856544bd7ba15818908146d61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Fri, 27 Sep 2024 16:29:59 +0200 Subject: [PATCH 2/2] Fix another change in the bindings --- internal/api/rust/rust.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/api/rust/rust.go b/internal/api/rust/rust.go index 5c099d5..55277a1 100644 --- a/internal/api/rust/rust.go +++ b/internal/api/rust/rust.go @@ -911,8 +911,9 @@ func timelineItemToEvent(item *matrix_sdk_ffi.TimelineItem) *api.Event { func eventTimelineItemToEvent(item matrix_sdk_ffi.EventTimelineItem) *api.Event { eventID := "" - if item.EventId != nil { - eventID = *item.EventId + switch id := item.EventOrTransactionId.(type) { + case matrix_sdk_ffi.EventOrTransactionIdEventId: + eventID = id.EventId } complementEvent := api.Event{ ID: eventID,