Skip to content

Commit

Permalink
show ads on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloose committed Oct 7, 2024
1 parent 1587c90 commit bafc687
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/api/notifications.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rocket::{http::Status, response::status, Route, State};

use crate::core::responses;
use crate::core::types::{ApiResponse, JsonResult};
use crate::core::{guards::IsMobileChecker, responses};
use crate::core::AppState;
use crate::features::notifications;

Expand All @@ -15,8 +15,8 @@ pub fn routes() -> Vec<Route> {
}

#[get("/")]
async fn get_notifications(state: &State<AppState>, is_mobile: IsMobileChecker) -> ApiResponse {
notifications::handlers::get_notifications_handler(state, is_mobile).await
async fn get_notifications(state: &State<AppState>) -> ApiResponse {
notifications::handlers::get_notifications_handler(state).await
}

#[post("/", format = "json", data = "<payload>")]
Expand Down
1 change: 1 addition & 0 deletions src/core/guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl<'r> FromRequest<'r> for IsMobileChecker {
}

impl IsMobileChecker {
#[allow(unused)]
pub fn ask(&self) -> bool {
self.0
}
Expand Down
12 changes: 1 addition & 11 deletions src/features/notifications/handlers/get_notifications.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
use rocket::State;
use serde_json::json;

use crate::core::guards::IsMobileChecker;
use crate::core::types::ApiResponse;
use crate::core::AppState;
use crate::features::flags;
use crate::features::notifications::schemas;

pub async fn get_notifications_handler(
state: &State<AppState>,
is_mobile: IsMobileChecker,
) -> ApiResponse {
if is_mobile.ask() {
// Empty notifications for mobile while we are on review
// TODO: remove
return Ok(json!([]));
}

pub async fn get_notifications_handler(state: &State<AppState>) -> ApiResponse {
let random_order = flags::get_flag(&state.pool, "ads_random_order", true).await;

match random_order {
Expand Down

0 comments on commit bafc687

Please sign in to comment.