Skip to content

Commit

Permalink
refactor: making account_link_processor pass through (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthick-Somasundaresan authored Jan 30, 2024
1 parent 83b5b1c commit a477061
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
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

0 comments on commit a477061

Please sign in to comment.