mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
style: Reformat with nightly
This commit is contained in:
11 files changed
+56
-47
No files matched your search
@@ -65,8 +65,8 @@ use crate::{Result, err, error::Error, utils::sys};
|
||||
ignore = "config_paths catchall"
|
||||
)]
|
||||
pub struct Config {
|
||||
// Paths to config file(s). Not supposed to be set manually in the config file,
|
||||
// only updated dynamically from the --config option given at runtime.
|
||||
// Paths to config file(s). Not supposed to be set manually in the config
|
||||
// file, only updated dynamically from the --config option given at runtime.
|
||||
pub config_paths: Option<Vec<PathBuf>>,
|
||||
|
||||
/// The server_name is the pretty name of this server. It is used as a
|
||||
|
||||
@@ -590,8 +590,8 @@ where
|
||||
.find(|aev| is_type_and_key(*aev, &TimelineEventType::RoomPowerLevels, ""));
|
||||
|
||||
let content: PowerLevelsContentFields = match pl {
|
||||
// With no m.room.power_levels in scope the create event's defaults apply,
|
||||
// under which the room creator holds 100 and everyone else 0.
|
||||
// With no m.room.power_levels in scope the create event's defaults
|
||||
// apply, under which the room creator holds 100 and everyone else 0.
|
||||
| None => return Ok(if sender_is_creator { int!(100) } else { int!(0) }),
|
||||
| Some(ev) => from_json_str(ev.content().get())?,
|
||||
};
|
||||
|
||||
@@ -146,8 +146,8 @@ impl crate::Service for Service {
|
||||
.redirect(redirect::Policy::limited(2))
|
||||
.build()?,
|
||||
|
||||
// MSC4174 recommends against following redirects, since the destination
|
||||
// is only checked before the request is sent.
|
||||
// MSC4174 recommends against following redirects, since the
|
||||
// destination is only checked before the request is sent.
|
||||
webpush: base(config)?
|
||||
.connect_timeout(Duration::from_secs(config.pusher_conn_timeout))
|
||||
.timeout(Duration::from_secs(config.pusher_timeout))
|
||||
|
||||
+26
-24
@@ -109,35 +109,37 @@ migration!(stringify!($name) => $name)
|
||||
migration!(fix_readreceiptid_readreceipt_duplicates),
|
||||
// End pre-fork logic.
|
||||
|
||||
// v18: `fix_corrupt_msc4133_fields` will change the `us.cloke.msc4175.tz` field
|
||||
// in a way that old versions don't understand.
|
||||
// v18: `fix_corrupt_msc4133_fields` will change the
|
||||
// `us.cloke.msc4175.tz` field in a way that old versions don't
|
||||
// understand.
|
||||
VersionBump(18),
|
||||
migration!(fix_corrupt_msc4133_fields),
|
||||
// v19: `populate_userroomid_leftstate_table` will put data in the values of
|
||||
// `userroomid_leftstate` that old versions will fail to deserialize because
|
||||
// they expect the values to be empty.
|
||||
// v19: `populate_userroomid_leftstate_table` will put data in the
|
||||
// values of `userroomid_leftstate` that old versions will fail to
|
||||
// deserialize because they expect the values to be empty.
|
||||
VersionBump(19),
|
||||
migration!(populate_userroomid_leftstate_table),
|
||||
// This is backwards compatible because it fixes some data that clients care about but we
|
||||
// don't.
|
||||
// This is backwards compatible because it fixes some data that clients
|
||||
// care about but we don't.
|
||||
migration!(fix_local_invite_state),
|
||||
// v20: Old versions expect remote users to be tracked in `userid_password`. This
|
||||
// migration moves them to a different keyspace.
|
||||
// v20: Old versions expect remote users to be tracked in
|
||||
// `userid_password`. This migration moves them to a different keyspace.
|
||||
VersionBump(20),
|
||||
migration!(split_userid_password),
|
||||
// This is backwards compatible because old versions will recreate the keyspace if it's
|
||||
// missing.
|
||||
// This is backwards compatible because old versions will recreate the
|
||||
// keyspace if it's missing.
|
||||
migration!("drop_roomsynctoken_shortstatehash" => obliterate_roomsynctoken_shortstatehash_with_extreme_prejudice),
|
||||
// v21: `unembed_unsigned_info` will remove `unsigned` data from PDUs that old versions
|
||||
// expect to be embedded.
|
||||
// v21: `unembed_unsigned_info` will remove `unsigned` data from PDUs
|
||||
// that old versions expect to be embedded.
|
||||
VersionBump(21),
|
||||
// This migration can take several hours on old databases, so we run it in the background
|
||||
// to keep the service manager from killing us for taking too long to start.
|
||||
// Future maintainers: !!! BE VERY CAREFUL !!! if you need to write more migrations like
|
||||
// this! This one is fine because it deletes data that we don't check anymore,
|
||||
// but migrations which replace existing data that we do check should NOT run in
|
||||
// the background. If they do, the server will finish starting up and might
|
||||
// access data that the migration hasn't gotten to yet.
|
||||
// This migration can take several hours on old databases, so we run it
|
||||
// in the background to keep the service manager from killing us for
|
||||
// taking too long to start. Future maintainers: !!! BE VERY CAREFUL !!!
|
||||
// if you need to write more migrations like this! This one is fine
|
||||
// because it deletes data that we don't check anymore, but migrations
|
||||
// which replace existing data that we do check should NOT run in
|
||||
// the background. If they do, the server will finish starting up and
|
||||
// might access data that the migration hasn't gotten to yet.
|
||||
Migration("unembed_unsigned_info", |services| {
|
||||
Box::pin(async {
|
||||
if services.db["global"]
|
||||
@@ -158,11 +160,11 @@ migration!(stringify!($name) => $name)
|
||||
Ok(())
|
||||
})
|
||||
}),
|
||||
// This is backwards compatible because old versions will recreate the keyspace if it's
|
||||
// missing.
|
||||
// This is backwards compatible because old versions will recreate the
|
||||
// keyspace if it's missing.
|
||||
migration!(drop_server_signingkeys),
|
||||
// v22: Old versions will fail to deserialize the fixed OAuth scope names,
|
||||
// preventing users from signing in.
|
||||
// v22: Old versions will fail to deserialize the fixed OAuth scope
|
||||
// names, preventing users from signing in.
|
||||
VersionBump(22),
|
||||
migration!(fix_oauth_scope_names),
|
||||
]
|
||||
|
||||
@@ -203,8 +203,8 @@ impl super::Service {
|
||||
"GET_MISSING_EVENTS_MAX_BATCH_SIZE (usize) should fit in u16 (<=65536)",
|
||||
))
|
||||
.max(
|
||||
// This max call ensures we fetch *at least* all the prev events the
|
||||
// head has.
|
||||
// This max call ensures we fetch *at least* all the prev
|
||||
// events the head has.
|
||||
u16::try_from(head.prev_events.len())
|
||||
.expect("cannot have more than 20 prev events, which fits in u16"),
|
||||
);
|
||||
|
||||
@@ -756,11 +756,13 @@ impl Service {
|
||||
let join_rule = self.services.state_accessor.get_join_rules(room_id).await;
|
||||
|
||||
match (join_rule, querying_user) {
|
||||
// Anyone can view summaries for `public`, `knock`, and `knock_restricted` rooms.
|
||||
// Anyone can view summaries for `public`, `knock`, and
|
||||
// `knock_restricted` rooms.
|
||||
| (JoinRule::Public | JoinRule::Knock | JoinRule::KnockRestricted(_), _) => true,
|
||||
|
||||
// The user may be able to view the summary for a `restricted` room, even if they
|
||||
// aren't invited, provided they fulfill the join rules.
|
||||
// The user may be able to view the summary for a `restricted` room,
|
||||
// even if they aren't invited, provided they fulfill the join
|
||||
// rules.
|
||||
| (JoinRule::Restricted(conditions), Some(querying_user)) =>
|
||||
self.services
|
||||
.membership
|
||||
|
||||
@@ -193,7 +193,8 @@ impl super::Service {
|
||||
let redacts = match redacts {
|
||||
// If this isn't a real redaction event, there's no redacts field.
|
||||
| _ if event_type != TimelineEventType::RoomRedaction || state_key.is_some() => None,
|
||||
// If the redaction is itself in the event content, we don't set the top-level field.
|
||||
// If the redaction is itself in the event content, we don't set the
|
||||
// top-level field.
|
||||
| Some(_) if room_version_rules.redaction.content_field_redacts => None,
|
||||
// Otherwise, we do if it's present
|
||||
| other => other,
|
||||
|
||||
@@ -124,8 +124,9 @@ impl Service {
|
||||
let mut sessions = self.sessions.lock().await;
|
||||
|
||||
let session = match sessions.get_session_by_client_secret(client_secret) {
|
||||
// If a validation session already exists for this client secret, we can either
|
||||
// reuse it with a new token or return early because it's already valid.
|
||||
// If a validation session already exists for this client secret, we
|
||||
// can either reuse it with a new token or return early because it's
|
||||
// already valid.
|
||||
| Some(session) => {
|
||||
if session.email != recipient.email {
|
||||
return Err!(Request(InvalidParam("Wrong email for session.")));
|
||||
|
||||
+2
-1
@@ -94,7 +94,8 @@ impl IntoResponse for WebError {
|
||||
error: self,
|
||||
status,
|
||||
context: TemplateContext {
|
||||
// Statically set false to prevent error pages from being indexed.
|
||||
// Statically set false to prevent error pages from being
|
||||
// indexed.
|
||||
allow_indexing: false,
|
||||
csp_nonce: String::new(),
|
||||
},
|
||||
|
||||
@@ -48,11 +48,12 @@ pub(crate) struct FormInput<'a> {
|
||||
pub autocomplete: &'a str,
|
||||
|
||||
// This is a hack to make the form! macro's support for client-only fields
|
||||
// work properly. Client-only fields are specified in the macro without a type and aren't
|
||||
// included in the POST body or as a field in the generated struct.
|
||||
// To keep the field from being included in the POST body, its `name` property needs not to
|
||||
// be set in the template. Because of limitations of macro_rules!'s repetition feature, this
|
||||
// field needs to exist to allow the template to check if the field is client-only.
|
||||
// work properly. Client-only fields are specified in the macro without a
|
||||
// type and aren't included in the POST body or as a field in the generated
|
||||
// struct. To keep the field from being included in the POST body, its
|
||||
// `name` property needs not to be set in the template. Because of
|
||||
// limitations of macro_rules!'s repetition feature, this field needs to
|
||||
// exist to allow the template to check if the field is client-only.
|
||||
#[doc(hidden)]
|
||||
pub type_name: Option<&'static str>,
|
||||
}
|
||||
|
||||
@@ -61,9 +61,10 @@ pub(super) async fn template_context_middleware(
|
||||
response.headers_mut().insert(
|
||||
header::CONTENT_SECURITY_POLICY,
|
||||
HeaderValue::from_str(&format!(
|
||||
// TODO: `unsafe-inline` for `style-src` defeats the purpose of having it, but
|
||||
// it's necessary to set CSS variables using the `style` attribute without
|
||||
// JavaScript. Come back to this once there's a less shitty solution.
|
||||
// TODO: `unsafe-inline` for `style-src` defeats the purpose of
|
||||
// having it, but it's necessary to set CSS variables using the
|
||||
// `style` attribute without JavaScript. Come back to this once
|
||||
// there's a less shitty solution.
|
||||
"default-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' https: data:; \
|
||||
script-src 'nonce-{csp_nonce}'; child-src {child_src};"
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user