Skip to content

Commit

Permalink
Merge pull request #140 from matrix-org/test/jme/timeline-event-ffi-o…
Browse files Browse the repository at this point in the history
…bject-to-record

 Adapt the `rust.go` code to the changes in FFI bindings for `EventTimelineItem`
  • Loading branch information
jmartinesp authored Sep 27, 2024
2 parents 047921a + 99febd0 commit 2ea24d0
Showing 1 changed file with 13 additions and 15 deletions.
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)

Check failure on line 909 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

cannot use *ev (variable of type *matrix_sdk_ffi.EventTimelineItem) as matrix_sdk_ffi.EventTimelineItem value in argument to eventTimelineItemToEvent

Check failure on line 909 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

cannot use *ev (variable of type *matrix_sdk_ffi.EventTimelineItem) as matrix_sdk_ffi.EventTimelineItem value in argument to eventTimelineItemToEvent
}

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) {

Check failure on line 914 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

item.EventOrTransactionId undefined (type matrix_sdk_ffi.EventTimelineItem has no field or method EventOrTransactionId)

Check failure on line 914 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

item.EventOrTransactionId undefined (type matrix_sdk_ffi.EventTimelineItem has no field or method EventOrTransactionId)
case matrix_sdk_ffi.EventOrTransactionIdEventId:
eventID = id.EventId
}
complementEvent := api.Event{
ID: eventID,
Sender: item.Sender(),
Sender: item.Sender,

Check failure on line 920 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

cannot use item.Sender (value of type func() string) as string value in struct literal

Check failure on line 920 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

cannot use item.Sender (value of type func() string) as string value in struct literal
}
switch k := item.Content().Kind().(type) {
case matrix_sdk_ffi.TimelineItemContentKindRoomMembership:
switch k := item.Content.(type) {

Check failure on line 922 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

item.Content (value of type func() *matrix_sdk_ffi.TimelineItemContent) is not an interface

Check failure on line 922 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

item.Content (value of type func() *matrix_sdk_ffi.TimelineItemContent) is not an interface
case matrix_sdk_ffi.TimelineItemContentRoomMembership:

Check failure on line 923 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

undefined: matrix_sdk_ffi.TimelineItemContentRoomMembership

Check failure on line 923 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

undefined: 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:

Check failure on line 950 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

undefined: matrix_sdk_ffi.TimelineItemContentUnableToDecrypt

Check failure on line 950 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

undefined: 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) {

Check failure on line 956 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

content (variable of type func() *matrix_sdk_ffi.TimelineItemContent) is not an interface

Check failure on line 956 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

content (variable of type func() *matrix_sdk_ffi.TimelineItemContent) is not an interface
case matrix_sdk_ffi.TimelineItemContentMessage:

Check failure on line 957 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests

undefined: matrix_sdk_ffi.TimelineItemContentMessage

Check failure on line 957 in internal/api/rust/rust.go

View workflow job for this annotation

GitHub Actions / Tests (Rust only, latest) / tests

undefined: matrix_sdk_ffi.TimelineItemContentMessage

complementEvent.Text = msg.Content.Body
}
}
return &complementEvent
Expand Down

0 comments on commit 2ea24d0

Please sign in to comment.