mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat(core): Add config option for the url preview user agent
This commit is contained in:
@@ -1474,6 +1474,12 @@
|
|||||||
#
|
#
|
||||||
#url_preview_check_root_domain = false
|
#url_preview_check_root_domain = false
|
||||||
|
|
||||||
|
# User agent that is used specifically when downloading url previews.
|
||||||
|
#
|
||||||
|
# example: "continuwuity (bot; +https://forgejo.ellis.link/continuwuation/continuwuity)"
|
||||||
|
#
|
||||||
|
#url_preview_user_agent = "continuwuity/$VERSION ($VERSION_TAG)"
|
||||||
|
|
||||||
# List of forbidden room aliases and room IDs as strings of regex
|
# List of forbidden room aliases and room IDs as strings of regex
|
||||||
# patterns.
|
# patterns.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1696,6 +1696,13 @@ pub struct Config {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub url_preview_check_root_domain: bool,
|
pub url_preview_check_root_domain: bool,
|
||||||
|
|
||||||
|
/// User agent that is used specifically when downloading url previews.
|
||||||
|
///
|
||||||
|
/// example: "continuwuity (bot; +https://forgejo.ellis.link/continuwuation/continuwuity)"
|
||||||
|
///
|
||||||
|
/// default: "continuwuity/$VERSION ($VERSION_TAG)"
|
||||||
|
pub url_preview_user_agent: Option<String>,
|
||||||
|
|
||||||
/// List of forbidden room aliases and room IDs as strings of regex
|
/// List of forbidden room aliases and room IDs as strings of regex
|
||||||
/// patterns.
|
/// patterns.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ impl crate::Service for Service {
|
|||||||
.clone()
|
.clone()
|
||||||
.and_then(Either::right);
|
.and_then(Either::right);
|
||||||
|
|
||||||
|
let url_preview_user_agent = config
|
||||||
|
.url_preview_user_agent
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_else(|| conduwuit::version::user_agent().to_string());
|
||||||
|
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
default: base(config)?
|
default: base(config)?
|
||||||
.dns_resolver(resolver.resolver.clone())
|
.dns_resolver(resolver.resolver.clone())
|
||||||
@@ -49,6 +54,7 @@ impl crate::Service for Service {
|
|||||||
.dns_resolver(resolver.resolver.clone())
|
.dns_resolver(resolver.resolver.clone())
|
||||||
.timeout(Duration::from_secs(config.url_preview_timeout))
|
.timeout(Duration::from_secs(config.url_preview_timeout))
|
||||||
.redirect(redirect::Policy::limited(3))
|
.redirect(redirect::Policy::limited(3))
|
||||||
|
.user_agent(url_preview_user_agent)
|
||||||
.build()?,
|
.build()?,
|
||||||
|
|
||||||
extern_media: base(config)?
|
extern_media: base(config)?
|
||||||
|
|||||||
Reference in New Issue
Block a user