Timestamps from the API seem to get deserialized wrongly

Đang mở
#29 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java, kotlin
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu với objectMapper được SDK sử dụng để deserialize các phản hồi API V2, sau đó tái hiện vấn đề bằng ví dụ UpdateUsersRequest và các trường createdAt và updatedAt được trả về. Xác nhận đơn vị thời gian được API sử dụng và kiểm tra rằng các timestamp tính bằng microsecond được chuyển đổi thành đúng ngày tháng thay vì tạo ra năm 55808194.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

I will just lead with some example code (it's kotlin, hope its okay, but the gist should be clear)

fun main() {
  val client = StreamSDKClient()
  val updateUsersRequest = UpdateUsersRequest().apply {
    users = mapOf("test" to UserRequest().apply {
      id = "tester"
      name = "Tester"
    })
  }
  client.updateUsers(
    updateUsersRequest
  ).execute().data.users.forEach {
    println(it)
  }
}

The output looks like this:

tester=FullUserResponse(banned=false, createdAt=Thu May 22 23:25:49 CEST 55808194, id=tester, invisible=false, language=, online=false, role=user, shadowBanned=false, totalUnreadCount=0, unreadChannels=0, unreadCount=0, unreadThreads=0, updatedAt=Thu May 22 23:25:49 CEST 55808194, blockedUserIds=[], channelMutes=[], devices=[], mutes=[], teams=[], custom={}, avgResponseTime=null, banExpires=null, deactivatedAt=null, deletedAt=null, image=null, lastActive=null, name=Tester, revokeTokensIssuedBefore=null, latestHiddenChannels=null, privacySettings=null, teamsRole=null)

As you see, the date is completely off: createdAt=Thu May 22 23:25:49 CEST 55808194 which is (roughly, maybe due to precission issues) the value if you multiply the current timestamp with 1e6.

The reasons seems to be that the V2 api responds with timestamps in microseconds resulution (e.g. 1761074344387549000), but the objectMapper the SDK is using to deserialize the response is not configured to understand these timestamps.

It's not a grave issue for us since we are not using this timestamp. I just noticed and thought I should share.

Ngôn ngữ chính
Java
Star
3
Fork
2
Merge trung bình
4 giờ 31 phút
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GetStream/stream-sdk-java

Tất cả issue của GetStream/stream-sdk-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.