Skip to content

Commit

Permalink
feat: add trakt field to user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Nov 28, 2024
1 parent 952dae9 commit b330179
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions stremio-core-protobuf/proto/stremio/core/types/profile.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ 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 {
required bool tos = 1;
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;
}
11 changes: 10 additions & 1 deletion stremio-core-protobuf/src/bridge/date.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,3 +17,12 @@ impl ToProtobuf<Timestamp, ()> for DateTime<Utc> {
}
}
}

impl ToProtobuf<Timestamp, ()> for TimeDelta {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> Timestamp {
Timestamp {
seconds: self.num_seconds(),
nanos: self.num_nanoseconds().map_or(0, |nanos| nanos as i32),
}
}
}
13 changes: 12 additions & 1 deletion stremio-core-protobuf/src/bridge/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -138,6 +138,16 @@ impl ToProtobuf<types::GdprConsent, ()> for GDPRConsent {
}
}

impl ToProtobuf<types::TraktInfo, ()> for TraktInfo {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::TraktInfo {
types::TraktInfo {
created_at: self.created_at.to_protobuf::<E>(&()),
expires_in: self.expires_in.to_protobuf::<E>(&()),
access_token: self.access_token.clone(),
}
}
}

impl ToProtobuf<types::User, ()> for User {
fn to_protobuf<E: stremio_core::runtime::Env + 'static>(&self, _args: &()) -> types::User {
types::User {
Expand All @@ -149,6 +159,7 @@ impl ToProtobuf<types::User, ()> for User {
date_registered: self.date_registered.to_protobuf::<E>(&()),
last_modified: self.last_modified.to_protobuf::<E>(&()),
premium_expire: self.premium_expire.to_protobuf::<E>(&()),
trakt: self.trakt.to_protobuf::<E>(&()),
}
}
}
Expand Down

0 comments on commit b330179

Please sign in to comment.