mirror of https://github.com/LemmyNet/lemmy.git
Compare commits
5 Commits
9120207314
...
117a8b42c8
Author | SHA1 | Date |
---|---|---|
renovate[bot] | 117a8b42c8 | |
dullbananas | fd58b4f809 | |
Dessalines | a7c39226e2 | |
renovate[bot] | d90e8f8550 | |
Richard Schwab | 2c57f42022 |
|
@ -977,9 +977,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.7"
|
||||
version = "4.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f"
|
||||
checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
|
@ -987,9 +987,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.7"
|
||||
version = "4.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f"
|
||||
checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
|
@ -999,9 +999,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.5"
|
||||
version = "4.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6"
|
||||
checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
|
@ -3281,7 +3281,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.52.5",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -5205,9 +5205,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.117"
|
||||
version = "1.0.120"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
|
||||
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5"
|
||||
dependencies = [
|
||||
"indexmap 2.2.6",
|
||||
"itoa",
|
||||
|
|
|
@ -8,7 +8,7 @@ CREATE FUNCTION r.controversy_rank (upvotes numeric, downvotes numeric)
|
|||
0
|
||||
ELSE
|
||||
(
|
||||
upvotes + downvotes) * CASE WHEN upvotes > downvotes THEN
|
||||
upvotes + downvotes) ^ CASE WHEN upvotes > downvotes THEN
|
||||
downvotes::float / upvotes::float
|
||||
ELSE
|
||||
upvotes::float / downvotes::float
|
||||
|
|
|
@ -85,12 +85,6 @@ impl fmt::Display for PrivateMessageId {
|
|||
/// The person mention id.
|
||||
pub struct PersonMentionId(i32);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
||||
#[cfg_attr(feature = "full", derive(DieselNewType, TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
/// The person block id.
|
||||
pub struct PersonBlockId(i32);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Default)]
|
||||
#[cfg_attr(feature = "full", derive(DieselNewType, TS))]
|
||||
#[cfg_attr(feature = "full", ts(export))]
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
UPDATE
|
||||
post_aggregates
|
||||
SET
|
||||
controversy_rank = CASE WHEN downvotes <= 0
|
||||
OR upvotes <= 0 THEN
|
||||
0
|
||||
ELSE
|
||||
(upvotes + downvotes) * CASE WHEN upvotes > downvotes THEN
|
||||
downvotes::float / upvotes::float
|
||||
ELSE
|
||||
upvotes::float / downvotes::float
|
||||
END
|
||||
END
|
||||
WHERE
|
||||
upvotes > 0
|
||||
AND downvotes > 0;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
UPDATE
|
||||
post_aggregates
|
||||
SET
|
||||
controversy_rank = CASE WHEN downvotes <= 0
|
||||
OR upvotes <= 0 THEN
|
||||
0
|
||||
ELSE
|
||||
(upvotes + downvotes) ^ CASE WHEN upvotes > downvotes THEN
|
||||
downvotes::float / upvotes::float
|
||||
ELSE
|
||||
upvotes::float / downvotes::float
|
||||
END
|
||||
END
|
||||
WHERE
|
||||
upvotes > 0
|
||||
AND downvotes > 0;
|
||||
|
31
src/lib.rs
31
src/lib.rs
|
@ -55,7 +55,7 @@ use prometheus_metrics::serve_prometheus;
|
|||
use reqwest_middleware::ClientBuilder;
|
||||
use reqwest_tracing::TracingMiddleware;
|
||||
use serde_json::json;
|
||||
use std::{env, ops::Deref};
|
||||
use std::{env, ops::Deref, time::Duration};
|
||||
use tokio::signal::unix::SignalKind;
|
||||
use tracing::subscriber::set_global_default;
|
||||
use tracing_actix_web::TracingLogger;
|
||||
|
@ -64,6 +64,13 @@ use tracing_log::LogTracer;
|
|||
use tracing_subscriber::{filter::Targets, layer::SubscriberExt, Layer, Registry};
|
||||
use url::Url;
|
||||
|
||||
/// Timeout for HTTP requests while sending activities. A longer timeout provides better
|
||||
/// compatibility with other ActivityPub software that might allocate more time for synchronous
|
||||
/// processing of incoming activities. This timeout should be slightly longer than the time we
|
||||
/// expect a remote server to wait before aborting processing on its own to account for delays from
|
||||
/// establishing the HTTP connection and sending the request itself.
|
||||
const ACTIVITY_SENDING_TIMEOUT: Duration = Duration::from_secs(125);
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(
|
||||
version,
|
||||
|
@ -173,8 +180,8 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> {
|
|||
serve_prometheus(prometheus, context.clone())?;
|
||||
}
|
||||
|
||||
let mut federation_config = FederationConfig::builder();
|
||||
federation_config
|
||||
let mut federation_config_builder = FederationConfig::builder();
|
||||
federation_config_builder
|
||||
.domain(SETTINGS.hostname.clone())
|
||||
.app_data(context.clone())
|
||||
.client(client.clone())
|
||||
|
@ -184,9 +191,9 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> {
|
|||
.url_verifier(Box::new(VerifyUrlData(context.inner_pool().clone())));
|
||||
if local_site.federation_signed_fetch {
|
||||
let site: ApubSite = site_view.site.into();
|
||||
federation_config.signed_fetch_actor(&site);
|
||||
federation_config_builder.signed_fetch_actor(&site);
|
||||
}
|
||||
let federation_config = federation_config.build().await?;
|
||||
let federation_config = federation_config_builder.build().await?;
|
||||
|
||||
MATCH_OUTGOING_ACTIVITIES
|
||||
.set(Box::new(move |d, c| {
|
||||
|
@ -209,13 +216,23 @@ pub async fn start_lemmy_server(args: CmdArgs) -> LemmyResult<()> {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let federate = (!args.disable_activity_sending).then(|| {
|
||||
|
||||
// This FederationConfig instance is exclusively used to send activities, so we can safely
|
||||
// increase the timeout without affecting timeouts for resolving objects anywhere.
|
||||
let federation_sender_config = if !args.disable_activity_sending {
|
||||
let mut federation_sender_config = federation_config_builder.clone();
|
||||
federation_sender_config.request_timeout(ACTIVITY_SENDING_TIMEOUT);
|
||||
Some(federation_sender_config.build().await?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let federate = federation_sender_config.map(|cfg| {
|
||||
SendManager::run(
|
||||
Opts {
|
||||
process_index: args.federate_process_index,
|
||||
process_count: args.federate_process_count,
|
||||
},
|
||||
federation_config,
|
||||
cfg,
|
||||
)
|
||||
});
|
||||
let mut interrupt = tokio::signal::unix::signal(SignalKind::interrupt())?;
|
||||
|
|
Loading…
Reference in New Issue