mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-27 10:57:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59c2649cde | ||
|
|
b0c1381f03 | ||
|
|
14ff018b9f | ||
|
|
1ca30e4268 | ||
|
|
71016a0d7f | ||
|
|
c7602a570c | ||
|
|
83cf15bccb | ||
|
|
e8a6a9ac9d |
No files matched your search
@@ -44,7 +44,7 @@ runs:
|
|||||||
|
|
||||||
- name: Login to builtin registry
|
- name: Login to builtin registry
|
||||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
|
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
registry: ${{ env.BUILTIN_REGISTRY }}
|
||||||
username: ${{ inputs.registry_user }}
|
username: ${{ inputs.registry_user }}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ runs:
|
|||||||
|
|
||||||
- name: Login to builtin registry
|
- name: Login to builtin registry
|
||||||
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
if: ${{ env.BUILTIN_REGISTRY_ENABLED == 'true' }}
|
||||||
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
|
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.BUILTIN_REGISTRY }}
|
registry: ${{ env.BUILTIN_REGISTRY }}
|
||||||
username: ${{ inputs.registry_user }}
|
username: ${{ inputs.registry_user }}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ runs:
|
|||||||
|
|
||||||
- name: Install timelord-cli and git-warp-time
|
- name: Install timelord-cli and git-warp-time
|
||||||
if: steps.check-binaries.outputs.need-install == 'true'
|
if: steps.check-binaries.outputs.need-install == 'true'
|
||||||
uses: https://github.com/taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2
|
uses: https://github.com/taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf # v2
|
||||||
with:
|
with:
|
||||||
tool: git-warp-time,timelord-cli@3.0.1
|
tool: git-warp-time,timelord-cli@3.0.1
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
container: [ "ubuntu-latest", "ubuntu-previous", "debian-latest", "debian-oldstable" ]
|
container: [ "ubuntu-latest", "ubuntu-previous", "debian-latest", "debian-oldstable" ]
|
||||||
arch: ["amd64", "arm64"]
|
arch: [ "amd64", "arm64" ]
|
||||||
container:
|
container:
|
||||||
image: "ghcr.io/tcpipuk/act-runner:${{ matrix.container }}"
|
image: "ghcr.io/tcpipuk/act-runner:${{ matrix.container }}"
|
||||||
|
|
||||||
@@ -165,6 +165,12 @@ jobs:
|
|||||||
apt-get update -y
|
apt-get update -y
|
||||||
# Build dependencies for rocksdb
|
# Build dependencies for rocksdb
|
||||||
apt-get install -y liburing-dev clang
|
apt-get install -y liburing-dev clang
|
||||||
|
# For arm64 builds, install cross-compiled dependencies.
|
||||||
|
# libstdc++6:arm64 is needed by dpkg-shlibdeps to resolve the
|
||||||
|
# dynamically-linked libstdc++ when cargo-deb computes $auto depends.
|
||||||
|
if [ "${{ matrix.arch }}" = "arm64" ]; then
|
||||||
|
apt-get install -y liburing-dev:arm64 libstdc++6:arm64
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Run cargo-deb
|
- name: Run cargo-deb
|
||||||
id: cargo-deb
|
id: cargo-deb
|
||||||
|
|||||||
Generated
+12
-12
@@ -816,7 +816,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
"aws-lc-rs",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -854,7 +854,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_admin"
|
name = "conduwuit_admin"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -880,7 +880,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_api"
|
name = "conduwuit_api"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -918,7 +918,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_build_metadata"
|
name = "conduwuit_build_metadata"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"built",
|
"built",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
@@ -926,7 +926,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_core"
|
name = "conduwuit_core"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
@@ -994,7 +994,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_database"
|
name = "conduwuit_database"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-channel",
|
"async-channel",
|
||||||
"conduwuit_core",
|
"conduwuit_core",
|
||||||
@@ -1015,7 +1015,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_macros"
|
name = "conduwuit_macros"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo_toml",
|
"cargo_toml",
|
||||||
"itertools 0.15.0",
|
"itertools 0.15.0",
|
||||||
@@ -1026,7 +1026,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_router"
|
name = "conduwuit_router"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -1063,7 +1063,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_service"
|
name = "conduwuit_service"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"assign",
|
"assign",
|
||||||
@@ -1115,7 +1115,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conduwuit_web"
|
name = "conduwuit_web"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"assign",
|
"assign",
|
||||||
@@ -4765,7 +4765,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ruminuwuity"
|
name = "ruminuwuity"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"assign",
|
"assign",
|
||||||
"ruma",
|
"ruma",
|
||||||
@@ -6874,7 +6874,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xtask"
|
name = "xtask"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"askama",
|
"askama",
|
||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ license = "Apache-2.0"
|
|||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
repository = "https://forgejo.ellis.link/continuwuation/continuwuity"
|
||||||
version = "26.7.0"
|
version = "26.7.2"
|
||||||
|
|
||||||
[workspace.metadata.crane]
|
[workspace.metadata.crane]
|
||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
**TODO - embargoed until next release** (maintainers see security issue 10 when writing rls notes). Contributed by @eleboucher.
|
||||||
+112
-23
@@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque},
|
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
@@ -138,6 +138,13 @@ pub(crate) async fn sync_events_v5_route(
|
|||||||
let (all_joined_rooms, all_invited_rooms, all_knocked_rooms) =
|
let (all_joined_rooms, all_invited_rooms, all_knocked_rooms) =
|
||||||
join3(all_joined_rooms, all_invited_rooms, all_knocked_rooms).await;
|
join3(all_joined_rooms, all_invited_rooms, all_knocked_rooms).await;
|
||||||
|
|
||||||
|
let allowed_rooms: BTreeSet<OwnedRoomId> = all_joined_rooms
|
||||||
|
.iter()
|
||||||
|
.chain(all_invited_rooms.iter())
|
||||||
|
.chain(all_knocked_rooms.iter())
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
|
|
||||||
let all_joined_rooms = all_joined_rooms.iter().map(AsRef::as_ref);
|
let all_joined_rooms = all_joined_rooms.iter().map(AsRef::as_ref);
|
||||||
let all_invited_rooms = all_invited_rooms.iter().map(AsRef::as_ref);
|
let all_invited_rooms = all_invited_rooms.iter().map(AsRef::as_ref);
|
||||||
let all_knocked_rooms = all_knocked_rooms.iter().map(AsRef::as_ref);
|
let all_knocked_rooms = all_knocked_rooms.iter().map(AsRef::as_ref);
|
||||||
@@ -190,13 +197,14 @@ pub(crate) async fn sync_events_v5_route(
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
fetch_subscriptions(services, sync_info, &known_rooms, &mut todo_rooms).await;
|
fetch_subscriptions(services, sync_info, &known_rooms, &allowed_rooms, &mut todo_rooms).await;
|
||||||
|
|
||||||
response.rooms = process_rooms(
|
response.rooms = process_rooms(
|
||||||
services,
|
services,
|
||||||
sender_user,
|
sender_user,
|
||||||
next_batch,
|
next_batch,
|
||||||
all_invited_rooms.clone(),
|
all_invited_rooms.clone(),
|
||||||
|
all_knocked_rooms.clone(),
|
||||||
&todo_rooms,
|
&todo_rooms,
|
||||||
&mut response,
|
&mut response,
|
||||||
&body,
|
&body,
|
||||||
@@ -214,6 +222,7 @@ pub(crate) async fn sync_events_v5_route(
|
|||||||
let no_room_data = response.rooms.iter().all(|(id, r)| {
|
let no_room_data = response.rooms.iter().all(|(id, r)| {
|
||||||
r.timeline.is_empty()
|
r.timeline.is_empty()
|
||||||
&& r.required_state.is_empty()
|
&& r.required_state.is_empty()
|
||||||
|
&& r.invite_state.is_none()
|
||||||
&& !response.extensions.receipts.rooms.contains_key(id)
|
&& !response.extensions.receipts.rooms.contains_key(id)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -247,10 +256,17 @@ async fn fetch_subscriptions(
|
|||||||
services: &Services,
|
services: &Services,
|
||||||
(sender_user, sender_device, globalsince, body): SyncInfo<'_>,
|
(sender_user, sender_device, globalsince, body): SyncInfo<'_>,
|
||||||
known_rooms: &KnownRooms,
|
known_rooms: &KnownRooms,
|
||||||
|
allowed_rooms: &BTreeSet<OwnedRoomId>,
|
||||||
todo_rooms: &mut TodoRooms,
|
todo_rooms: &mut TodoRooms,
|
||||||
) {
|
) {
|
||||||
let mut known_subscription_rooms = BTreeSet::new();
|
let mut known_subscription_rooms = BTreeSet::new();
|
||||||
for (room_id, room) in &body.room_subscriptions {
|
for (room_id, room) in &body.room_subscriptions {
|
||||||
|
// Silently ignore subscriptions to rooms the user is not a member of
|
||||||
|
// (joined or invited).
|
||||||
|
if !allowed_rooms.contains(room_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let not_exists = services.rooms.metadata.exists(room_id).eq(&false);
|
let not_exists = services.rooms.metadata.exists(room_id).eq(&false);
|
||||||
|
|
||||||
let is_disabled = services.rooms.metadata.is_disabled(room_id);
|
let is_disabled = services.rooms.metadata.is_disabled(room_id);
|
||||||
@@ -409,11 +425,13 @@ where
|
|||||||
BTreeMap::default()
|
BTreeMap::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn process_rooms<'a, Rooms>(
|
async fn process_rooms<'a, Rooms>(
|
||||||
services: &Services,
|
services: &Services,
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
next_batch: u64,
|
next_batch: u64,
|
||||||
all_invited_rooms: Rooms,
|
all_invited_rooms: Rooms,
|
||||||
|
all_knocked_rooms: Rooms,
|
||||||
todo_rooms: &TodoRooms,
|
todo_rooms: &TodoRooms,
|
||||||
response: &mut sync_events::v5::Response,
|
response: &mut sync_events::v5::Response,
|
||||||
body: &sync_events::v5::Request,
|
body: &sync_events::v5::Request,
|
||||||
@@ -426,38 +444,101 @@ where
|
|||||||
let roomsincecount = PduCount::Normal(*roomsince);
|
let roomsincecount = PduCount::Normal(*roomsince);
|
||||||
|
|
||||||
let mut timestamp: Option<_> = None;
|
let mut timestamp: Option<_> = None;
|
||||||
let mut invite_state = None;
|
|
||||||
let (timeline_pdus, limited);
|
let (timeline_pdus, limited);
|
||||||
let new_room_id: &RoomId = (*room_id).as_ref();
|
let new_room_id: &RoomId = (*room_id).as_ref();
|
||||||
if all_invited_rooms.clone().any(is_equal_to!(new_room_id)) {
|
if all_invited_rooms.clone().any(is_equal_to!(new_room_id)) {
|
||||||
|
let Ok(invite_count) = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.get_invite_count(room_id, sender_user)
|
||||||
|
.await
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
if *roomsince >= invite_count {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: figure out a timestamp we can use for remote invites
|
// TODO: figure out a timestamp we can use for remote invites
|
||||||
invite_state = services
|
let invite_state = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.invite_state(sender_user, room_id)
|
.invite_state(sender_user, room_id)
|
||||||
.await
|
.await
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
(timeline_pdus, limited) = (VecDeque::new(), true);
|
rooms.insert(
|
||||||
} else {
|
room_id.clone(),
|
||||||
TimelinePdus { pdus: timeline_pdus, limited } = match load_timeline(
|
assign!(sync_events::v5::response::Room::new(), {
|
||||||
services,
|
initial: Some(roomsince == &0),
|
||||||
sender_user,
|
invite_state,
|
||||||
room_id,
|
limited: true,
|
||||||
Some(roomsincecount),
|
}),
|
||||||
Some(PduCount::from(next_batch)),
|
);
|
||||||
*timeline_limit,
|
continue;
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
| Ok(value) => value,
|
|
||||||
| Err(err) => {
|
|
||||||
warn!("Encountered missing timeline in {}, error {}", room_id, err);
|
|
||||||
continue;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if all_knocked_rooms.clone().any(is_equal_to!(new_room_id)) {
|
||||||
|
let Ok(knock_count) = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.get_knock_count(room_id, sender_user)
|
||||||
|
.await
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
if *roomsince >= knock_count {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Ok(knock_state) = services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.knock_state(sender_user, room_id)
|
||||||
|
.await
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
rooms.insert(
|
||||||
|
room_id.clone(),
|
||||||
|
assign!(sync_events::v5::response::Room::new(), {
|
||||||
|
initial: Some(roomsince == &0),
|
||||||
|
invite_state: Some(knock_state),
|
||||||
|
limited: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_joined(sender_user, room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TimelinePdus { pdus: timeline_pdus, limited } = match load_timeline(
|
||||||
|
services,
|
||||||
|
sender_user,
|
||||||
|
room_id,
|
||||||
|
Some(roomsincecount),
|
||||||
|
Some(PduCount::from(next_batch)),
|
||||||
|
*timeline_limit,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
| Ok(value) => value,
|
||||||
|
| Err(err) => {
|
||||||
|
warn!("Encountered missing timeline in {}, error {}", room_id, err);
|
||||||
|
continue;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if body.extensions.account_data.enabled == Some(true) {
|
if body.extensions.account_data.enabled == Some(true) {
|
||||||
response.extensions.account_data.rooms.insert(
|
response.extensions.account_data.rooms.insert(
|
||||||
room_id.to_owned(),
|
room_id.to_owned(),
|
||||||
@@ -641,7 +722,6 @@ where
|
|||||||
},
|
},
|
||||||
initial: Some(roomsince == &0),
|
initial: Some(roomsince == &0),
|
||||||
is_dm: None,
|
is_dm: None,
|
||||||
invite_state,
|
|
||||||
unread_notifications: assign!(UnreadNotificationsCount::new(), {
|
unread_notifications: assign!(UnreadNotificationsCount::new(), {
|
||||||
highlight_count: Some(
|
highlight_count: Some(
|
||||||
services
|
services
|
||||||
@@ -769,6 +849,15 @@ async fn collect_typing_events(
|
|||||||
|
|
||||||
let mut typing_response = sync_events::v5::response::Typing::default();
|
let mut typing_response = sync_events::v5::response::Typing::default();
|
||||||
for (room_id, (_, _, roomsince)) in todo_rooms {
|
for (room_id, (_, _, roomsince)) in todo_rooms {
|
||||||
|
if !services
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.is_joined(sender_user, room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if services.rooms.typing.last_typing_update(room_id).await? <= *roomsince {
|
if services.rooms.typing.last_typing_update(room_id).await? <= *roomsince {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use conduwuit::{
|
|||||||
Err, Event, Result, debug, debug_error, debug_warn, defer, matrix::PartialPdu, trace,
|
Err, Event, Result, debug, debug_error, debug_warn, defer, matrix::PartialPdu, trace,
|
||||||
utils::time::jitter,
|
utils::time::jitter,
|
||||||
};
|
};
|
||||||
use futures::{FutureExt, StreamExt, future::try_join3};
|
use futures::{FutureExt, StreamExt, future::try_join4};
|
||||||
use ruma::{CanonicalJsonValue, EventId, RoomId, ServerName, UserId};
|
use ruma::{CanonicalJsonValue, EventId, RoomId, ServerName, UserId};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
@@ -69,9 +69,13 @@ impl super::Service {
|
|||||||
.and_then(|s| UserId::parse(s).ok())
|
.and_then(|s| UserId::parse(s).ok())
|
||||||
.is_some_and(|u| self.services.globals.user_is_local(&u));
|
.is_some_and(|u| self.services.globals.user_is_local(&u));
|
||||||
|
|
||||||
let (room_exists, is_disabled, ()) = try_join3(
|
let (room_exists, is_disabled, is_resident, ()) = try_join4(
|
||||||
self.services.metadata.exists(room_id).map(Ok),
|
self.services.metadata.exists(room_id).map(Ok),
|
||||||
self.services.metadata.is_disabled(room_id).map(Ok),
|
self.services.metadata.is_disabled(room_id).map(Ok),
|
||||||
|
self.services
|
||||||
|
.state_cache
|
||||||
|
.server_in_room(self.services.globals.server_name(), room_id)
|
||||||
|
.map(Ok),
|
||||||
self.acl_check(origin, room_id),
|
self.acl_check(origin, room_id),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@@ -85,12 +89,20 @@ impl super::Service {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the room doesn't exist (we don't have the create event), there's nothing
|
||||||
|
// we can do.
|
||||||
if !room_exists {
|
if !room_exists {
|
||||||
|
return Err!(Request(NotFound("Room is unknown to this server")));
|
||||||
|
}
|
||||||
|
// If the room does exist, but we aren't a resident of it, we might be
|
||||||
|
// interested in an out-of-band membership (for example, an inviter rescinding
|
||||||
|
// their invite).
|
||||||
|
if !is_resident {
|
||||||
if is_interesting_member_event {
|
if is_interesting_member_event {
|
||||||
// TODO: handle interesting membership events where we aren't in
|
// TODO: handle interesting membership events where we aren't in
|
||||||
// the room
|
// the room
|
||||||
}
|
}
|
||||||
return Err!(Request(NotFound("Room is unknown to this server")));
|
return Err!(Request(NotFound("This server does not have any members this room")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch create event
|
// Fetch create event
|
||||||
|
|||||||
@@ -104,24 +104,24 @@ impl super::Service {
|
|||||||
// Determine whether this PDU should be soft-failed.
|
// Determine whether this PDU should be soft-failed.
|
||||||
// If the auth check failed, invariably yes. Otherwise, only if the user isn't
|
// If the auth check failed, invariably yes. Otherwise, only if the user isn't
|
||||||
// allowed to redact the target event (if any).
|
// allowed to redact the target event (if any).
|
||||||
let mut should_soft_fail =
|
let redaction_permitted =
|
||||||
match (passes_current_state, incoming_pdu.redacts_id(&room_version_rules)) {
|
if let Some(redacted_id) = incoming_pdu.redacts_id(&room_version_rules) {
|
||||||
| (false, _) => true,
|
self.services
|
||||||
| (true, None) => false,
|
|
||||||
| (true, Some(redact_id)) => self
|
|
||||||
.services
|
|
||||||
.state_accessor
|
.state_accessor
|
||||||
.user_can_redact(&redact_id, incoming_pdu.sender(), room_id, true)
|
.user_can_redact(&redacted_id, incoming_pdu.sender(), room_id, true)
|
||||||
.await
|
.await
|
||||||
.is_ok_and(is_true!()),
|
.is_ok_and(is_true!())
|
||||||
|
} else {
|
||||||
|
true
|
||||||
};
|
};
|
||||||
|
let mut should_soft_fail = !redaction_permitted || !passes_current_state;
|
||||||
|
|
||||||
if !should_soft_fail {
|
if !should_soft_fail {
|
||||||
// Now we can perform check 7, which is ensuring the event passes policy server
|
// Now we can perform check 7, which is ensuring the event passes policy server
|
||||||
// checks.
|
// checks.
|
||||||
// We explicitly only do this if we aren't already going to soft-fail the event,
|
// We explicitly only do this if we aren't already going to soft-fail the event,
|
||||||
// since the policy server refusing this event also soft-fails it.
|
// since the policy server refusing this event also soft-fails it.
|
||||||
debug!(event_id = %incoming_pdu.event_id, "Checking policy server for event");
|
debug!("Checking policy server for event");
|
||||||
should_soft_fail = !self
|
should_soft_fail = !self
|
||||||
.policy_server_check_7(&incoming_pdu, &mut val, &room_version_rules)
|
.policy_server_check_7(&incoming_pdu, &mut val, &room_version_rules)
|
||||||
.await
|
.await
|
||||||
@@ -153,6 +153,12 @@ impl super::Service {
|
|||||||
should_soft_fail = true;
|
should_soft_fail = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
debug!(
|
||||||
|
%redaction_permitted,
|
||||||
|
%passes_current_state,
|
||||||
|
"Intending to soft-fail event (skipping further PDU checks)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The PDU has now passed all checks! We can now promote it (or soft-fail it if
|
// The PDU has now passed all checks! We can now promote it (or soft-fail it if
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use conduwuit::{Err, Result, matrix::Event, pdu::PartialPdu};
|
use conduwuit::{Err, Result, matrix::Event, pdu::PartialPdu, trace};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
EventId, RoomId, UserId,
|
EventId, RoomId, UserId,
|
||||||
events::{
|
events::{
|
||||||
@@ -46,6 +46,7 @@ impl super::Service {
|
|||||||
let power_levels = self.get_room_power_levels(room_id).await;
|
let power_levels = self.get_room_power_levels(room_id).await;
|
||||||
|
|
||||||
if power_levels.user_can_redact_event_of_other(sender) {
|
if power_levels.user_can_redact_event_of_other(sender) {
|
||||||
|
trace!(%sender, "Sender is allowed to redact other users' events");
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,10 +60,12 @@ impl super::Service {
|
|||||||
},
|
},
|
||||||
| _ => false,
|
| _ => false,
|
||||||
};
|
};
|
||||||
|
trace!(%is_own_event, "User can redact own event");
|
||||||
|
|
||||||
return Ok(is_own_event);
|
return Ok(is_own_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace!("User is not permitted to redact their own event nor others' events");
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user