diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_feature_flags/edit_user_feature_flags_handler.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_feature_flags/edit_user_feature_flags_handler.rs index 614fb8371b..70a0a67531 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_feature_flags/edit_user_feature_flags_handler.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_feature_flags/edit_user_feature_flags_handler.rs @@ -8,6 +8,7 @@ use actix_web::error::ResponseError; use actix_web::http::StatusCode; use actix_web::web::{Data, Json, Path}; use log::{info, log, warn}; +use r2d2_redis::{r2d2, RedisConnectionManager}; use utoipa::ToSchema; use composite_identifiers::by_table::audit_logs::audit_log_entity::AuditLogEntity; use enums::by_table::audit_logs::audit_log_entity_action::AuditLogEntityAction; @@ -19,6 +20,7 @@ use mysql_queries::queries::users::user::get_user_token_by_username::get_user_to use mysql_queries::queries::users::user::set_user_feature_flags::{set_user_feature_flags, SetUserFeatureFlagArgs}; use mysql_queries::queries::users::user_profiles::get_user_profile_by_token::get_user_profile_by_token; use mysql_queries::queries::users::user_sessions::get_user_session_by_token::get_user_session_by_token; +use redis_caching::redis_ttl_cache::RedisTtlCache; use tokens::tokens::users::UserToken; use users_component::endpoints::get_profile_handler::GetProfilePathInfo; use users_component::session::lookup::user_session_feature_flags::UserSessionFeatureFlags; @@ -113,7 +115,8 @@ pub async fn edit_user_feature_flags_handler( http_request: HttpRequest, path: Path, request: Json, - server_state: Data> + server_state: Data>, + redis_ttl_cache: Data, ) -> Result { let maybe_user_session = server_state @@ -213,5 +216,11 @@ pub async fn edit_user_feature_flags_handler( phantom: Default::default(), }).await; + if let Ok(mut redis) = redis_ttl_cache.get_connection() { + // TODO(bt,2024-04-20): This should be coordinated with other code. + let cache_key = format!("cache:userProfile:{}", user_profile.username); + let _r = redis.delete_from_cache(&cache_key); + } + Ok(simple_json_success()) }