Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt the rust.go code to the changes in FFI bindings #140

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions internal/api/rust/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,20 +909,18 @@ 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()
switch id := item.EventOrTransactionId.(type) {
case matrix_sdk_ffi.EventOrTransactionIdEventId:
eventID = id.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 {
Expand All @@ -949,16 +947,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
Expand Down
Loading