Skip to content

Commit

Permalink
Clean up old feature flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Syfaro committed Jun 1, 2024
1 parent 5f3b231 commit 8bf398f
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 34 deletions.
8 changes: 0 additions & 8 deletions src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,10 @@ struct AdminOverview {
linked_accounts: i64,
total_filesize: i64,
recent_media: i64,

ingest_rate_graph: bool,
}

#[get("", name = "admin_overview")]
async fn admin_overview(
unleash: web::Data<crate::Unleash>,
conn: web::Data<sqlx::PgPool>,
request: actix_web::HttpRequest,
user: models::User,
Expand All @@ -94,11 +91,6 @@ async fn admin_overview(
linked_accounts: stats.linked_accounts,
total_filesize: stats.total_filesize,
recent_media: stats.recent_media,
ingest_rate_graph: unleash.is_enabled(
crate::Features::AdminIngestRate,
Some(&user.context()),
false,
),
}
.wrap_admin(&request, &user)
.await
Expand Down
9 changes: 0 additions & 9 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,13 @@ async fn events(

#[get("/ingest/stats")]
async fn ingest_stats(
unleash: web::Data<crate::Unleash>,
user: models::User,
nats: web::Data<async_nats::Client>,
) -> impl actix_web::Responder {
if !user.is_admin {
return Err(Error::Unauthorized);
}

if !unleash.is_enabled(
crate::Features::AdminIngestRate,
Some(&user.context()),
false,
) {
return Err(Error::Unauthorized);
}

let (tx, rx) = tokio::sync::mpsc::channel::<Result<_, Error>>(10);

tokio::task::spawn_local(
Expand Down
4 changes: 0 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,8 @@ impl<'de> Deserialize<'de> for UrlUuid {

#[derive(Clone, Debug, Serialize, Deserialize, enum_map::Enum)]
enum Features {
#[serde(rename = "fuzzysearch.owo.merge-media")]
MergeMedia,
#[serde(rename = "fuzzysearch.owo.webauthn")]
Webauthn,
#[serde(rename = "fuzzysearch.owo.admin-ingest-rate")]
AdminIngestRate,
}

type Unleash = foxlib::flags::Unleash<Features>;
Expand Down
10 changes: 0 additions & 10 deletions src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,15 +675,13 @@ struct MediaView<'a> {
similar_image_events: &'a [(chrono::DateTime<chrono::Utc>, models::SimilarImage)],
other_events: &'a [models::UserEvent],
allowlisted_users: HashMap<(Site, String), Uuid>,
merge_enabled: bool,
similar_media: Vec<models::OwnedMediaItem>,
}

#[get("/view/{media_id}", name = "media_view")]
async fn media_view(
request: actix_web::HttpRequest,
conn: web::Data<sqlx::PgPool>,
unleash: web::Data<crate::Unleash>,
path: web::Path<(UrlUuid,)>,
user: models::User,
) -> Result<HttpResponse, Error> {
Expand Down Expand Up @@ -735,7 +733,6 @@ async fn media_view(
similar_image_events: &similar_events,
other_events: &other_events,
allowlisted_users,
merge_enabled: unleash.is_enabled(Features::MergeMedia, Some(&user.context()), false),
similar_media,
}
.wrap(&request, Some(&user))
Expand All @@ -749,19 +746,12 @@ async fn media_view(
async fn media_merge(
conn: web::Data<sqlx::PgPool>,
s3: web::Data<rusoto_s3::S3Client>,
unleash: web::Data<crate::Unleash>,
config: web::Data<crate::Config>,
request: actix_web::HttpRequest,
session: actix_session::Session,
user: models::User,
form: web::Form<Vec<(String, String)>>,
) -> Result<HttpResponse, Error> {
if !unleash.is_enabled(Features::MergeMedia, Some(&user.context()), false) {
return Ok(HttpResponse::Found()
.insert_header(("Location", request.url_for_static("user_home")?.as_str()))
.finish());
}

let mut kvs: HashMap<String, Vec<Uuid>> = HashMap::new();
for (name, value) in form.0 {
if let Ok(value_id) = value.parse() {
Expand Down
2 changes: 0 additions & 2 deletions templates/admin/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@
</div>
</div>

{% if ingest_rate_graph %}
<div class="columns is-centered is-desktop">
<div class="column">
<div class="block">
<div id="ingest-stats" style="height: 400px;"></div>
</div>
</div>
</div>
{% endif %}
</div>
2 changes: 1 addition & 1 deletion templates/user/media/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3 class="subtitle has-text-centered absolute-time" data-timestamp="{{ posted_a
</div>
</div>

{% if merge_enabled && !similar_media.is_empty() %}
{% if !similar_media.is_empty() %}
<div class="columns is-centered">
<div class="column is-one-third">
<div class="notification is-info">
Expand Down

0 comments on commit 8bf398f

Please sign in to comment.