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

refactor: making account_link_processor pass through #363

Merged
merged 6 commits into from
Jan 30, 2024
5 changes: 2 additions & 3 deletions core/main/src/firebolt/handlers/discovery_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,10 @@ impl DiscoveryServer for DiscoveryImpl {

async fn watched(&self, context: CallContext, info: WatchedInfo) -> RpcResult<bool> {
info!("Discovery.watched");
let unit = info.get_progress();
let request = WatchedRequest {
context,
info,
unit,
unit: None,
};
if let Ok(response) = self
.state
Expand Down Expand Up @@ -504,7 +503,7 @@ impl DiscoveryServer for DiscoveryImpl {
let request = WatchedRequest {
context: ctx.clone(),
info: watched_info,
unit: ripple_sdk::api::firebolt::fb_discovery::ProgressUnit::WatchNext,
unit: None,
};
if let Ok(response) = self
.state
Expand Down
10 changes: 2 additions & 8 deletions core/main/src/processor/account_link_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use ripple_sdk::{
firebolt::fb_discovery::{
ClearContentSetParams, ContentAccessAvailability, ContentAccessEntitlement,
ContentAccessInfo, ContentAccessListSetParams, ContentAccessRequest, MediaEvent,
MediaEventsAccountLinkRequestParams, ProgressUnit, SessionParams, SignInRequestParams,
MediaEventsAccountLinkRequestParams, SessionParams, SignInRequestParams,
},
gateway::rpc_gateway_api::CallContext,
},
Expand Down Expand Up @@ -264,20 +264,14 @@ impl AccountLinkProcessor {
.await
.is_ok();
}
let progress =
if matches!(request.unit, ProgressUnit::WatchNext) || watched_info.progress > 1.0 {
watched_info.progress
} else {
watched_info.progress * 100.0
};

if let Some(dist_session) = state.session_state.get_account_session() {
let request =
MediaEventRequest::MediaEventAccountLink(MediaEventsAccountLinkRequestParams {
media_event: MediaEvent {
content_id: watched_info.entity_id.to_owned(),
completed: watched_info.completed.unwrap_or(true),
progress,
progress: watched_info.progress,
progress_unit: request.unit.clone(),
watched_on: watched_info.watched_on.clone(),
app_id: ctx.app_id.to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion core/sdk/src/api/account_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum AccountLinkRequest {
pub struct WatchedRequest {
pub context: CallContext,
pub info: WatchedInfo,
pub unit: ProgressUnit,
pub unit: Option<ProgressUnit>,
}

impl ExtnPayloadProvider for AccountLinkRequest {
Expand Down
13 changes: 1 addition & 12 deletions core/sdk/src/api/firebolt/fb_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ pub struct WatchedInfo {
pub watched_on: Option<String>,
}

impl WatchedInfo {
pub fn get_progress(&self) -> ProgressUnit {
if self.progress.ge(&1.0) {
ProgressUnit::Percent
} else {
ProgressUnit::Seconds
}
}
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct WatchNextInfo {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -326,15 +316,14 @@ pub struct DiscoveryEntitlement {
pub enum ProgressUnit {
Seconds,
Percent,
WatchNext,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MediaEvent {
pub content_id: String,
pub completed: bool,
pub progress: f32,
pub progress_unit: ProgressUnit,
pub progress_unit: Option<ProgressUnit>,
pub watched_on: Option<String>,
pub app_id: String,
}
Expand Down
Loading