diff --git a/stremio-core-protobuf/proto/stremio/core/types/profile.proto b/stremio-core-protobuf/proto/stremio/core/types/profile.proto index 8f8b60d..35dd8bb 100644 --- a/stremio-core-protobuf/proto/stremio/core/types/profile.proto +++ b/stremio-core-protobuf/proto/stremio/core/types/profile.proto @@ -61,6 +61,7 @@ message User{ required google.protobuf.Timestamp date_registered = 6; required google.protobuf.Timestamp last_modified = 7; optional google.protobuf.Timestamp premium_expire = 8; + optional TraktInfo trakt = 9; } message GDPRConsent { @@ -68,4 +69,10 @@ message GDPRConsent { required bool privacy = 2; required bool marketing = 3; optional string from = 4; +} + +message TraktInfo { + required google.protobuf.Timestamp created_at = 1; + required google.protobuf.Timestamp expires_in = 2; + required string access_token = 3; } \ No newline at end of file diff --git a/stremio-core-protobuf/src/bridge/date.rs b/stremio-core-protobuf/src/bridge/date.rs index 0656371..d063dc3 100644 --- a/stremio-core-protobuf/src/bridge/date.rs +++ b/stremio-core-protobuf/src/bridge/date.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, TimeDelta, TimeZone, Utc}; use crate::bridge::{FromProtobuf, ToProtobuf}; use crate::protobuf::google::protobuf::Timestamp; @@ -17,3 +17,12 @@ impl ToProtobuf for DateTime { } } } + +impl ToProtobuf for TimeDelta { + fn to_protobuf(&self, _args: &()) -> Timestamp { + Timestamp { + seconds: self.num_seconds(), + nanos: self.num_nanoseconds().map_or(0, |nanos| nanos as i32), + } + } +} diff --git a/stremio-core-protobuf/src/bridge/profile.rs b/stremio-core-protobuf/src/bridge/profile.rs index b36ead8..8b015f6 100644 --- a/stremio-core-protobuf/src/bridge/profile.rs +++ b/stremio-core-protobuf/src/bridge/profile.rs @@ -3,7 +3,7 @@ use std::convert::TryFrom; use stremio_core::types::api::{LinkAuthKey, LinkCodeResponse}; use stremio_core::types::profile::{ - Auth, FrameRateMatchingStrategy, GDPRConsent, Profile, Settings, User, + Auth, FrameRateMatchingStrategy, GDPRConsent, Profile, Settings, TraktInfo, User, }; use crate::bridge::{FromProtobuf, ToProtobuf}; @@ -138,6 +138,16 @@ impl ToProtobuf for GDPRConsent { } } +impl ToProtobuf for TraktInfo { + fn to_protobuf(&self, _args: &()) -> types::TraktInfo { + types::TraktInfo { + created_at: self.created_at.to_protobuf::(&()), + expires_in: self.expires_in.to_protobuf::(&()), + access_token: self.access_token.clone(), + } + } +} + impl ToProtobuf for User { fn to_protobuf(&self, _args: &()) -> types::User { types::User { @@ -149,6 +159,7 @@ impl ToProtobuf for User { date_registered: self.date_registered.to_protobuf::(&()), last_modified: self.last_modified.to_protobuf::(&()), premium_expire: self.premium_expire.to_protobuf::(&()), + trakt: self.trakt.to_protobuf::(&()), } } }