Merge branch 'main' into feature/custom-emoji-and-tagline-views

This commit is contained in:
SleeplessOne1917 2024-04-05 21:05:51 -04:00 committed by GitHub
commit 55be9a14ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 123 additions and 128 deletions

View file

@ -2,7 +2,7 @@
# See https://github.com/woodpecker-ci/woodpecker/issues/1677
variables:
- &rust_image "rust:1.76"
- &rust_image "rust:1.77"
- &install_pnpm "corepack enable pnpm"
- &slow_check_paths
- event: pull_request
@ -42,7 +42,7 @@ steps:
- git submodule init
- git submodule update
when:
- event: pull_request
- event: [pull_request, tag]
prettier_check:
image: tmknom/prettier:3.0.0
@ -59,7 +59,7 @@ steps:
- event: pull_request
sql_fmt:
image: backplane/pgformatter:latest
image: backplane/pgformatter
commands:
- ./scripts/sql_format_check.sh
when:
@ -248,7 +248,6 @@ steps:
publish_to_crates_io:
image: *rust_image
commands:
- 'echo "pub const VERSION: &str = \"$(git describe --tag)\";" > "crates/utils/src/version.rs"'
- cargo install cargo-workspaces
- cp -r migrations crates/db_schema/
- cargo login "$CARGO_API_TOKEN"
@ -263,7 +262,7 @@ steps:
- apk add curl
- "curl -d'Lemmy CI build failed: ${CI_PIPELINE_URL}' ntfy.sh/lemmy_drone_ci"
when:
- event: pull_request
- event: [pull_request, tag]
status: failure
notify_on_tag_deploy:

27
Cargo.lock generated
View file

@ -2612,7 +2612,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lemmy_api"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"actix-web",
@ -2641,7 +2641,7 @@ dependencies = [
[[package]]
name = "lemmy_api_common"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"actix-web",
@ -2679,7 +2679,7 @@ dependencies = [
[[package]]
name = "lemmy_api_crud"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"accept-language",
"activitypub_federation",
@ -2702,7 +2702,7 @@ dependencies = [
[[package]]
name = "lemmy_apub"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"actix-web",
@ -2740,7 +2740,7 @@ dependencies = [
[[package]]
name = "lemmy_db_perf"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"anyhow",
"clap",
@ -2755,7 +2755,7 @@ dependencies = [
[[package]]
name = "lemmy_db_schema"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"anyhow",
@ -2772,6 +2772,7 @@ dependencies = [
"futures-util",
"i-love-jesus",
"lemmy_utils",
"moka",
"once_cell",
"pretty_assertions",
"regex",
@ -2794,7 +2795,7 @@ dependencies = [
[[package]]
name = "lemmy_db_views"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"actix-web",
"chrono",
@ -2816,7 +2817,7 @@ dependencies = [
[[package]]
name = "lemmy_db_views_actor"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"chrono",
"diesel",
@ -2836,7 +2837,7 @@ dependencies = [
[[package]]
name = "lemmy_db_views_moderator"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"diesel",
"diesel-async",
@ -2848,7 +2849,7 @@ dependencies = [
[[package]]
name = "lemmy_federate"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"anyhow",
@ -2871,7 +2872,7 @@ dependencies = [
[[package]]
name = "lemmy_routes"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"actix-web",
@ -2896,7 +2897,7 @@ dependencies = [
[[package]]
name = "lemmy_server"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"activitypub_federation",
"actix-cors",
@ -2939,7 +2940,7 @@ dependencies = [
[[package]]
name = "lemmy_utils"
version = "0.19.3"
version = "0.19.4-beta.2"
dependencies = [
"actix-web",
"anyhow",

View file

@ -1,5 +1,5 @@
[workspace.package]
version = "0.19.3"
version = "0.19.4-beta.2"
edition = "2021"
description = "A link aggregator for the fediverse"
license = "AGPL-3.0"
@ -88,16 +88,17 @@ unused_self = "deny"
unwrap_used = "deny"
[workspace.dependencies]
lemmy_api = { version = "=0.19.3", path = "./crates/api" }
lemmy_api_crud = { version = "=0.19.3", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.19.3", path = "./crates/apub" }
lemmy_utils = { version = "=0.19.3", path = "./crates/utils", default-features = false }
lemmy_db_schema = { version = "=0.19.3", path = "./crates/db_schema" }
lemmy_api_common = { version = "=0.19.3", path = "./crates/api_common" }
lemmy_routes = { version = "=0.19.3", path = "./crates/routes" }
lemmy_db_views = { version = "=0.19.3", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.19.3", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.19.3", path = "./crates/db_views_moderator" }
lemmy_api = { version = "=0.19.4-beta.2", path = "./crates/api" }
lemmy_api_crud = { version = "=0.19.4-beta.2", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.19.4-beta.2", path = "./crates/apub" }
lemmy_utils = { version = "=0.19.4-beta.2", path = "./crates/utils", default-features = false }
lemmy_db_schema = { version = "=0.19.4-beta.2", path = "./crates/db_schema" }
lemmy_api_common = { version = "=0.19.4-beta.2", path = "./crates/api_common" }
lemmy_routes = { version = "=0.19.4-beta.2", path = "./crates/routes" }
lemmy_db_views = { version = "=0.19.4-beta.2", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.19.4-beta.2", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.19.4-beta.2", path = "./crates/db_views_moderator" }
lemmy_federate = { version = "=0.19.4-beta.2", path = "./crates/federate" }
activitypub_federation = { version = "0.5.2", default-features = false, features = [
"actix-web",
] }
@ -175,7 +176,7 @@ lemmy_utils = { workspace = true }
lemmy_db_schema = { workspace = true }
lemmy_api_common = { workspace = true }
lemmy_routes = { workspace = true }
lemmy_federate = { version = "0.19.3", path = "crates/federate" }
lemmy_federate = { workspace = true }
activitypub_federation = { workspace = true }
diesel = { workspace = true }
diesel-async = { workspace = true }

View file

@ -133,7 +133,6 @@ Lemmy is made possible by a generous grant from the [NLnet foundation](https://n
- bitcoin: `1Hefs7miXS5ff5Ck5xvmjKjXf5242KzRtK`
- ethereum: `0x400c96c96acbC6E7B3B43B1dc1BB446540a88A01`
- monero: `41taVyY6e1xApqKyMVDRVxJ76sPkfZhALLTjRvVKpaAh2pBd4wv9RgYj1tSPrx8wc6iE1uWUfjtQdTmTy2FGMeChGVKPQuV`
- cardano: `addr1q858t89l2ym6xmrugjs0af9cslfwvnvsh2xxp6x4dcez7pf5tushkp4wl7zxfhm2djp6gq60dk4cmc7seaza5p3slx0sakjutm`
## Contributing

View file

@ -15,7 +15,7 @@ use lemmy_db_views::structs::{LocalUserView, SiteView};
use lemmy_db_views_actor::structs::PersonView;
use lemmy_utils::{
error::{LemmyError, LemmyErrorType},
version,
VERSION,
};
#[tracing::instrument(skip(context))]
@ -66,7 +66,7 @@ pub async fn leave_admin(
Ok(Json(GetSiteResponse {
site_view,
admins,
version: version::VERSION.to_string(),
version: VERSION.to_string(),
my_user: None,
all_languages,
discussion_languages,

View file

@ -19,8 +19,8 @@ use lemmy_utils::{
error::{LemmyError, LemmyErrorType},
settings::structs::{PictrsImageMode, Settings},
spawn_try_task,
version::VERSION,
REQWEST_TIMEOUT,
VERSION,
};
use mime::Mime;
use reqwest::{header::CONTENT_TYPE, Client, ClientBuilder};
@ -32,11 +32,7 @@ use urlencoding::encode;
use webpage::HTML;
pub fn client_builder(settings: &Settings) -> ClientBuilder {
let user_agent = format!(
"Lemmy/{}; +{}",
VERSION,
settings.get_protocol_and_hostname()
);
let user_agent = format!("Lemmy/{VERSION}; +{}", settings.get_protocol_and_hostname());
Client::builder()
.user_agent(user_agent.clone())

View file

@ -42,21 +42,18 @@ use lemmy_utils::{
markdown::{markdown_check_for_blocked_urls, markdown_rewrite_image_links},
slurs::{build_slur_regex, remove_slurs},
},
CACHE_DURATION_SHORT,
};
use moka::future::Cache;
use once_cell::sync::Lazy;
use regex::{escape, Regex, RegexSet};
use rosetta_i18n::{Language, LanguageId};
use std::{collections::HashSet, time::Duration};
use std::collections::HashSet;
use tracing::warn;
use url::{ParseError, Url};
use urlencoding::encode;
pub static AUTH_COOKIE_NAME: &str = "jwt";
#[cfg(debug_assertions)]
static URL_BLOCKLIST_RECHECK_DELAY: Duration = Duration::from_millis(500);
#[cfg(not(debug_assertions))]
static URL_BLOCKLIST_RECHECK_DELAY: Duration = Duration::from_secs(60);
#[tracing::instrument(skip_all)]
pub async fn is_mod_or_admin(
@ -527,7 +524,7 @@ pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet>
static URL_BLOCKLIST: Lazy<Cache<(), RegexSet>> = Lazy::new(|| {
Cache::builder()
.max_capacity(1)
.time_to_live(URL_BLOCKLIST_RECHECK_DELAY)
.time_to_live(CACHE_DURATION_SHORT)
.build()
});

View file

@ -20,11 +20,11 @@ use lemmy_db_views_actor::structs::{
};
use lemmy_utils::{
error::{LemmyError, LemmyErrorExt, LemmyErrorType},
version,
CACHE_DURATION_SHORT,
VERSION,
};
use moka::future::Cache;
use once_cell::sync::Lazy;
use std::time::Duration;
#[tracing::instrument(skip(context))]
pub async fn get_site(
@ -34,7 +34,7 @@ pub async fn get_site(
static CACHE: Lazy<Cache<(), GetSiteResponse>> = Lazy::new(|| {
Cache::builder()
.max_capacity(1)
.time_to_live(Duration::from_secs(1))
.time_to_live(CACHE_DURATION_SHORT)
.build()
});
@ -50,7 +50,7 @@ pub async fn get_site(
Ok(GetSiteResponse {
site_view,
admins,
version: version::VERSION.to_string(),
version: VERSION.to_string(),
my_user: None,
all_languages,
discussion_languages,

View file

@ -9,11 +9,14 @@ use lemmy_db_schema::{
source::{activity::ReceivedActivity, instance::Instance, local_site::LocalSite},
utils::{ActualDbPool, DbPool},
};
use lemmy_utils::error::{LemmyError, LemmyErrorType, LemmyResult};
use lemmy_utils::{
error::{LemmyError, LemmyErrorType, LemmyResult},
CACHE_DURATION_SHORT,
};
use moka::future::Cache;
use once_cell::sync::Lazy;
use serde_json::Value;
use std::{sync::Arc, time::Duration};
use std::sync::Arc;
use url::Url;
pub mod activities;
@ -27,11 +30,6 @@ pub mod objects;
pub mod protocol;
pub const FEDERATION_HTTP_FETCH_LIMIT: u32 = 50;
/// All incoming and outgoing federation actions read the blocklist/allowlist and slur filters
/// multiple times. This causes a huge number of database reads if we hit the db directly. So we
/// cache these values for a short time, which will already make a huge difference and ensures that
/// changes take effect quickly.
const BLOCKLIST_CACHE_DURATION: Duration = Duration::from_secs(60);
/// Only include a basic context to save space and bandwidth. The main context is hosted statically
/// on join-lemmy.org. Include activitystreams explicitly for better compat, but this could
@ -122,10 +120,14 @@ pub(crate) struct LocalSiteData {
pub(crate) async fn local_site_data_cached(
pool: &mut DbPool<'_>,
) -> LemmyResult<Arc<LocalSiteData>> {
// All incoming and outgoing federation actions read the blocklist/allowlist and slur filters
// multiple times. This causes a huge number of database reads if we hit the db directly. So we
// cache these values for a short time, which will already make a huge difference and ensures that
// changes take effect quickly.
static CACHE: Lazy<Cache<(), Arc<LocalSiteData>>> = Lazy::new(|| {
Cache::builder()
.max_capacity(1)
.time_to_live(BLOCKLIST_CACHE_DURATION)
.time_to_live(CACHE_DURATION_SHORT)
.build()
});
Ok(

View file

@ -80,6 +80,7 @@ rustls = { workspace = true, optional = true }
uuid = { workspace = true, features = ["v4"] }
i-love-jesus = { workspace = true, optional = true }
anyhow = { workspace = true }
moka.workspace = true
[dev-dependencies]
serial_test = { workspace = true }

View file

@ -29,6 +29,7 @@ use diesel::{
select,
sql_types,
update,
BoolExpressionMethods,
ExpressionMethods,
NullableExpressionMethods,
QueryDsl,
@ -150,30 +151,16 @@ impl Community {
for p in &posts {
debug_assert!(p.community_id == community_id);
}
conn
.build_transaction()
.run(|conn| {
Box::pin(async move {
update(
// first remove all existing featured posts
post::table,
)
.filter(post::dsl::community_id.eq(community_id))
.set(post::dsl::featured_community.eq(false))
.execute(conn)
.await?;
// then mark the given posts as featured
let post_ids: Vec<_> = posts.iter().map(|p| p.id).collect();
update(post::table)
.filter(post::dsl::id.eq_any(post_ids))
.set(post::dsl::featured_community.eq(true))
.execute(conn)
.await?;
Ok(())
}) as _
})
.await
// Mark the given posts as featured and all other posts as not featured.
let post_ids = posts.iter().map(|p| p.id);
update(post::table)
.filter(post::dsl::community_id.eq(community_id))
// This filter is just for performance
.filter(post::dsl::featured_community.or(post::dsl::id.eq_any(post_ids.clone())))
.set(post::dsl::featured_community.eq(post::dsl::id.eq_any(post_ids)))
.execute(conn)
.await?;
Ok(())
}
}

View file

@ -5,6 +5,9 @@ use crate::{
};
use diesel::{dsl::insert_into, result::Error};
use diesel_async::RunQueryDsl;
use lemmy_utils::{error::LemmyError, CACHE_DURATION_SHORT};
use moka::future::Cache;
use once_cell::sync::Lazy;
impl LocalSite {
pub async fn create(pool: &mut DbPool<'_>, form: &LocalSiteInsertForm) -> Result<Self, Error> {
@ -14,9 +17,21 @@ impl LocalSite {
.get_result::<Self>(conn)
.await
}
pub async fn read(pool: &mut DbPool<'_>) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
local_site.first::<Self>(conn).await
pub async fn read(pool: &mut DbPool<'_>) -> Result<Self, LemmyError> {
static CACHE: Lazy<Cache<(), LocalSite>> = Lazy::new(|| {
Cache::builder()
.max_capacity(1)
.time_to_live(CACHE_DURATION_SHORT)
.build()
});
Ok(
CACHE
.try_get_with((), async {
let conn = &mut get_conn(pool).await?;
local_site.first::<Self>(conn).await
})
.await?,
)
}
pub async fn update(pool: &mut DbPool<'_>, form: &LocalSiteUpdateForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;

View file

@ -49,14 +49,18 @@ fn queries<'a>() -> Queries<
let list = move |mut conn: DbConn<'a>, options: PrivateMessageReportQuery| async move {
let mut query = all_joins(private_message_report::table.into_boxed());
// If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)
if options.unresolved_only {
query = query.filter(private_message_report::resolved.eq(false));
query = query
.filter(private_message_report::resolved.eq(false))
.order_by(private_message_report::published.asc());
} else {
query = query.order_by(private_message_report::published.desc());
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
query
.order_by(private_message::published.asc())
.limit(limit)
.offset(offset)
.load::<PrivateMessageReportView>(&mut conn)

View file

@ -1,6 +1,7 @@
use anyhow::{anyhow, Context, Result};
use diesel::prelude::*;
use diesel_async::RunQueryDsl;
use lemmy_api_common::lemmy_utils::CACHE_DURATION_SHORT;
use lemmy_apub::{
activity_lists::SharedInboxActivities,
fetcher::{site_or_community_or_user::SiteOrCommunityOrUser, user_or_community::UserOrCommunity},
@ -31,6 +32,7 @@ pub(crate) static LEMMY_TEST_FAST_FEDERATION: Lazy<bool> = Lazy::new(|| {
.map(|s| !s.is_empty())
.unwrap_or(false)
});
/// Recheck for new federation work every n seconds.
///
/// When the queue is processed faster than new activities are added and it reaches the current time with an empty batch,
@ -167,15 +169,8 @@ pub(crate) async fn get_activity_cached(
/// return the most current activity id (with 1 second cache)
pub(crate) async fn get_latest_activity_id(pool: &mut DbPool<'_>) -> Result<ActivityId> {
static CACHE: Lazy<Cache<(), ActivityId>> = Lazy::new(|| {
Cache::builder()
.time_to_live(if *LEMMY_TEST_FAST_FEDERATION {
*WORK_FINISHED_RECHECK_DELAY
} else {
Duration::from_secs(1)
})
.build()
});
static CACHE: Lazy<Cache<(), ActivityId>> =
Lazy::new(|| Cache::builder().time_to_live(CACHE_DURATION_SHORT).build());
CACHE
.try_get_with((), async {
use diesel::dsl::max;

View file

@ -6,7 +6,7 @@ use lemmy_db_views::structs::SiteView;
use lemmy_utils::{
cache_header::{cache_1hour, cache_3days},
error::LemmyError,
version,
VERSION,
};
use serde::{Deserialize, Serialize};
use url::Url;
@ -56,7 +56,7 @@ async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Err
version: Some("2.0".to_string()),
software: Some(NodeInfoSoftware {
name: Some("lemmy".to_string()),
version: Some(version::VERSION.to_string()),
version: Some(VERSION.to_string()),
}),
protocols,
usage: Some(NodeInfoUsage {

View file

@ -10,7 +10,6 @@ cfg_if! {
pub mod response;
pub mod settings;
pub mod utils;
pub mod version;
}
}
@ -20,8 +19,15 @@ use std::time::Duration;
pub type ConnectionId = usize;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const REQWEST_TIMEOUT: Duration = Duration::from_secs(10);
#[cfg(debug_assertions)]
pub const CACHE_DURATION_SHORT: Duration = Duration::from_millis(500);
#[cfg(not(debug_assertions))]
pub const CACHE_DURATION_SHORT: Duration = Duration::from_secs(60);
#[macro_export]
macro_rules! location_info {
() => {

View file

@ -1 +0,0 @@
pub const VERSION: &str = "unknown version";

@ -1 +1 @@
Subproject commit c3e61706e2ff7977db83e964e3010f72cad5e408
Subproject commit b3131d6881adb639dc0e298cc7c213c5245091f6

View file

@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.6
ARG RUST_VERSION=1.76
ARG RUST_VERSION=1.77
ARG CARGO_BUILD_FEATURES=default
ARG RUST_RELEASE_MODE=debug
@ -28,7 +28,6 @@ COPY . ./
# Debug build
RUN --mount=type=cache,target=/lemmy/target set -ex; \
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
cargo build --features "${CARGO_BUILD_FEATURES}"; \
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
fi
@ -36,8 +35,7 @@ RUN --mount=type=cache,target=/lemmy/target set -ex; \
# Release build
RUN --mount=type=cache,target=/lemmy/target set -ex; \
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
cargo clean --release; \
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
mv target/"${RUST_RELEASE_MODE}"/lemmy_server ./lemmy_server; \
fi
@ -63,7 +61,6 @@ ENV RUST_RELEASE_MODE=${RUST_RELEASE_MODE} \
# Debug build
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
if [ "${RUST_RELEASE_MODE}" = "debug" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
cargo build --features "${CARGO_BUILD_FEATURES}"; \
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
fi
@ -71,8 +68,7 @@ RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
# Release build
RUN --mount=type=cache,target=./target,uid=10001,gid=10001 set -ex; \
if [ "${RUST_RELEASE_MODE}" = "release" ]; then \
echo "pub const VERSION: &str = \"$(git describe --tag)\";" > crates/utils/src/version.rs; \
[ -z "$USE_RELEASE_CACHE" ] && cargo clean --release; \
cargo clean --release; \
cargo build --features "${CARGO_BUILD_FEATURES}" --release; \
mv "./target/$CARGO_BUILD_TARGET/$RUST_RELEASE_MODE/lemmy_server" /home/lemmy/lemmy_server; \
fi

View file

@ -1,5 +1,3 @@
version: "3.7"
x-logging: &default-logging
driver: "json-file"
options:

View file

@ -150,7 +150,6 @@ Lemmy はフリーでオープンソースのソフトウェアです。つま
- bitcoin: `1Hefs7miXS5ff5Ck5xvmjKjXf5242KzRtK`
- ethereum: `0x400c96c96acbC6E7B3B43B1dc1BB446540a88A01`
- monero: `41taVyY6e1xApqKyMVDRVxJ76sPkfZhALLTjRvVKpaAh2pBd4wv9RgYj1tSPrx8wc6iE1uWUfjtQdTmTy2FGMeChGVKPQuV`
- cardano: `addr1q858t89l2ym6xmrugjs0af9cslfwvnvsh2xxp6x4dcez7pf5tushkp4wl7zxfhm2djp6gq60dk4cmc7seaza5p3slx0sakjutm`
## コントリビュート

View file

@ -49,7 +49,7 @@ use lemmy_utils::{
rate_limit::RateLimitCell,
response::jsonify_plain_text_errors,
settings::{structs::Settings, SETTINGS},
version,
VERSION,
};
use prometheus::default_registry;
use prometheus_metrics::serve_prometheus;
@ -109,7 +109,7 @@ pub struct CmdArgs {
/// Placing the main function in lib.rs allows other crates to import it and embed Lemmy
pub async fn start_lemmy_server(args: CmdArgs) -> Result<(), LemmyError> {
// Print version number to log
println!("Lemmy v{}", version::VERSION);
println!("Lemmy v{VERSION}");
// return error 503 while running db migrations and startup tasks
let mut startup_server_handle = None;

View file

@ -94,7 +94,7 @@ pub async fn setup(context: LemmyContext) -> Result<(), LemmyError> {
delete_old_denied_users(&mut context.pool()).await;
update_instance_software(&mut context.pool(), context.client())
.await
.inspect_err(|e| warn!("Failed to update instance software: {e}"))
.map_err(|e| warn!("Failed to update instance software: {e}"))
.ok();
}
});
@ -276,10 +276,10 @@ async fn delete_expired_captcha_answers(pool: &mut DbPool<'_>) {
)
.execute(&mut conn)
.await
.inspect(|_| {
.map(|_| {
info!("Done.");
})
.inspect_err(|e| error!("Failed to clear old captcha answers: {e}"))
.map_err(|e| error!("Failed to clear old captcha answers: {e}"))
.ok();
}
Err(e) => {
@ -300,7 +300,7 @@ async fn clear_old_activities(pool: &mut DbPool<'_>) {
)
.execute(&mut conn)
.await
.inspect_err(|e| error!("Failed to clear old sent activities: {e}"))
.map_err(|e| error!("Failed to clear old sent activities: {e}"))
.ok();
diesel::delete(
@ -309,8 +309,8 @@ async fn clear_old_activities(pool: &mut DbPool<'_>) {
)
.execute(&mut conn)
.await
.inspect(|_| info!("Done."))
.inspect_err(|e| error!("Failed to clear old received activities: {e}"))
.map(|_| info!("Done."))
.map_err(|e| error!("Failed to clear old received activities: {e}"))
.ok();
}
Err(e) => {
@ -322,10 +322,10 @@ async fn clear_old_activities(pool: &mut DbPool<'_>) {
async fn delete_old_denied_users(pool: &mut DbPool<'_>) {
LocalUser::delete_old_denied_local_users(pool)
.await
.inspect(|_| {
.map(|_| {
info!("Done.");
})
.inspect(|e| error!("Failed to deleted old denied users: {e}"))
.map_err(|e| error!("Failed to deleted old denied users: {e}"))
.ok();
}
@ -348,10 +348,10 @@ async fn overwrite_deleted_posts_and_comments(pool: &mut DbPool<'_>) {
))
.execute(&mut conn)
.await
.inspect(|_| {
.map(|_| {
info!("Done.");
})
.inspect_err(|e| error!("Failed to overwrite deleted posts: {e}"))
.map_err(|e| error!("Failed to overwrite deleted posts: {e}"))
.ok();
info!("Overwriting deleted comments...");
@ -364,10 +364,10 @@ async fn overwrite_deleted_posts_and_comments(pool: &mut DbPool<'_>) {
.set(comment::content.eq(DELETED_REPLACEMENT_TEXT))
.execute(&mut conn)
.await
.inspect(|_| {
.map(|_| {
info!("Done.");
})
.inspect_err(|e| error!("Failed to overwrite deleted comments: {e}"))
.map_err(|e| error!("Failed to overwrite deleted comments: {e}"))
.ok();
}
Err(e) => {
@ -399,14 +399,14 @@ async fn active_counts(pool: &mut DbPool<'_>) {
sql_query(update_site_stmt)
.execute(&mut conn)
.await
.inspect_err(|e| error!("Failed to update site stats: {e}"))
.map_err(|e| error!("Failed to update site stats: {e}"))
.ok();
let update_community_stmt = format!("update community_aggregates ca set users_active_{} = mv.count_ from community_aggregates_activity('{}') mv where ca.community_id = mv.community_id_", i.1, i.0);
sql_query(update_community_stmt)
.execute(&mut conn)
.await
.inspect_err(|e| error!("Failed to update community stats: {e}"))
.map_err(|e| error!("Failed to update community stats: {e}"))
.ok();
}
@ -433,7 +433,7 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) {
.set(person::banned.eq(false))
.execute(&mut conn)
.await
.inspect_err(|e| error!("Failed to update person.banned when expires: {e}"))
.map_err(|e| error!("Failed to update person.banned when expires: {e}"))
.ok();
diesel::delete(
@ -441,7 +441,7 @@ async fn update_banned_when_expired(pool: &mut DbPool<'_>) {
)
.execute(&mut conn)
.await
.inspect_err(|e| error!("Failed to remove community_ban expired rows: {e}"))
.map_err(|e| error!("Failed to remove community_ban expired rows: {e}"))
.ok();
}
Err(e) => {