Compare commits

...
44 Commits
Author SHA1 Message Date
Jade 8c7cc68cbf fix(ci): Don't use shallow clone when we're comparing git history 2025-10-15 12:53:15 +00:00
Ginger dc047b635f feat: Send notifications to systemd when a reload is triggered 2025-10-15 03:12:25 +00:00
Renovate Bot cc4c2fed25 chore(deps): lock file maintenance 2025-10-13 12:05:52 +00:00
Renovate Bot 17e47ecd6d chore(deps): update github-actions-non-major 2025-10-13 11:27:22 +00:00
Jade b1d5ff477b chore: Update renovate config
- Limit renovate updates to mondays
- Don't group lock updates
- Update checksums if possible
2025-10-13 11:26:26 +00:00
Renovate Bot d6dc01ac2c chore(deps): update https://code.forgejo.org/actions/checkout action to v5 2025-10-13 10:41:20 +00:00
Jimmy Brush 77ebe0d02f fix(!714): Off-by-one in v5 sync
Simplified sliding sync specifies ranges to be inclusive while rust ranges are
exclusive.
2025-10-13 10:28:19 +00:00
Renovate Bot 81e3d4c905 chore(deps): update dependency cargo-bins/cargo-binstall to v1.15.7 2025-10-13 10:27:18 +00:00
nexy7574 cb8f36444c feat: Proactively read Content-Length to reject oversized uploads 2025-10-12 19:42:57 +00:00
nexy7574 799def70dc feat: Produce even more informative errors when saving media fails 2025-10-12 19:42:57 +00:00
nexy7574 20f741d0e5 feat: Produce a more informative error when uploading media fails 2025-10-12 19:42:57 +00:00
Renovate Bot d38f4a24f2 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.146.0 2025-10-11 05:03:03 +00:00
Renovate Bot 6604cc4df9 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.144.1 2025-10-10 05:01:39 +00:00
Renovate Bot 89aa4d1eae chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.143.1 2025-10-09 05:03:56 +00:00
Renovate Bot 9231ea5114 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.141.0 2025-10-08 05:01:41 +00:00
Renovate Bot 4a3c72338d chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.138.1 2025-10-07 05:02:54 +00:00
Renovate Bot ab862f4383 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.135.5 2025-10-06 05:01:26 +00:00
Renovate Bot bd43be931a chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.135.4 2025-10-05 05:03:52 +00:00
Ginger 148240cbbb fix: Add missing ldap3 feature 2025-10-01 18:55:30 +00:00
Renovate Bot 2e9e42d9ae chore(deps): update rust crate ldap3 to 0.12.0 2025-10-01 18:55:30 +00:00
Renovate Bot 89fbda0d6e chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.132.5 2025-10-01 05:03:28 +00:00
Renovate Bot c97eb5c889 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.132.2 2025-09-30 05:01:26 +00:00
Ginger 366ec46b26 fix: Upload debs built on a schedule 2025-09-29 14:17:44 +00:00
ginger 62a98ebc71 fix: Upload RPMs built on a schedule 2025-09-29 14:17:44 +00:00
Renovate Bot 439c605efe chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.131.9 2025-09-29 05:03:13 +00:00
Renovate Bot 32df2f3487 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.131.8 2025-09-28 05:03:46 +00:00
Renovate Bot 692da7ffc2 chore(deps): update dependency cargo-bins/cargo-binstall to v1.15.6 2025-09-27 16:17:44 +00:00
Renovate Bot 1082b24b1d chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.131.6 2025-09-27 05:03:28 +00:00
nexy7574 f45ceedb8a fix(upgrade): Potentially resolve CI clippy errors
I'm not convinced this isn't a rust bug itself,
but CI was complaining about lifetimes
and those complaints couldn't be reproduced locally,
so this should probably fix it maybe?
2025-09-26 18:47:49 +01:00
nexy7574 d614e43981 fix(stateres): Creators can always unban
Also basically rewrote all of the event auth logs to be more digestable
2025-09-26 18:47:49 +01:00
Renovate Bot 1e0e7a31aa chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.131.2 2025-09-26 05:02:43 +00:00
Renovate Bot 92fffe9c82 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.130.1 2025-09-25 08:28:06 +00:00
Renovate Bot 11e51300a5 chore(deps): update github-actions-non-major 2025-09-25 08:16:34 +00:00
Jade Ellis ef84e1bb02 fix(v12): Create tombstone event on room upgrade 2025-09-25 08:15:23 +00:00
nexy7574 1887d58df8 fix: V12 room upgrades 2025-09-25 08:15:23 +00:00
nexy7574 c66f6f8900 fix(stateres): Correctly fetch missing auth events for incoming PDUs 2025-09-25 02:54:00 +01:00
Ginger 902fe7b7ab fix: Fix panic in debug builds caused by MSC4133 migration 2025-09-24 16:45:11 -04:00
Renovate Bot 472e1fee17 chore(deps): update ghcr.io/renovatebot/renovate docker tag to v41.127.2 2025-09-24 05:03:46 +00:00
Jade Ellis 3c6f2d07e0 ci: Only run RPM builds on tags or schedule 2025-09-23 22:16:46 +01:00
ginger 43254aa396 fix: Attempt to enable RPM signing 2025-09-23 22:15:01 +01:00
Tom Foster 48ebf86335 feat(ci): Add Fedora RPM package build workflow
Build and publish RPM packages for Fedora using rpkg and official
rust-packaging macros. Packages are automatically signed by Forgejo's
built-in package registry (introduced in v9.0).

Publishes packages to organised groups:
- continuwuity (binary): base group (stable/dev/branch-name)
- continuwuity-debuginfo: GROUP-debug
- continuwuity (source RPM): GROUP-src

Workflow triggers on pushes to relevant paths and version tags (v*).
Tagged releases use clean version numbers (v1.2.3 becomes 1.2.3-1)
while branch builds use sanitised branch name versioning.

Uses dnf builddep to install build dependencies directly from the
generated SRPM, ensuring consistency between CI and spec file without
duplication. This also prevents hiding packaging issues that could
occur with --nodeps fallbacks.
2025-09-23 22:15:00 +01:00
Ginger f1e3b4907e Build Debian packages and upload them to Forgejo's repository (#996)
This uses the existing `cargo-deb` metadata.

Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/996
Reviewed-by: Tom Foster <tom@tcpip.uk>
Reviewed-by: nex <nex@noreply.forgejo.ellis.link>
Co-authored-by: Ginger <ginger@gingershaped.computer>
Co-committed-by: Ginger <ginger@gingershaped.computer>
2025-09-23 19:53:37 +00:00
Jade Ellis 9346a0d05e fix(ci): Typo 2025-09-23 12:55:04 +01:00
nyanbinary c99faae115 chore(nix): bump rocksdb version in flake.nix to 10.5.fb 2025-09-23 06:31:10 +00:00
32 changed files with 1657 additions and 827 deletions

No files matched your search

@@ -61,8 +61,8 @@ runs:
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
flavour: | flavor: |
suffix=${{ inputs.tag_suffix }} suffix=${{ inputs.tag_suffix }},onlatest=true
tags: | tags: |
type=semver,pattern={{version}},prefix=v type=semver,pattern={{version}},prefix=v
type=semver,pattern={{major}}.{{minor}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.0.') }},prefix=v type=semver,pattern={{major}}.{{minor}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.0.') }},prefix=v
+148
View File
@@ -0,0 +1,148 @@
name: Build / Debian DEB
concurrency:
group: "build-debian-${{ forge.ref }}"
cancel-in-progress: true
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
schedule:
- cron: '30 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
container: ["ubuntu-latest", "ubuntu-previous", "debian-latest", "debian-oldstable"]
container:
image: "ghcr.io/tcpipuk/act-runner:${{ matrix.container }}"
steps:
- name: Get Debian version
id: debian-version
run: |
VERSION=$(cat /etc/debian_version)
DISTRIBUTION=$(lsb_release -sc 2>/dev/null)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "distribution=$DISTRIBUTION" >> $GITHUB_OUTPUT
echo "Debian distribution: $DISTRIBUTION ($VERSION)"
- name: Checkout repository with full history
uses: https://code.forgejo.org/actions/checkout@v5
with:
fetch-depth: 0
- name: Cache Cargo registry
uses: https://code.forgejo.org/actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-debian-${{ steps.debian-version.outputs.distribution }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-debian-${{ steps.debian-version.outputs.distribution }}-
- name: Setup sccache
uses: https://git.tomfos.tr/tom/sccache-action@v1
- name: Configure sccache environment
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "SCCACHE_CACHE_SIZE=10G" >> $GITHUB_ENV
# Aggressive GC since cache restores don't increment counter
echo "CARGO_INCREMENTAL_GC_TRIGGER=5" >> $GITHUB_ENV
- name: Setup Rust nightly
uses: ./.forgejo/actions/setup-rust
with:
rust-version: nightly
github-token: ${{ secrets.GH_PUBLIC_RO }}
- name: Get package version and component
id: package-meta
run: |
BASE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[] | select(.name == \"conduwuit\").version" | sed 's/[^a-zA-Z0-9.+]/~/g')
# VERSION is the package version, COMPONENT is used in
# apt's repository config like a git repo branch
if [[ "${{ forge.ref }}" == "refs/tags/"* ]]; then
# Use the "stable" component for tagged releases
COMPONENT="stable"
VERSION=$BASE_VERSION
else
# Use the "dev" component for development builds
SHA=$(echo "${{ forge.sha }}" | cut -c1-7)
DATE=$(date +%Y%m%d)
if [ "${{ forge.ref_name }}" = "main" ]; then
COMPONENT="dev"
else
# Use the sanitized ref name as the component for feature branches
COMPONENT="dev-$(echo '${{ forge.ref_name }}' | sed 's/[^a-zA-Z0-9.+]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-30)"
fi
CLEAN_COMPONENT=$(echo $COMPONENT | sed 's/[^a-zA-Z0-9.+]/~/g')
VERSION="$BASE_VERSION~git$DATE.$SHA-$CLEAN_COMPONENT"
fi
echo "component=$COMPONENT" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Component: $COMPONENT"
echo "Version: $VERSION"
- name: Install cargo-deb
run: |
if command -v cargo-deb &> /dev/null; then
echo "cargo-deb already available"
else
echo "Installing cargo-deb"
cargo-binstall -y --no-symlinks cargo-deb
fi
- name: Install build dependencies
run: |
apt-get update -y
# Build dependencies for rocksdb
apt-get install -y clang liburing-dev
- name: Run cargo-deb
id: cargo-deb
run: |
DEB_PATH=$(cargo deb --deb-version ${{ steps.package-meta.outputs.version }})
echo "path=$DEB_PATH" >> $GITHUB_OUTPUT
- name: Test deb installation
run: |
echo "Installing: ${{ steps.cargo-deb.outputs.path }}"
apt-get install -y ${{ steps.cargo-deb.outputs.path }}
dpkg -s continuwuity
[ -f /usr/bin/conduwuit ] && echo "✅ Binary installed successfully"
[ -f /usr/lib/systemd/system/conduwuit.service ] && echo "✅ Systemd service installed"
[ -f /etc/conduwuit/conduwuit.toml ] && echo "✅ Config file installed"
- name: Upload deb artifact
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: continuwuity-${{ steps.debian-version.outputs.distribution }}
path: ${{ steps.cargo-deb.outputs.path }}
- name: Publish to Forgejo package registry
if: ${{ forge.event_name == 'push' || forge.event_name == 'workflow_dispatch' || forge.event_name == 'schedule' }}
run: |
OWNER="continuwuation"
DISTRIBUTION=${{ steps.debian-version.outputs.distribution }}
COMPONENT=${{ steps.package-meta.outputs.component }}
DEB=${{ steps.cargo-deb.outputs.path }}
echo "Publishing: $DEB in component $COMPONENT for distribution $DISTRIBUTION"
curl --fail-with-body \
-X PUT \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
--upload-file "$DEB" \
"${{ forge.server_url }}/api/packages/$OWNER/debian/pool/$DISTRIBUTION/$COMPONENT/upload"
+389
View File
@@ -0,0 +1,389 @@
name: Build / Fedora RPM
concurrency:
group: "build-fedora-${{ github.ref }}"
cancel-in-progress: true
on:
push:
tags:
- "v*.*.*"
# paths:
# - 'pkg/fedora/**'
# - 'src/**'
# - 'Cargo.toml'
# - 'Cargo.lock'
# - '.forgejo/workflows/build-fedora.yml'
workflow_dispatch:
schedule:
- cron: '30 0 * * *'
jobs:
build:
runs-on: fedora-latest
steps:
- name: Detect Fedora version
id: fedora
run: |
VERSION=$(rpm -E %fedora)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Fedora version: $VERSION"
- name: Checkout repository with full history
uses: https://code.forgejo.org/actions/checkout@v5
with:
fetch-depth: 0
- name: Cache DNF packages
uses: https://code.forgejo.org/actions/cache@v4
with:
path: |
/var/cache/dnf
/var/cache/yum
key: dnf-fedora${{ steps.fedora.outputs.version }}-${{ hashFiles('pkg/fedora/continuwuity.spec.rpkg') }}-v1
restore-keys: |
dnf-fedora${{ steps.fedora.outputs.version }}-
- name: Cache Cargo registry
uses: https://code.forgejo.org/actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-fedora${{ steps.fedora.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-fedora${{ steps.fedora.outputs.version }}-
- name: Cache Rust build dependencies
uses: https://code.forgejo.org/actions/cache@v4
with:
path: |
~/rpmbuild/BUILD/*/target/release/deps
~/rpmbuild/BUILD/*/target/release/build
~/rpmbuild/BUILD/*/target/release/.fingerprint
~/rpmbuild/BUILD/*/target/release/incremental
key: rust-deps-fedora${{ steps.fedora.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
rust-deps-fedora${{ steps.fedora.outputs.version }}-
- name: Setup sccache
uses: https://git.tomfos.tr/tom/sccache-action@v1
- name: Configure sccache environment
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV
echo "SCCACHE_CACHE_SIZE=10G" >> $GITHUB_ENV
# Aggressive GC since cache restores don't increment counter
echo "CARGO_INCREMENTAL_GC_TRIGGER=5" >> $GITHUB_ENV
- name: Install base RPM tools
run: |
dnf install -y --setopt=keepcache=1 \
fedora-packager \
python3-pip \
rpm-sign \
rpkg \
wget
- name: Setup build environment and build SRPM
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global user.email "ci@continuwuity.org"
git config --global user.name "Continuwuity"
rpmdev-setuptree
cd "$GITHUB_WORKSPACE"
# Determine release suffix and version based on ref type and branch
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
# Tags get clean version numbers for stable releases
RELEASE_SUFFIX=""
TAG_NAME="${{ github.ref_name }}"
# Extract version from tag (remove v prefix if present)
TAG_VERSION=$(echo "$TAG_NAME" | sed 's/^v//')
# Create spec file with tag version
sed -e "s/^Version:.*$/Version: $TAG_VERSION/" \
-e "s/^Release:.*$/Release: 1%{?dist}/" \
pkg/fedora/continuwuity.spec.rpkg > continuwuity.spec.rpkg
elif [ "${{ github.ref_name }}" = "main" ]; then
# Main branch gets .dev suffix
RELEASE_SUFFIX=".dev"
# Replace the Release line to include our suffix
sed "s/^Release:.*$/Release: 1${RELEASE_SUFFIX}%{?dist}/" \
pkg/fedora/continuwuity.spec.rpkg > continuwuity.spec.rpkg
else
# Other branches get sanitized branch name as suffix
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9]/_/g' | cut -c1-20)
RELEASE_SUFFIX=".${SAFE_BRANCH}"
# Replace the Release line to include our suffix
sed "s/^Release:.*$/Release: 1${RELEASE_SUFFIX}%{?dist}/" \
pkg/fedora/continuwuity.spec.rpkg > continuwuity.spec.rpkg
fi
rpkg srpm --outdir "$HOME/rpmbuild/SRPMS"
ls -la $HOME/rpmbuild/SRPMS/
- name: Install build dependencies from SRPM
run: |
SRPM=$(find "$HOME/rpmbuild/SRPMS" -name "*.src.rpm" | head -1)
if [ -z "$SRPM" ]; then
echo "Error: No SRPM file found"
exit 1
fi
echo "Installing build dependencies from: $(basename $SRPM)"
dnf builddep -y "$SRPM"
- name: Build RPM from SRPM
run: |
SRPM=$(find "$HOME/rpmbuild/SRPMS" -name "*.src.rpm" | head -1)
if [ -z "$SRPM" ]; then
echo "Error: No SRPM file found"
exit 1
fi
echo "Building from SRPM: $SRPM"
rpmbuild --rebuild "$SRPM" \
--define "_topdir $HOME/rpmbuild" \
--define "_sourcedir $GITHUB_WORKSPACE" \
--nocheck # Skip %check section to avoid test dependencies
- name: Test RPM installation
run: |
# Find the main binary RPM (exclude debug and source RPMs)
RPM=$(find "$HOME/rpmbuild/RPMS" -name "continuwuity-*.rpm" \
! -name "*debuginfo*" \
! -name "*debugsource*" \
! -name "*.src.rpm" | head -1)
if [ -z "$RPM" ]; then
echo "Error: No binary RPM file found"
exit 1
fi
echo "Testing installation of: $RPM"
# Dry run first
rpm -qpi "$RPM"
echo ""
rpm -qpl "$RPM"
# Actually install it
dnf install -y "$RPM"
# Verify installation
rpm -qa | grep continuwuity
# Check that the binary exists
[ -f /usr/bin/conduwuit ] && echo "✅ Binary installed successfully"
[ -f /usr/lib/systemd/system/conduwuit.service ] && echo "✅ Systemd service installed"
[ -f /etc/conduwuit/conduwuit.toml ] && echo "✅ Config file installed"
- name: List built packages
run: |
echo "Binary RPMs:"
find "$HOME/rpmbuild/RPMS" -name "*.rpm" -type f -exec ls -la {} \;
echo ""
echo "Source RPMs:"
find "$HOME/rpmbuild/SRPMS" -name "*.rpm" -type f -exec ls -la {} \;
- name: Collect artifacts
run: |
mkdir -p artifacts
find "$HOME/rpmbuild/RPMS" -name "*.rpm" -type f -exec cp {} artifacts/ \;
find "$HOME/rpmbuild/SRPMS" -name "*.rpm" -type f -exec cp {} artifacts/ \;
cd artifacts
echo "Build Information:" > BUILD_INFO.txt
echo "==================" >> BUILD_INFO.txt
echo "Git commit: ${{ github.sha }}" >> BUILD_INFO.txt
echo "Git branch: ${{ github.ref_name }}" >> BUILD_INFO.txt
echo "Build date: $(date -u +%Y-%m-%d_%H:%M:%S_UTC)" >> BUILD_INFO.txt
echo "" >> BUILD_INFO.txt
echo "Package contents:" >> BUILD_INFO.txt
echo "-----------------" >> BUILD_INFO.txt
for rpm in *.rpm; do
echo "" >> BUILD_INFO.txt
echo "File: $rpm" >> BUILD_INFO.txt
rpm -qpi "$rpm" 2>/dev/null | grep -E "^(Name|Version|Release|Architecture|Size)" >> BUILD_INFO.txt
done
ls -la
- name: Upload binary RPM artifact
run: |
# Find the main binary RPM (exclude debug and source RPMs)
BIN_RPM=$(find artifacts -name "continuwuity-*.rpm" \
! -name "*debuginfo*" \
! -name "*debugsource*" \
! -name "*.src.rpm" \
-type f)
mkdir -p upload-bin
cp $BIN_RPM upload-bin/
- name: Upload binary RPM
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: continuwuity
path: upload-bin/
- name: Upload debug RPM artifact
uses: https://code.forgejo.org/actions/upload-artifact@v3
with:
name: continuwuity-debug
path: artifacts/*debuginfo*.rpm
- name: Publish to RPM Package Registry
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }}
run: |
# Find the main binary RPM (exclude debug and source RPMs)
RPM=$(find artifacts -name "continuwuity-*.rpm" \
! -name "*debuginfo*" \
! -name "*debugsource*" \
! -name "*.src.rpm" \
-type f | head -1)
if [ -z "$RPM" ]; then
echo "No binary RPM found to publish"
exit 0
fi
RPM_BASENAME=$(basename "$RPM")
echo "Publishing: $RPM_BASENAME"
# Determine the group based on ref type and branch
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
GROUP="stable"
# For tags, extract the tag name for version info
TAG_NAME="${{ github.ref_name }}"
elif [ "${{ github.ref_name }}" = "main" ]; then
GROUP="dev"
else
# Use sanitized branch name as group for feature branches
GROUP=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-30)
fi
PACKAGE_INFO=$(rpm -qpi "$RPM" 2>/dev/null)
PACKAGE_NAME=$(echo "$PACKAGE_INFO" | grep "^Name" | awk '{print $3}')
PACKAGE_VERSION=$(echo "$PACKAGE_INFO" | grep "^Version" | awk '{print $3}')
PACKAGE_RELEASE=$(echo "$PACKAGE_INFO" | grep "^Release" | awk '{print $3}')
PACKAGE_ARCH=$(echo "$PACKAGE_INFO" | grep "^Architecture" | awk '{print $2}')
# Full version includes release
FULL_VERSION="${PACKAGE_VERSION}-${PACKAGE_RELEASE}"
# Forgejo's RPM registry cannot overwrite existing packages, so we must delete first
# 404 is OK if package doesn't exist yet
echo "Removing any existing package: $PACKAGE_NAME-$FULL_VERSION.$PACKAGE_ARCH"
RESPONSE=$(curl -s -w "\n%{http_code}" -X DELETE \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
"https://forgejo.ellis.link/api/packages/continuwuation/rpm/$GROUP/package/$PACKAGE_NAME/$FULL_VERSION/$PACKAGE_ARCH")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
if [ "$HTTP_CODE" != "204" ] && [ "$HTTP_CODE" != "404" ]; then
echo "ERROR: Failed to delete package (HTTP $HTTP_CODE)"
echo "$RESPONSE" | head -n -1
exit 1
fi
curl --fail-with-body \
-X PUT \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/x-rpm" \
-T "$RPM" \
"https://forgejo.ellis.link/api/packages/continuwuation/rpm/$GROUP/upload?sign=true"
echo ""
echo "✅ Published binary RPM to: https://forgejo.ellis.link/continuwuation/-/packages/rpm/continuwuity/"
echo "Group: $GROUP"
# Upload debug RPMs to separate group
DEBUG_RPMS=$(find artifacts -name "*debuginfo*.rpm")
if [ -n "$DEBUG_RPMS" ]; then
echo ""
echo "Publishing debug RPMs to group: ${GROUP}-debug"
for DEBUG_RPM in $DEBUG_RPMS; do
echo "Publishing: $(basename "$DEBUG_RPM")"
DEBUG_INFO=$(rpm -qpi "$DEBUG_RPM" 2>/dev/null)
DEBUG_NAME=$(echo "$DEBUG_INFO" | grep "^Name" | awk '{print $3}')
DEBUG_VERSION=$(echo "$DEBUG_INFO" | grep "^Version" | awk '{print $3}')
DEBUG_RELEASE=$(echo "$DEBUG_INFO" | grep "^Release" | awk '{print $3}')
DEBUG_ARCH=$(echo "$DEBUG_INFO" | grep "^Architecture" | awk '{print $2}')
DEBUG_FULL_VERSION="${DEBUG_VERSION}-${DEBUG_RELEASE}"
# Must delete existing package first (Forgejo limitation)
RESPONSE=$(curl -s -w "\n%{http_code}" -X DELETE \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
"https://forgejo.ellis.link/api/packages/continuwuation/rpm/${GROUP}-debug/package/$DEBUG_NAME/$DEBUG_FULL_VERSION/$DEBUG_ARCH")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
if [ "$HTTP_CODE" != "204" ] && [ "$HTTP_CODE" != "404" ]; then
echo "ERROR: Failed to delete debug package (HTTP $HTTP_CODE)"
echo "$RESPONSE" | head -n -1
exit 1
fi
curl --fail-with-body \
-X PUT \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/x-rpm" \
-T "$DEBUG_RPM" \
"https://forgejo.ellis.link/api/packages/continuwuation/rpm/${GROUP}-debug/upload?sign=true"
done
echo "✅ Published debug RPMs to group: ${GROUP}-debug"
fi
# Also upload the SRPM to separate group
SRPM=$(find artifacts -name "*.src.rpm" | head -1)
if [ -n "$SRPM" ]; then
echo ""
echo "Publishing source RPM: $(basename "$SRPM")"
echo "Publishing to group: ${GROUP}-src"
SRPM_INFO=$(rpm -qpi "$SRPM" 2>/dev/null)
SRPM_NAME=$(echo "$SRPM_INFO" | grep "^Name" | awk '{print $3}')
SRPM_VERSION=$(echo "$SRPM_INFO" | grep "^Version" | awk '{print $3}')
SRPM_RELEASE=$(echo "$SRPM_INFO" | grep "^Release" | awk '{print $3}')
SRPM_FULL_VERSION="${SRPM_VERSION}-${SRPM_RELEASE}"
# Must delete existing SRPM first (Forgejo limitation)
echo "Removing any existing SRPM: $SRPM_NAME-$SRPM_FULL_VERSION.src"
RESPONSE=$(curl -s -w "\n%{http_code}" -X DELETE \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
"https://forgejo.ellis.link/api/packages/continuwuation/rpm/${GROUP}-src/package/$SRPM_NAME/$SRPM_FULL_VERSION/src")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
if [ "$HTTP_CODE" != "204" ] && [ "$HTTP_CODE" != "404" ]; then
echo "ERROR: Failed to delete SRPM (HTTP $HTTP_CODE)"
echo "$RESPONSE" | head -n -1
exit 1
fi
curl --fail-with-body \
-X PUT \
-H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/x-rpm" \
-T "$SRPM" \
"https://forgejo.ellis.link/api/packages/continuwuation/rpm/${GROUP}-src/upload?sign=true"
echo "✅ Published source RPM to group: ${GROUP}-src"
fi
+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
name: Renovate name: Renovate
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: ghcr.io/renovatebot/renovate:41.125.2@sha256:880470695f96411e67d4ada54ea11998a6f7ddf6fddacf7d2eeae7c49e89d420 image: ghcr.io/renovatebot/renovate:41.146.4@sha256:bb70194b7405faf10a6f279b60caa10403a440ba37d158c5a4ef0ae7b67a0f92
options: --tmpfs /tmp:exec options: --tmpfs /tmp:exec
steps: steps:
- name: Checkout - name: Checkout
+3 -2
View File
@@ -7,6 +7,7 @@ on:
- "Cargo.lock" - "Cargo.lock"
- "Cargo.toml" - "Cargo.toml"
- "rust-toolchain.toml" - "rust-toolchain.toml"
- ".forgejo/workflows/update-flake-hashes.yml"
jobs: jobs:
update-flake-hashes: update-flake-hashes:
@@ -14,13 +15,13 @@ jobs:
steps: steps:
- uses: https://code.forgejo.org/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 - uses: https://code.forgejo.org/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with: with:
fetch-depth: 1 fetch-depth: 0
fetch-tags: false fetch-tags: false
fetch-single-branch: true fetch-single-branch: true
submodules: false submodules: false
persist-credentials: false persist-credentials: false
- uses: https://github.com/cachix/install-nix-action@a809471b5c7c913aa67bec8f459a11a0decc3fce # v31.6.2 - uses: https://github.com/cachix/install-nix-action@7ab6e7fd29da88e74b1e314a4ae9ac6b5cda3801 # v31.8.0
with: with:
nix_path: nixpkgs=channel:nixos-unstable nix_path: nixpkgs=channel:nixos-unstable
Generated
+321 -604
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -551,9 +551,9 @@ features = ["std"]
version = "1.0.2" version = "1.0.2"
[workspace.dependencies.ldap3] [workspace.dependencies.ldap3]
version = "0.11.5" version = "0.12.0"
default-features = false default-features = false
features = ["sync", "tls-rustls"] features = ["sync", "tls-rustls", "rustls-provider"]
[workspace.dependencies.resolv-conf] [workspace.dependencies.resolv-conf]
version = "0.7.5" version = "0.7.5"
+1 -1
View File
@@ -48,7 +48,7 @@ EOF
# Developer tool versions # Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall # renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.15.5 ENV BINSTALL_VERSION=1.15.7
# renovate: datasource=github-releases depName=psastras/sbom-rs # renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1 ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree # renovate: datasource=crate depName=lddtree
+1 -1
View File
@@ -18,7 +18,7 @@ RUN --mount=type=cache,target=/etc/apk/cache apk add \
# Developer tool versions # Developer tool versions
# renovate: datasource=github-releases depName=cargo-bins/cargo-binstall # renovate: datasource=github-releases depName=cargo-bins/cargo-binstall
ENV BINSTALL_VERSION=1.15.5 ENV BINSTALL_VERSION=1.15.7
# renovate: datasource=github-releases depName=psastras/sbom-rs # renovate: datasource=github-releases depName=psastras/sbom-rs
ENV CARGO_SBOM_VERSION=0.9.1 ENV CARGO_SBOM_VERSION=0.9.1
# renovate: datasource=crate depName=lddtree # renovate: datasource=crate depName=lddtree
+1
View File
@@ -10,6 +10,7 @@
- [Kubernetes](deploying/kubernetes.md) - [Kubernetes](deploying/kubernetes.md)
- [Arch Linux](deploying/arch-linux.md) - [Arch Linux](deploying/arch-linux.md)
- [Debian](deploying/debian.md) - [Debian](deploying/debian.md)
- [Fedora](deploying/fedora.md)
- [FreeBSD](deploying/freebsd.md) - [FreeBSD](deploying/freebsd.md)
- [TURN](turn.md) - [TURN](turn.md)
- [Appservices](appservices.md) - [Appservices](appservices.md)
+201
View File
@@ -0,0 +1,201 @@
# RPM Installation Guide
Continuwuity is available as RPM packages for Fedora, RHEL, and compatible distributions.
The RPM packaging files are maintained in the `fedora/` directory:
- `continuwuity.spec.rpkg` - RPM spec file using rpkg macros for building from git
- `continuwuity.service` - Systemd service file for the server
- `RPM-GPG-KEY-continuwuity.asc` - GPG public key for verifying signed packages
RPM packages built by CI are signed with our GPG key (Ed25519, ID: `5E0FF73F411AAFCA`).
```bash
# Import the signing key
sudo rpm --import https://forgejo.ellis.link/continuwuation/continuwuity/raw/branch/main/fedora/RPM-GPG-KEY-continuwuity.asc
# Verify a downloaded package
rpm --checksig continuwuity-*.rpm
```
## Installation methods
**Stable releases** (recommended)
```bash
# Add the repository and install
sudo dnf config-manager addrepo --from-repofile=https://forgejo.ellis.link/api/packages/continuwuation/rpm/stable/continuwuation.repo
sudo dnf install continuwuity
```
**Development builds** from main branch
```bash
# Add the dev repository and install
sudo dnf config-manager addrepo --from-repofile=https://forgejo.ellis.link/api/packages/continuwuation/rpm/dev/continuwuation.repo
sudo dnf install continuwuity
```
**Feature branch builds** (example: `tom/new-feature`)
```bash
# Branch names are sanitized (slashes become hyphens, lowercase only)
sudo dnf config-manager addrepo --from-repofile=https://forgejo.ellis.link/api/packages/continuwuation/rpm/tom-new-feature/continuwuation.repo
sudo dnf install continuwuity
```
**Direct installation** without adding repository
```bash
# Latest stable release
sudo dnf install https://forgejo.ellis.link/api/packages/continuwuation/rpm/stable/continuwuity
# Latest development build
sudo dnf install https://forgejo.ellis.link/api/packages/continuwuation/rpm/dev/continuwuity
# Specific feature branch
sudo dnf install https://forgejo.ellis.link/api/packages/continuwuation/rpm/branch-name/continuwuity
```
**Manual repository configuration** (alternative method)
```bash
cat << 'EOF' | sudo tee /etc/yum.repos.d/continuwuity.repo
[continuwuity]
name=Continuwuity - Matrix homeserver
baseurl=https://forgejo.ellis.link/api/packages/continuwuation/rpm/stable
enabled=1
gpgcheck=1
gpgkey=https://forgejo.ellis.link/continuwuation/continuwuity/raw/branch/main/fedora/RPM-GPG-KEY-continuwuity.asc
EOF
sudo dnf install continuwuity
```
## Package management
**Automatic updates** with DNF Automatic
```bash
# Install and configure
sudo dnf install dnf-automatic
sudo nano /etc/dnf/automatic.conf # Set: apply_updates = yes
sudo systemctl enable --now dnf-automatic.timer
```
**Manual updates**
```bash
# Check for updates
sudo dnf check-update continuwuity
# Update to latest version
sudo dnf update continuwuity
```
**Switching channels** (stable/dev/feature branches)
```bash
# List enabled repositories
dnf repolist | grep continuwuation
# Disable current repository
sudo dnf config-manager --set-disabled continuwuation-stable # or -dev, or branch name
# Enable desired repository
sudo dnf config-manager --set-enabled continuwuation-dev # or -stable, or branch name
# Update to the new channel's version
sudo dnf update continuwuity
```
**Verifying installation**
```bash
# Check installed version
rpm -q continuwuity
# View package information
rpm -qi continuwuity
# List installed files
rpm -ql continuwuity
# Verify package integrity
rpm -V continuwuity
```
## Service management and removal
**Systemd service commands**
```bash
# Start the service
sudo systemctl start conduwuit
# Enable on boot
sudo systemctl enable conduwuit
# Check status
sudo systemctl status conduwuit
# View logs
sudo journalctl -u conduwuit -f
```
**Uninstallation**
```bash
# Stop and disable the service
sudo systemctl stop conduwuit
sudo systemctl disable conduwuit
# Remove the package
sudo dnf remove continuwuity
# Remove the repository (optional)
sudo rm /etc/yum.repos.d/continuwuation-*.repo
```
## Troubleshooting
**GPG key errors**: Temporarily disable GPG checking
```bash
sudo dnf --nogpgcheck install continuwuity
```
**Repository metadata issues**: Clear and rebuild cache
```bash
sudo dnf clean all
sudo dnf makecache
```
**Finding specific versions**
```bash
# List all available versions
dnf --showduplicates list continuwuity
# Install a specific version
sudo dnf install continuwuity-<version>
```
## Building locally
Build the RPM locally using rpkg:
```bash
# Install dependencies
sudo dnf install rpkg rpm-build cargo-rpm-macros systemd-rpm-macros
# Clone the repository
git clone https://forgejo.ellis.link/continuwuation/continuwuity.git
cd continuwuity
# Build SRPM
rpkg srpm
# Build RPM
rpmbuild --rebuild *.src.rpm
```
Generated
+15 -15
View File
@@ -10,11 +10,11 @@
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1757683818, "lastModified": 1758711588,
"narHash": "sha256-q7q0pWT+wu5AUU1Qlbwq8Mqb+AzHKhaMCVUq/HNZfo8=", "narHash": "sha256-0nZlCCDC5PfndsQJXXtcyrtrfW49I3KadGMDlutzaGU=",
"owner": "zhaofengli", "owner": "zhaofengli",
"repo": "attic", "repo": "attic",
"rev": "7c5d79ad62cda340cb8c80c99b921b7b7ffacf69", "rev": "12cbeca141f46e1ade76728bce8adc447f2166c6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -99,11 +99,11 @@
}, },
"crane_2": { "crane_2": {
"locked": { "locked": {
"lastModified": 1757183466, "lastModified": 1759893430,
"narHash": "sha256-kTdCCMuRE+/HNHES5JYsbRHmgtr+l9mOtf5dpcMppVc=", "narHash": "sha256-yAy4otLYm9iZ+NtQwTMEbqHwswSFUbhn7x826RR6djw=",
"owner": "ipetkov", "owner": "ipetkov",
"repo": "crane", "repo": "crane",
"rev": "d599ae4847e7f87603e7082d73ca673aa93c916d", "rev": "1979a2524cb8c801520bd94c38bb3d5692419d93",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -152,11 +152,11 @@
"rust-analyzer-src": "rust-analyzer-src" "rust-analyzer-src": "rust-analyzer-src"
}, },
"locked": { "locked": {
"lastModified": 1758004879, "lastModified": 1760337631,
"narHash": "sha256-kV7tQzcNbmo58wg2uE2MQ/etaTx+PxBMHeNrLP8vOgk=", "narHash": "sha256-3nvEN2lEpWtM1x7nfuiwpYHLNDgEUiWeBbyvy4vtVw8=",
"owner": "nix-community", "owner": "nix-community",
"repo": "fenix", "repo": "fenix",
"rev": "07e5ce53dd020e6b337fdddc934561bee0698fa2", "rev": "fee7cf67cbd80a74460563388ac358b394014238",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -455,11 +455,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1758029226, "lastModified": 1760256791,
"narHash": "sha256-TjqVmbpoCqWywY9xIZLTf6ANFvDCXdctCjoYuYPYdMI=", "narHash": "sha256-uTpzDHRASEDeFUuToWSQ46Re8beXyG9dx4W36FQa0/c=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "08b8f92ac6354983f5382124fef6006cade4a1c1", "rev": "832e3b6db48508ae436c2c7bfc0cf914eac6938e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -484,11 +484,11 @@
"rust-analyzer-src": { "rust-analyzer-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1757362324, "lastModified": 1760260966,
"narHash": "sha256-/PAhxheUq4WBrW5i/JHzcCqK5fGWwLKdH6/Lu1tyS18=", "narHash": "sha256-pOVvZz/aa+laeaUKyE6PtBevdo4rywMwjhWdSZE/O1c=",
"owner": "rust-lang", "owner": "rust-lang",
"repo": "rust-analyzer", "repo": "rust-analyzer",
"rev": "9edc9cbe5d8e832b5864e09854fa94861697d2fd", "rev": "c5181dbbe33af6f21b9d83e02fdb6fda298a3b65",
"type": "github" "type": "github"
}, },
"original": { "original": {
+3 -3
View File
@@ -65,10 +65,10 @@
domain = "forgejo.ellis.link"; domain = "forgejo.ellis.link";
owner = "continuwuation"; owner = "continuwuation";
repo = "rocksdb"; repo = "rocksdb";
rev = "10.4.fb"; rev = "10.5.fb";
sha256 = "sha256-/Hvy1yTH/0D5aa7bc+/uqFugCQq4InTdwlRw88vA5IY="; sha256 = "sha256-X4ApGLkHF9ceBtBg77dimEpu720I79ffLoyPa8JMHaU=";
}; };
version = "v10.4.fb"; version = "v10.5.fb";
cmakeFlags = cmakeFlags =
pkgs.lib.subtractLists [ pkgs.lib.subtractLists [
# No real reason to have snappy or zlib, no one uses this # No real reason to have snappy or zlib, no one uses this
+20 -4
View File
@@ -1,12 +1,28 @@
# Continuwuity for Debian # Continuwuity for Debian
This document provides information about downloading and deploying the Debian package. You can also use this guide for other `apt`-based distributions such as Ubuntu. This document provides information about downloading and deploying the Debian package. You can also use this guide for other deb-based distributions such as Ubuntu.
### Installation ### Installation
See the [generic deployment guide](../deploying/generic.md) for additional information about using the Debian package. To add the Continuwuation apt repository:
```bash
# Replace with `"dev"` for bleeding-edge builds at your own risk
export COMPONENT="stable"
# Import the Continuwuation signing key
sudo curl https://forgejo.ellis.link/api/packages/continuwuation/debian/repository.key -o /etc/apt/keyrings/forgejo-continuwuation.asc
# Add a new apt source list pointing to the repository
echo "deb [signed-by=/etc/apt/keyrings/forgejo-continuwuation.asc] https://forgejo.ellis.link/api/packages/continuwuation/debian $(lsb_release -sc) $COMPONENT" | sudo tee /etc/apt/sources.list.d/continuwuation.list
# Update remote package lists
sudo apt update
```
No `apt` repository is currently available. This feature is in development. To install continuwuity:
```bash
sudo apt install continuwuity
```
The `continuwuity` package conflicts with the old `conduwuit` package and will remove it automatically when installed.
See the [generic deployment guide](../deploying/generic.md) for additional information about using the Debian package.
### Configuration ### Configuration
@@ -16,7 +32,7 @@ You can customize additional settings by uncommenting and modifying the configur
### Running ### Running
The package uses the [`conduwuit.service`](../configuration/examples.md#example-systemd-unit-file) systemd unit file to start and stop Continuwuity. The binary installs at `/usr/sbin/conduwuit`. The package uses the [`conduwuit.service`](../configuration/examples.md#example-systemd-unit-file) systemd unit file to start and stop Continuwuity. The binary installs at `/usr/bin/conduwuit`.
By default, this package assumes that Continuwuity runs behind a reverse proxy. The default configuration options apply (listening on `localhost` and TCP port `6167`). Matrix federation requires a valid domain name and TLS. To federate properly, you must set up TLS certificates and certificate renewal. By default, this package assumes that Continuwuity runs behind a reverse proxy. The default configuration options apply (listening on `localhost` and TCP port `6167`). Matrix federation requires a valid domain name and TLS. To federate properly, you must set up TLS certificates and certificate renewal.
+1 -2
View File
@@ -1,6 +1,5 @@
# This should be run using rpkg-util: https://docs.pagure.org/rpkg-util # This should be run using rpkg: https://docs.pagure.org/rpkg
# it requires Internet access and is not suitable for Fedora main repos # it requires Internet access and is not suitable for Fedora main repos
# TODO: rpkg-util is no longer maintained, find a replacement
Name: continuwuity Name: continuwuity
Version: {{{ git_repo_version }}} Version: {{{ git_repo_version }}}
+3 -7
View File
@@ -64,12 +64,8 @@
"matchDatasources": ["docker"], "matchDatasources": ["docker"],
"matchPackageNames": ["ghcr.io/renovatebot/renovate"], "matchPackageNames": ["ghcr.io/renovatebot/renovate"],
"automerge": true, "automerge": true,
"automergeStrategy": "fast-forward" "automergeStrategy": "fast-forward",
}, "extends": ["schedule:earlyMondays"]
{
"description": "Group lockfile updates into a single PR",
"matchUpdateTypes": ["lockFileMaintenance"],
"groupName": "lockfile-maintenance"
} }
], ],
"customManagers": [ "customManagers": [
@@ -81,7 +77,7 @@
"/(^|/|\\.)([Dd]ocker|[Cc]ontainer)file$/" "/(^|/|\\.)([Dd]ocker|[Cc]ontainer)file$/"
], ],
"matchStrings": [ "matchStrings": [
"# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?(?: registryUrl=(?<registryUrl>[^\\s]+?))?\\s+(?:ENV|ARG)\\s+[A-Za-z0-9_]+?_VERSION[ =][\"']?(?<currentValue>.+?)[\"']?\\s" "# renovate: datasource=(?<datasource>[a-zA-Z0-9-._]+?) depName=(?<depName>[^\\s]+?)(?: (lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?(?: registryUrl=(?<registryUrl>[^\\s]+?))?\\s+(?:ENV\\s+|ARG\\s+)?[A-Za-z0-9_]+?_VERSION[ =][\"']?(?<currentValue>.+?)[\"']?\\s+(?:(?:ENV\\s+|ARG\\s+)?[A-Za-z0-9_]+?_CHECKSUM[ =][\"']?(?<currentDigest>.+?)[\"']?\\s)?"
] ]
} }
] ]
+6 -2
View File
@@ -64,10 +64,14 @@ pub(crate) async fn create_content_route(
media_id: &utils::random_string(MXC_LENGTH), media_id: &utils::random_string(MXC_LENGTH),
}; };
services if let Err(e) = services
.media .media
.create(mxc, Some(user), Some(&content_disposition), content_type, &body.file) .create(mxc, Some(user), Some(&content_disposition), content_type, &body.file)
.await?; .await
{
err!("Failed to save uploaded media: {e}");
return Err!(Request(Unknown("Failed to save uploaded media")));
}
let blurhash = body.generate_blurhash.then(|| { let blurhash = body.generate_blurhash.then(|| {
services services
+114 -38
View File
@@ -2,7 +2,7 @@ use std::cmp::max;
use axum::extract::State; use axum::extract::State;
use conduwuit::{ use conduwuit::{
Err, Error, Event, Result, debug, err, info, Err, Error, Event, Result, RoomVersion, debug, err, info,
matrix::{StateKey, pdu::PduBuilder}, matrix::{StateKey, pdu::PduBuilder},
}; };
use futures::{FutureExt, StreamExt}; use futures::{FutureExt, StreamExt};
@@ -68,37 +68,77 @@ pub(crate) async fn upgrade_room_route(
return Err!(Request(UserSuspended("You cannot perform this action while suspended."))); return Err!(Request(UserSuspended("You cannot perform this action while suspended.")));
} }
// First, check if the user has permission to upgrade the room (send tombstone
// event)
let old_room_state_lock = services.rooms.state.mutex.lock(&body.room_id).await;
// Check tombstone permission by attempting to create (but not send) the event
// Note that this does internally call the policy server with a fake room ID,
// which may not be good?
let tombstone_test_result = services
.rooms
.timeline
.create_hash_and_sign_event(
PduBuilder::state(StateKey::new(), &RoomTombstoneEventContent {
body: "This room has been replaced".to_owned(),
replacement_room: RoomId::new(services.globals.server_name()),
}),
sender_user,
Some(&body.room_id),
&old_room_state_lock,
)
.await;
if let Err(_e) = tombstone_test_result {
return Err!(Request(Forbidden("User does not have permission to upgrade this room.")));
}
drop(old_room_state_lock);
// Create a replacement room // Create a replacement room
let replacement_room = RoomId::new(services.globals.server_name()); let room_features = RoomVersion::new(&body.new_version)?;
let replacement_room_owned = if !room_features.room_ids_as_hashes {
Some(RoomId::new(services.globals.server_name()))
} else {
None
};
let replacement_room: Option<&RoomId> = replacement_room_owned.as_ref().map(AsRef::as_ref);
let replacement_room_tmp = match replacement_room {
| Some(v) => v,
| None => &RoomId::new(services.globals.server_name()),
};
let _short_id = services let _short_id = services
.rooms .rooms
.short .short
.get_or_create_shortroomid(&replacement_room) .get_or_create_shortroomid(replacement_room_tmp)
.await; .await;
let state_lock = services.rooms.state.mutex.lock(&body.room_id).await; // For pre-v12 rooms, send tombstone before creating replacement room
let tombstone_event_id = if !room_features.room_ids_as_hashes {
// Send a m.room.tombstone event to the old room to indicate that it is not let state_lock = services.rooms.state.mutex.lock(&body.room_id).await;
// intended to be used any further Fail if the sender does not have the required // Send a m.room.tombstone event to the old room to indicate that it is not
// permissions // intended to be used any further
let tombstone_event_id = services let tombstone_event_id = services
.rooms .rooms
.timeline .timeline
.build_and_append_pdu( .build_and_append_pdu(
PduBuilder::state(StateKey::new(), &RoomTombstoneEventContent { PduBuilder::state(StateKey::new(), &RoomTombstoneEventContent {
body: "This room has been replaced".to_owned(), body: "This room has been replaced".to_owned(),
replacement_room: replacement_room.clone(), replacement_room: replacement_room.unwrap().to_owned(),
}), }),
sender_user, sender_user,
Some(&body.room_id), Some(&body.room_id),
&state_lock, &state_lock,
) )
.await?; .await?;
// Change lock to replacement room
// Change lock to replacement room drop(state_lock);
drop(state_lock); Some(tombstone_event_id)
let state_lock = services.rooms.state.mutex.lock(&replacement_room).await; } else {
None
};
let state_lock = services.rooms.state.mutex.lock(replacement_room_tmp).await;
// Get the old room creation event // Get the old room creation event
let mut create_event_content: CanonicalJsonObject = services let mut create_event_content: CanonicalJsonObject = services
@@ -111,7 +151,7 @@ pub(crate) async fn upgrade_room_route(
// Use the m.room.tombstone event as the predecessor // Use the m.room.tombstone event as the predecessor
let predecessor = Some(ruma::events::room::create::PreviousRoom::new( let predecessor = Some(ruma::events::room::create::PreviousRoom::new(
body.room_id.clone(), body.room_id.clone(),
Some(tombstone_event_id), tombstone_event_id,
)); ));
// Send a m.room.create event containing a predecessor field and the applicable // Send a m.room.create event containing a predecessor field and the applicable
@@ -132,6 +172,7 @@ pub(crate) async fn upgrade_room_route(
// "creator" key no longer exists in V11 rooms // "creator" key no longer exists in V11 rooms
create_event_content.remove("creator"); create_event_content.remove("creator");
}, },
// TODO(hydra): additional_creators
} }
} }
@@ -159,7 +200,7 @@ pub(crate) async fn upgrade_room_route(
return Err(Error::BadRequest(ErrorKind::BadJson, "Error forming creation event")); return Err(Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"));
} }
services let create_event_id = services
.rooms .rooms
.timeline .timeline
.build_and_append_pdu( .build_and_append_pdu(
@@ -173,11 +214,18 @@ pub(crate) async fn upgrade_room_route(
timestamp: None, timestamp: None,
}, },
sender_user, sender_user,
Some(&replacement_room), replacement_room,
&state_lock, &state_lock,
) )
.boxed() .boxed()
.await?; .await?;
let create_id = create_event_id.as_str().replace('$', "!");
let (replacement_room, state_lock) = if room_features.room_ids_as_hashes {
let parsed_room_id = RoomId::parse(&create_id)?;
(Some(parsed_room_id), services.rooms.state.mutex.lock(parsed_room_id).await)
} else {
(replacement_room, state_lock)
};
// Join the new room // Join the new room
services services
@@ -204,7 +252,7 @@ pub(crate) async fn upgrade_room_route(
timestamp: None, timestamp: None,
}, },
sender_user, sender_user,
Some(&replacement_room), replacement_room,
&state_lock, &state_lock,
) )
.boxed() .boxed()
@@ -243,7 +291,7 @@ pub(crate) async fn upgrade_room_route(
..Default::default() ..Default::default()
}, },
sender_user, sender_user,
Some(&replacement_room), replacement_room,
&state_lock, &state_lock,
) )
.boxed() .boxed()
@@ -268,7 +316,7 @@ pub(crate) async fn upgrade_room_route(
services services
.rooms .rooms
.alias .alias
.set_alias(alias, &replacement_room, sender_user)?; .set_alias(alias, replacement_room.unwrap(), sender_user)?;
} }
// Get the old room power levels // Get the old room power levels
@@ -310,6 +358,27 @@ pub(crate) async fn upgrade_room_route(
drop(state_lock); drop(state_lock);
// For v12 rooms, send tombstone AFTER creating replacement room
if room_features.room_ids_as_hashes {
let old_room_state_lock = services.rooms.state.mutex.lock(&body.room_id).await;
// For v12 rooms, no event reference in predecessor due to cyclic dependency -
// could best effort one maybe?
services
.rooms
.timeline
.build_and_append_pdu(
PduBuilder::state(StateKey::new(), &RoomTombstoneEventContent {
body: "This room has been replaced".to_owned(),
replacement_room: replacement_room.unwrap().to_owned(),
}),
sender_user,
Some(&body.room_id),
&old_room_state_lock,
)
.await?;
drop(old_room_state_lock);
}
// Check if the old room has a space parent, and if so, whether we should update // Check if the old room has a space parent, and if so, whether we should update
// it (m.space.parent, room_id) // it (m.space.parent, room_id)
let parents = services let parents = services
@@ -334,8 +403,9 @@ pub(crate) async fn upgrade_room_route(
continue; continue;
}; };
debug!( debug!(
"Updating space {space_id} child event for room {} to {replacement_room}", "Updating space {space_id} child event for room {} to {}",
&body.room_id &body.room_id,
replacement_room.unwrap()
); );
// First, drop the space's child event // First, drop the space's child event
let state_lock = services.rooms.state.mutex.lock(space_id).await; let state_lock = services.rooms.state.mutex.lock(space_id).await;
@@ -359,7 +429,10 @@ pub(crate) async fn upgrade_room_route(
.await .await
.ok(); .ok();
// Now, add a new child event for the replacement room // Now, add a new child event for the replacement room
debug!("Adding space child event for room {replacement_room} in space {space_id}"); debug!(
"Adding space child event for room {} in space {space_id}",
replacement_room.unwrap()
);
services services
.rooms .rooms
.timeline .timeline
@@ -372,7 +445,7 @@ pub(crate) async fn upgrade_room_route(
suggested: child.suggested, suggested: child.suggested,
}) })
.expect("event is valid, we just created it"), .expect("event is valid, we just created it"),
state_key: Some(replacement_room.as_str().into()), state_key: Some(replacement_room.unwrap().as_str().into()),
..Default::default() ..Default::default()
}, },
sender_user, sender_user,
@@ -383,12 +456,15 @@ pub(crate) async fn upgrade_room_route(
.await .await
.ok(); .ok();
debug!( debug!(
"Finished updating space {space_id} child event for room {} to {replacement_room}", "Finished updating space {space_id} child event for room {} to {}",
&body.room_id &body.room_id,
replacement_room.unwrap()
); );
drop(state_lock); drop(state_lock);
} }
// Return the replacement room id // Return the replacement room id
Ok(upgrade_room::v3::Response { replacement_room }) Ok(upgrade_room::v3::Response {
replacement_room: replacement_room.unwrap().to_owned(),
})
} }
+1
View File
@@ -320,6 +320,7 @@ where
for mut range in ranges { for mut range in ranges {
range.0 = uint!(0); range.0 = uint!(0);
range.1 = range.1.checked_add(uint!(1)).unwrap_or(range.1);
range.1 = range range.1 = range
.1 .1
.clamp(range.0, UInt::try_from(active_rooms.len()).unwrap_or(UInt::MAX)); .clamp(range.0, UInt::try_from(active_rooms.len()).unwrap_or(UInt::MAX));
+13
View File
@@ -34,6 +34,19 @@ pub(super) async fn from(
let max_body_size = services.server.config.max_request_size; let max_body_size = services.server.config.max_request_size;
// Check if the Content-Length header is present and valid, saves us streaming
// the response into memory
if let Some(content_length) = parts.headers.get(http::header::CONTENT_LENGTH) {
if let Ok(content_length) = content_length
.to_str()
.map(|s| s.parse::<usize>().unwrap_or_default())
{
if content_length > max_body_size {
return Err(err!(Request(TooLarge("Request body too large"))));
}
}
}
let body = axum::body::to_bytes(body, max_body_size) let body = axum::body::to_bytes(body, max_body_size)
.await .await
.map_err(|e| err!(Request(TooLarge("Request body too large: {e}"))))?; .map_err(|e| err!(Request(TooLarge("Request body too large: {e}"))))?;
+284 -87
View File
@@ -200,11 +200,15 @@ where
if incoming_event.room_id().is_some() { if incoming_event.room_id().is_some() {
let Some(room_id_server_name) = incoming_event.room_id().unwrap().server_name() let Some(room_id_server_name) = incoming_event.room_id().unwrap().server_name()
else { else {
warn!("room ID has no servername"); warn!("legacy room ID has no server name");
return Ok(false); return Ok(false);
}; };
if room_id_server_name != sender.server_name() { if room_id_server_name != sender.server_name() {
warn!("servername of room ID does not match servername of sender"); warn!(
expected = %sender.server_name(),
received = %room_id_server_name,
"server name of legacy room ID does not match server name of sender"
);
return Ok(false); return Ok(false);
} }
} }
@@ -215,12 +219,12 @@ where
.room_version .room_version
.is_some_and(|v| v.deserialize().is_err()) .is_some_and(|v| v.deserialize().is_err())
{ {
warn!("invalid room version found in m.room.create event"); warn!("unsupported room version found in m.room.create event");
return Ok(false); return Ok(false);
} }
if room_version.room_ids_as_hashes && incoming_event.room_id().is_some() { if room_version.room_ids_as_hashes && incoming_event.room_id().is_some() {
warn!("room create event incorrectly claims a room ID"); warn!("room create event incorrectly claims to have a room ID when it should not");
return Ok(false); return Ok(false);
} }
@@ -229,7 +233,7 @@ where
{ {
// If content has no creator field, reject // If content has no creator field, reject
if content.creator.is_none() { if content.creator.is_none() {
warn!("no creator field found in m.room.create content"); warn!("m.room.create event incorrectly omits 'creator' field");
return Ok(false); return Ok(false);
} }
} }
@@ -282,16 +286,19 @@ where
.room_version .room_version
.is_some_and(|v| v.deserialize().is_err()) .is_some_and(|v| v.deserialize().is_err())
{ {
warn!("invalid room version found in m.room.create event"); warn!(
create_event_id = %room_create_event.event_id(),
"unsupported room version found in m.room.create event"
);
return Ok(false); return Ok(false);
} }
let expected_room_id = room_create_event.room_id_or_hash(); let expected_room_id = room_create_event.room_id_or_hash();
if incoming_event.room_id().unwrap() != expected_room_id { if incoming_event.room_id().expect("event must have a room ID") != expected_room_id {
warn!( warn!(
expected = %expected_room_id, expected = %expected_room_id,
received = %incoming_event.room_id().unwrap(), received = %incoming_event.room_id().unwrap(),
"room_id of incoming event ({}) does not match room_id of m.room.create event ({})", "room_id of incoming event ({}) does not match that of the m.room.create event ({})",
incoming_event.room_id().unwrap(), incoming_event.room_id().unwrap(),
expected_room_id, expected_room_id,
); );
@@ -304,12 +311,15 @@ where
.auth_events() .auth_events()
.any(|id| id == room_create_event.event_id()); .any(|id| id == room_create_event.event_id());
if room_version.room_ids_as_hashes && claims_create_event { if room_version.room_ids_as_hashes && claims_create_event {
warn!("m.room.create event incorrectly found in auth events"); warn!("event incorrectly references m.room.create event in auth events");
return Ok(false); return Ok(false);
} else if !room_version.room_ids_as_hashes && !claims_create_event { } else if !room_version.room_ids_as_hashes && !claims_create_event {
// If the create event is not referenced in the event's auth events, and this is // If the create event is not referenced in the event's auth events, and this is
// a v11 room, reject // a v11 room, reject
warn!("no m.room.create event found in auth events"); warn!(
missing = %room_create_event.event_id(),
"event incorrectly did not reference an m.room.create in its auth events"
);
return Ok(false); return Ok(false);
} }
@@ -318,7 +328,7 @@ where
warn!( warn!(
expected = %expected_room_id, expected = %expected_room_id,
received = %pe.room_id().unwrap(), received = %pe.room_id().unwrap(),
"room_id of power levels event does not match room_id of m.room.create event" "room_id of referenced power levels event does not match that of the m.room.create event"
); );
return Ok(false); return Ok(false);
} }
@@ -332,8 +342,9 @@ where
&& room_create_event.sender().server_name() != incoming_event.sender().server_name() && room_create_event.sender().server_name() != incoming_event.sender().server_name()
{ {
warn!( warn!(
"room is not federated and event's sender domain does not match create event's \ sender = %incoming_event.sender(),
sender domain" create_sender = %room_create_event.sender(),
"room is not federated and event's sender domain does not match create event's sender domain"
); );
return Ok(false); return Ok(false);
} }
@@ -416,7 +427,6 @@ where
&user_for_join_auth_membership, &user_for_join_auth_membership,
&room_create_event, &room_create_event,
)? { )? {
warn!("membership change not valid for some reason");
return Ok(false); return Ok(false);
} }
@@ -429,7 +439,7 @@ where
let sender_member_event = match sender_member_event { let sender_member_event = match sender_member_event {
| Some(mem) => mem, | Some(mem) => mem,
| None => { | None => {
warn!("sender not found in room"); warn!("sender has no membership event");
return Ok(false); return Ok(false);
}, },
}; };
@@ -440,7 +450,7 @@ where
!= expected_room_id != expected_room_id
{ {
warn!( warn!(
"room_id of incoming event ({}) does not match room_id of m.room.create event ({})", "room_id of incoming event ({}) does not match that of the m.room.create event ({})",
sender_member_event sender_member_event
.room_id() .room_id()
.expect("event must have a room ID"), .expect("event must have a room ID"),
@@ -453,8 +463,7 @@ where
from_json_str(sender_member_event.content().get())?; from_json_str(sender_member_event.content().get())?;
let Some(membership_state) = sender_membership_event_content.membership else { let Some(membership_state) = sender_membership_event_content.membership else {
warn!( warn!(
sender_membership_event_content = format!("{sender_membership_event_content:?}"), ?sender_membership_event_content,
event_id = format!("{}", incoming_event.event_id()),
"Sender membership event content missing membership field" "Sender membership event content missing membership field"
); );
return Err(Error::InvalidPdu("Missing membership field".to_owned())); return Err(Error::InvalidPdu("Missing membership field".to_owned()));
@@ -462,7 +471,11 @@ where
let membership_state = membership_state.deserialize()?; let membership_state = membership_state.deserialize()?;
if !matches!(membership_state, MembershipState::Join) { if !matches!(membership_state, MembershipState::Join) {
warn!("sender's membership is not join"); warn!(
%sender,
?membership_state,
"sender cannot send events without being joined to the room"
);
return Ok(false); return Ok(false);
} }
@@ -522,7 +535,12 @@ where
}; };
if sender_power_level < invite_level { if sender_power_level < invite_level {
warn!("sender's cannot send invites in this room"); warn!(
%sender,
has=?sender_power_level,
required=?invite_level,
"sender cannot send invites in this room"
);
return Ok(false); return Ok(false);
} }
@@ -534,7 +552,11 @@ where
// level, reject If the event has a state_key that starts with an @ and does // level, reject If the event has a state_key that starts with an @ and does
// not match the sender, reject. // not match the sender, reject.
if !can_send_event(incoming_event, power_levels_event.as_ref(), sender_power_level) { if !can_send_event(incoming_event, power_levels_event.as_ref(), sender_power_level) {
warn!("user cannot send event"); warn!(
%sender,
event_type=?incoming_event.kind(),
"sender cannot send event"
);
return Ok(false); return Ok(false);
} }
@@ -579,6 +601,12 @@ where
}; };
if !check_redaction(room_version, incoming_event, sender_power_level, redact_level)? { if !check_redaction(room_version, incoming_event, sender_power_level, redact_level)? {
warn!(
%sender,
?sender_power_level,
?redact_level,
"redaction event was not allowed"
);
return Ok(false); return Ok(false);
} }
} }
@@ -759,7 +787,7 @@ where
if prev_event_is_create_event && no_more_prev_events { if prev_event_is_create_event && no_more_prev_events {
trace!( trace!(
sender = %sender, %sender,
target_user = %target_user, target_user = %target_user,
?sender_creator, ?sender_creator,
?target_creator, ?target_creator,
@@ -779,22 +807,33 @@ where
); );
if sender != target_user { if sender != target_user {
// If the sender does not match state_key, reject. // If the sender does not match state_key, reject.
warn!("Can't make other user join"); warn!(
%sender,
target_user = %target_user,
"sender cannot join on behalf of another user"
);
false false
} else if target_user_current_membership == MembershipState::Ban { } else if target_user_current_membership == MembershipState::Ban {
// If the sender is banned, reject. // If the sender is banned, reject.
warn!(?target_user_membership_event_id, "Banned user can't join"); warn!(
%sender,
membership_event_id = ?target_user_membership_event_id,
"sender cannot join as they are banned from the room"
);
false false
} else { } else {
match join_rules { match join_rules {
| JoinRule::Invite => | JoinRule::Invite =>
if !membership_allows_join { if !membership_allows_join {
warn!( warn!(
membership=?target_user_current_membership, %sender,
"Join rule is invite but membership does not allow join" membership_event_id = ?target_user_membership_event_id,
membership = ?target_user_current_membership,
"sender cannot join as they are not invited to the invite-only room"
); );
false false
} else { } else {
trace!(sender=%sender, "sender is invited to room, allowing join");
true true
}, },
| JoinRule::Knock if !room_version.allow_knocking => { | JoinRule::Knock if !room_version.allow_knocking => {
@@ -804,11 +843,14 @@ where
| JoinRule::Knock => | JoinRule::Knock =>
if !membership_allows_join { if !membership_allows_join {
warn!( warn!(
%sender,
membership_event_id = ?target_user_membership_event_id,
membership=?target_user_current_membership, membership=?target_user_current_membership,
"Join rule is knock but membership does not allow join" "sender cannot join a knock room without being invited or already joined"
); );
false false
} else { } else {
trace!(sender=%sender, "sender is invited or already joined to room, allowing join");
true true
}, },
| JoinRule::KnockRestricted(_) if !room_version.knock_restricted_join_rule => | JoinRule::KnockRestricted(_) if !room_version.knock_restricted_join_rule =>
@@ -820,33 +862,55 @@ where
}, },
| JoinRule::KnockRestricted(_) => { | JoinRule::KnockRestricted(_) => {
if membership_allows_join || user_for_join_auth_is_valid { if membership_allows_join || user_for_join_auth_is_valid {
trace!(
%sender,
%membership_allows_join,
%user_for_join_auth_is_valid,
"sender is invited, already joined to, or authorised to join the room, allowing join"
);
true true
} else { } else {
warn!( warn!(
%sender,
membership_event_id = ?target_user_membership_event_id,
membership=?target_user_current_membership, membership=?target_user_current_membership,
"Join rule is a restricted one, but no valid authorising user \ %user_for_join_auth_is_valid,
was given and the sender's current membership does not permit \ ?user_for_join_auth,
a join transition" "sender cannot join as they are not invited nor already joined to the room, nor was a \
valid authorising user given to permit the join"
); );
false false
} }
}, },
| JoinRule::Restricted(_) => | JoinRule::Restricted(_) =>
if membership_allows_join || user_for_join_auth_is_valid { if membership_allows_join || user_for_join_auth_is_valid {
trace!(
%sender,
%membership_allows_join,
%user_for_join_auth_is_valid,
"sender is invited, already joined to, or authorised to join the room, allowing join"
);
true true
} else { } else {
warn!( warn!(
"Join rule is a restricted one but no valid authorising user \ %sender,
was given" membership_event_id = ?target_user_membership_event_id,
membership=?target_user_current_membership,
%user_for_join_auth_is_valid,
?user_for_join_auth,
"sender cannot join as they are not invited nor already joined to the room, nor was a \
valid authorising user given to permit the join"
); );
false false
}, },
| JoinRule::Public => true, | JoinRule::Public => {
trace!(%sender, "join rule is public, allowing join");
true
},
| _ => { | _ => {
warn!( warn!(
join_rule=?join_rules, join_rule=?join_rules,
membership=?target_user_current_membership, "Join rule is unknown, or the rule's conditions were not met"
"Unknown join rule doesn't allow joining, or the rule's conditions were not met"
); );
false false
}, },
@@ -873,16 +937,23 @@ where
} }
allow allow
}, },
| _ => { | _ =>
if !sender_is_joined if !sender_is_joined {
|| target_user_current_membership == MembershipState::Join warn!(
|| target_user_current_membership == MembershipState::Ban %sender,
{ ?sender_membership_event_id,
?sender_membership,
"sender cannot produce an invite without being joined to the room",
);
false
} else if matches!(
target_user_current_membership,
MembershipState::Join | MembershipState::Ban
) {
warn!( warn!(
?target_user_membership_event_id, ?target_user_membership_event_id,
?sender_membership_event_id, ?target_user_current_membership,
"Can't invite user if sender not joined or the user is currently \ "cannot invite a user who is banned or already joined",
joined or banned",
); );
false false
} else { } else {
@@ -892,56 +963,107 @@ where
.is_some(); .is_some();
if !allow { if !allow {
warn!( warn!(
?target_user_membership_event_id, %sender,
?power_levels_event_id, has=?sender_power,
"User does not have enough power to invite", required=?power_levels.invite,
"sender does not have enough power to produce invites",
); );
} }
trace!(
%sender,
?sender_membership_event_id,
?sender_membership,
?target_user_membership_event_id,
?target_user_current_membership,
sender_pl=?sender_power,
required_pl=?power_levels.invite,
"allowing invite"
);
allow allow
} },
},
} }
}, },
| MembershipState::Leave => | MembershipState::Leave => {
let can_unban = if target_user_current_membership == MembershipState::Ban {
sender_creator || sender_power.filter(|&p| p < &power_levels.ban).is_some()
} else {
true
};
let can_kick = if !matches!(
target_user_current_membership,
MembershipState::Ban | MembershipState::Leave
) {
sender_creator || sender_power.filter(|&p| p < &power_levels.kick).is_some()
} else {
true
};
if sender == target_user { if sender == target_user {
let allow = target_user_current_membership == MembershipState::Join // self-leave
|| target_user_current_membership == MembershipState::Invite // let allow = target_user_current_membership == MembershipState::Join
|| target_user_current_membership == MembershipState::Knock; // || target_user_current_membership == MembershipState::Invite
// || target_user_current_membership == MembershipState::Knock;
let allow = matches!(
target_user_current_membership,
MembershipState::Join | MembershipState::Invite | MembershipState::Knock
);
if !allow { if !allow {
warn!( warn!(
?target_user_membership_event_id, %sender,
?target_user_current_membership, current_membership_event_id=?target_user_membership_event_id,
"Can't leave if sender is not already invited, knocked, or joined" current_membership=?target_user_current_membership,
"sender cannot leave as they are not already knocking on, invited to, or joined to the room"
); );
} }
trace!(sender=%sender, "allowing leave");
allow allow
} else if !sender_is_joined } else if !sender_is_joined {
|| target_user_current_membership == MembershipState::Ban
&& (sender_creator
|| sender_power.filter(|&p| p < &power_levels.ban).is_some())
{
warn!( warn!(
?target_user_membership_event_id, %sender,
?sender_membership_event_id, ?sender_membership_event_id,
"Can't kick if sender not joined or user is already banned", "sender cannot kick another user as they are not joined to the room",
);
false
} else if !can_unban {
// If the target is banned, only a room creator or someone with ban power
// level can unban them
warn!(
%sender,
?target_user_membership_event_id,
?power_levels_event_id,
"sender lacks the power level required to unban users",
);
false
} else if !can_kick {
warn!(
%sender,
%target_user,
?target_user_membership_event_id,
?target_user_current_membership,
?power_levels_event_id,
"sender does not have enough power to kick the target",
); );
false false
} else { } else {
let allow = sender_creator trace!(
|| (sender_power.filter(|&p| p >= &power_levels.kick).is_some() %sender,
&& target_power < sender_power); %target_user,
if !allow { ?target_user_membership_event_id,
warn!( ?target_user_current_membership,
?target_user_membership_event_id, sender_pl=?sender_power,
?power_levels_event_id, target_pl=?target_power,
"User does not have enough power to kick", required_pl=?power_levels.kick,
); "allowing kick/unban",
} );
allow true
}, }
},
| MembershipState::Ban => | MembershipState::Ban =>
if !sender_is_joined { if !sender_is_joined {
warn!(?sender_membership_event_id, "Can't ban user if sender is not joined"); warn!(
%sender,
?sender_membership_event_id,
"sender cannot ban another user as they are not joined to the room",
);
false false
} else { } else {
let allow = sender_creator let allow = sender_creator
@@ -949,9 +1071,11 @@ where
&& target_power < sender_power); && target_power < sender_power);
if !allow { if !allow {
warn!( warn!(
%sender,
%target_user,
?target_user_membership_event_id, ?target_user_membership_event_id,
?power_levels_event_id, ?power_levels_event_id,
"User does not have enough power to ban", "sender does not have enough power to ban the target",
); );
} }
allow allow
@@ -977,9 +1101,9 @@ where
} else if sender != target_user { } else if sender != target_user {
// 3. If `sender` does not match `state_key`, reject. // 3. If `sender` does not match `state_key`, reject.
warn!( warn!(
?sender, %sender,
?target_user, %target_user,
"Can't make another user knock, sender did not match target" "sender cannot knock on behalf of another user",
); );
false false
} else if matches!( } else if matches!(
@@ -991,15 +1115,25 @@ where
// 5. Otherwise, reject. // 5. Otherwise, reject.
warn!( warn!(
?target_user_membership_event_id, ?target_user_membership_event_id,
?sender_membership,
"Knocking with a membership state of ban, invite or join is invalid", "Knocking with a membership state of ban, invite or join is invalid",
); );
false false
} else { } else {
trace!(%sender, "allowing knock");
true true
} }
}, },
| _ => { | _ => {
warn!("Unknown membership transition"); warn!(
%sender,
?target_membership,
%target_user,
%target_user_current_membership,
"Unknown or invalid membership transition {} -> {}",
target_user_current_membership,
target_membership
);
false false
}, },
}) })
@@ -1029,6 +1163,13 @@ fn can_send_event(event: &impl Event, ple: Option<&impl Event>, user_level: Int)
if event.state_key().is_some_and(|k| k.starts_with('@')) if event.state_key().is_some_and(|k| k.starts_with('@'))
&& event.state_key() != Some(event.sender().as_str()) && event.state_key() != Some(event.sender().as_str())
{ {
warn!(
%user_level,
required=?event_type_power_level,
state_key=?event.state_key(),
sender=%event.sender(),
"state_key starts with @ but does not match sender",
);
return false; // permission required to post in this room return false; // permission required to post in this room
} }
@@ -1113,7 +1254,14 @@ fn check_power_levels(
// If the current value is equal to the sender's current power level, reject // If the current value is equal to the sender's current power level, reject
if user != power_event.sender() && old_level == Some(&user_level) { if user != power_event.sender() && old_level == Some(&user_level) {
warn!("m.room.power_level cannot remove ops == to own"); warn!(
?old_level,
?new_level,
?user,
%user_level,
sender=%power_event.sender(),
"cannot alter the power level of a user with the same power level as sender's own"
);
return Some(false); // cannot remove ops level == to own return Some(false); // cannot remove ops level == to own
} }
@@ -1121,8 +1269,26 @@ fn check_power_levels(
// If the new value is higher than the sender's current power level, reject // If the new value is higher than the sender's current power level, reject
let old_level_too_big = old_level > Some(&user_level); let old_level_too_big = old_level > Some(&user_level);
let new_level_too_big = new_level > Some(&user_level); let new_level_too_big = new_level > Some(&user_level);
if old_level_too_big || new_level_too_big { if old_level_too_big {
warn!("m.room.power_level failed to add ops > than own"); warn!(
?old_level,
?new_level,
?user,
%user_level,
sender=%power_event.sender(),
"cannot alter the power level of a user with a higher power level than sender's own"
);
return Some(false); // cannot add ops greater than own
}
if new_level_too_big {
warn!(
?old_level,
?new_level,
?user,
%user_level,
sender=%power_event.sender(),
"cannot set the power level of a user to a level higher than sender's own"
);
return Some(false); // cannot add ops greater than own return Some(false); // cannot add ops greater than own
} }
} }
@@ -1139,8 +1305,26 @@ fn check_power_levels(
// If the new value is higher than the sender's current power level, reject // If the new value is higher than the sender's current power level, reject
let old_level_too_big = old_level > Some(&user_level); let old_level_too_big = old_level > Some(&user_level);
let new_level_too_big = new_level > Some(&user_level); let new_level_too_big = new_level > Some(&user_level);
if old_level_too_big || new_level_too_big { if old_level_too_big {
warn!("m.room.power_level failed to add ops > than own"); warn!(
?old_level,
?new_level,
?ev_type,
%user_level,
sender=%power_event.sender(),
"cannot alter the power level of an event with a higher power level than sender's own"
);
return Some(false); // cannot add ops greater than own
}
if new_level_too_big {
warn!(
?old_level,
?new_level,
?ev_type,
%user_level,
sender=%power_event.sender(),
"cannot set the power level of an event to a level higher than sender's own"
);
return Some(false); // cannot add ops greater than own return Some(false); // cannot add ops greater than own
} }
} }
@@ -1155,7 +1339,13 @@ fn check_power_levels(
let old_level_too_big = old_level > user_level; let old_level_too_big = old_level > user_level;
let new_level_too_big = new_level > user_level; let new_level_too_big = new_level > user_level;
if old_level_too_big || new_level_too_big { if old_level_too_big || new_level_too_big {
warn!("m.room.power_level failed to add ops > than own"); warn!(
?old_level,
?new_level,
%user_level,
sender=%power_event.sender(),
"cannot alter the power level of notifications greater than sender's own"
);
return Some(false); // cannot add ops greater than own return Some(false); // cannot add ops greater than own
} }
} }
@@ -1179,7 +1369,14 @@ fn check_power_levels(
let new_level_too_big = new_lvl > user_level; let new_level_too_big = new_lvl > user_level;
if old_level_too_big || new_level_too_big { if old_level_too_big || new_level_too_big {
warn!("cannot add ops > than own"); warn!(
?old_lvl,
?new_lvl,
%user_level,
sender=%power_event.sender(),
action=%lvl_name,
"cannot alter the power level of action greater than sender's own",
);
return Some(false); return Some(false);
} }
} }
+14 -3
View File
@@ -36,7 +36,7 @@ pub use self::{
room_version::RoomVersion, room_version::RoomVersion,
}; };
use crate::{ use crate::{
debug, debug_error, debug, debug_error, err,
matrix::{Event, StateKey}, matrix::{Event, StateKey},
state_res::room_version::StateResolutionVersion, state_res::room_version::StateResolutionVersion,
trace, trace,
@@ -319,8 +319,19 @@ where
path.pop(); path.pop();
continue; continue;
} }
let evt = fetch_event(event_id.clone()).await?; trace!(event_id = event_id.as_str(), "fetching event for its auth events");
stack.push(evt.auth_events().map(ToOwned::to_owned).collect()); let evt = fetch_event(event_id.clone()).await;
if evt.is_none() {
err!("could not fetch event {} to calculate conflicted subgraph", event_id);
path.pop();
continue;
}
stack.push(
evt.expect("checked")
.auth_events()
.map(ToOwned::to_owned)
.collect(),
);
seen.insert(event_id); seen.insert(event_id);
} }
Some(subgraph) Some(subgraph)
+6 -3
View File
@@ -22,11 +22,13 @@ crate-type = [
] ]
[package.metadata.deb] [package.metadata.deb]
name = "conduwuit" name = "continuwuity"
maintainer = "strawberry <strawberry@puppygock.gay>" maintainer = "continuwuity developers <contact@continuwuity.org>"
copyright = "2024, strawberry <strawberry@puppygock.gay>" copyright = "2024, continuwuity developers"
license-file = ["../../LICENSE", "3"] license-file = ["../../LICENSE", "3"]
depends = "$auto, ca-certificates" depends = "$auto, ca-certificates"
breaks = ["conduwuit (<<0.5.0)"]
replaces = ["conduwuit (<<0.5.0)"]
extended-description = """\ extended-description = """\
a cool hard fork of Conduit, a Matrix homeserver written in Rust""" a cool hard fork of Conduit, a Matrix homeserver written in Rust"""
section = "net" section = "net"
@@ -154,6 +156,7 @@ sentry_telemetry = [
] ]
systemd = [ systemd = [
"conduwuit-router/systemd", "conduwuit-router/systemd",
"conduwuit-service/systemd"
] ]
journald = [ # This is a stub on non-unix platforms journald = [ # This is a stub on non-unix platforms
"dep:tracing-journald", "dep:tracing-journald",
-1
View File
@@ -40,7 +40,6 @@ io_uring = [
"conduwuit-admin/io_uring", "conduwuit-admin/io_uring",
"conduwuit-api/io_uring", "conduwuit-api/io_uring",
"conduwuit-service/io_uring", "conduwuit-service/io_uring",
"conduwuit-api/io_uring",
] ]
jemalloc = [ jemalloc = [
"conduwuit-admin/jemalloc", "conduwuit-admin/jemalloc",
+2 -2
View File
@@ -65,7 +65,7 @@ pub(crate) async fn start(server: Arc<Server>) -> Result<Arc<Services>> {
let services = Services::build(server).await?.start().await?; let services = Services::build(server).await?.start().await?;
#[cfg(all(feature = "systemd", target_os = "linux"))] #[cfg(all(feature = "systemd", target_os = "linux"))]
sd_notify::notify(true, &[sd_notify::NotifyState::Ready]) sd_notify::notify(false, &[sd_notify::NotifyState::Ready])
.expect("failed to notify systemd of ready state"); .expect("failed to notify systemd of ready state");
debug!("Started"); debug!("Started");
@@ -78,7 +78,7 @@ pub(crate) async fn stop(services: Arc<Services>) -> Result<()> {
debug!("Shutting down..."); debug!("Shutting down...");
#[cfg(all(feature = "systemd", target_os = "linux"))] #[cfg(all(feature = "systemd", target_os = "linux"))]
sd_notify::notify(true, &[sd_notify::NotifyState::Stopping]) sd_notify::notify(false, &[sd_notify::NotifyState::Stopping])
.expect("failed to notify systemd of stopping state"); .expect("failed to notify systemd of stopping state");
// Wait for all completions before dropping or we'll lose them to the module // Wait for all completions before dropping or we'll lose them to the module
+7
View File
@@ -67,6 +67,9 @@ release_max_log_level = [
"tracing/max_level_trace", "tracing/max_level_trace",
"tracing/release_max_level_info", "tracing/release_max_level_info",
] ]
systemd = [
"dep:sd-notify",
]
url_preview = [ url_preview = [
"dep:image", "dep:image",
"dep:webpage", "dep:webpage",
@@ -119,5 +122,9 @@ blurhash.optional = true
recaptcha-verify = { version = "0.1.5", default-features = false } recaptcha-verify = { version = "0.1.5", default-features = false }
ctor.workspace = true ctor.workspace = true
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
sd-notify.workspace = true
sd-notify.optional = true
[lints] [lints]
workspace = true workspace = true
+6 -3
View File
@@ -45,13 +45,16 @@ impl Deref for Service {
fn handle_reload(&self) -> Result { fn handle_reload(&self) -> Result {
if self.server.config.config_reload_signal { if self.server.config.config_reload_signal {
#[cfg(all(feature = "systemd", target_os = "linux"))] #[cfg(all(feature = "systemd", target_os = "linux"))]
sd_notify::notify(true, &[sd_notify::NotifyState::Reloading]) sd_notify::notify(false, &[
.expect("failed to notify systemd of reloading state"); sd_notify::NotifyState::Reloading,
sd_notify::NotifyState::monotonic_usec_now().expect("Failed to read monotonic time"),
])
.expect("failed to notify systemd of reloading state");
self.reload(iter::empty())?; self.reload(iter::empty())?;
#[cfg(all(feature = "systemd", target_os = "linux"))] #[cfg(all(feature = "systemd", target_os = "linux"))]
sd_notify::notify(true, &[sd_notify::NotifyState::Ready]) sd_notify::notify(false, &[sd_notify::NotifyState::Ready])
.expect("failed to notify systemd of ready state"); .expect("failed to notify systemd of ready state");
} }
+14 -9
View File
@@ -90,17 +90,22 @@ impl Service {
file: &[u8], file: &[u8],
) -> Result<()> { ) -> Result<()> {
// Width, Height = 0 if it's not a thumbnail // Width, Height = 0 if it's not a thumbnail
let key = self.db.create_file_metadata( let key = self
mxc, .db
user, .create_file_metadata(mxc, user, &Dim::default(), content_disposition, content_type)
&Dim::default(), .map_err(|e| {
content_disposition, err!(Database(error!("Failed to create media metadata for MXC {mxc}: {e}")))
content_type, })?;
)?;
//TODO: Dangling metadata in database if creation fails //TODO: Dangling metadata in database if creation fails
let mut f = self.create_media_file(&key).await?; let mut f = self.create_media_file(&key).await.map_err(|e| {
f.write_all(file).await?; err!(Database(error!(
"Failed to create media file for MXC {mxc} at key {key:?}: {e}"
)))
})?;
f.write_all(file).await.map_err(|e| {
err!(Database(error!("Failed to write media file for MXC {mxc} at key {key:?}: {e}")))
})?;
Ok(()) Ok(())
} }
+2 -1
View File
@@ -9,6 +9,7 @@ use conduwuit::{
}, },
warn, warn,
}; };
use database::Json;
use futures::{FutureExt, StreamExt, TryStreamExt}; use futures::{FutureExt, StreamExt, TryStreamExt};
use itertools::Itertools; use itertools::Itertools;
use ruma::{ use ruma::{
@@ -606,7 +607,7 @@ async fn fix_corrupt_msc4133_fields(services: &Services) -> Result {
); );
}; };
useridprofilekey_value.put((user, key), new_value); useridprofilekey_value.put((user, key), Json(new_value));
fixed = fixed.saturating_add(1); fixed = fixed.saturating_add(1);
} }
total = total.saturating_add(1); total = total.saturating_add(1);
@@ -4,9 +4,8 @@ use std::{
}; };
use conduwuit::{ use conduwuit::{
Event, PduEvent, debug, debug_error, debug_warn, implement, Event, PduEvent, debug, debug_warn, implement, matrix::event::gen_event_id_canonical_json,
matrix::event::gen_event_id_canonical_json, trace, utils::continue_exponential_backoff_secs, trace, utils::continue_exponential_backoff_secs, warn,
warn,
}; };
use ruma::{ use ruma::{
CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName, CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName,
@@ -52,12 +51,14 @@ where
}; };
let mut events_with_auth_events = Vec::with_capacity(events.clone().count()); let mut events_with_auth_events = Vec::with_capacity(events.clone().count());
trace!("Fetching {} outlier pdus", events.clone().count());
for id in events { for id in events {
// a. Look in the main timeline (pduid_pdu tree) // a. Look in the main timeline (pduid_pdu tree)
// b. Look at outlier pdu tree // b. Look at outlier pdu tree
// (get_pdu_json checks both) // (get_pdu_json checks both)
if let Ok(local_pdu) = self.services.timeline.get_pdu(id).await { if let Ok(local_pdu) = self.services.timeline.get_pdu(id).await {
trace!("Found {id} in main timeline or outlier tree");
events_with_auth_events.push((id.to_owned(), Some(local_pdu), vec![])); events_with_auth_events.push((id.to_owned(), Some(local_pdu), vec![]));
continue; continue;
} }
@@ -104,7 +105,7 @@ where
continue; continue;
} }
debug!("Fetching {next_id} over federation."); debug!("Fetching {next_id} over federation from {origin}.");
match self match self
.services .services
.sending .sending
@@ -115,7 +116,7 @@ where
.await .await
{ {
| Ok(res) => { | Ok(res) => {
debug!("Got {next_id} over federation"); debug!("Got {next_id} over federation from {origin}");
let Ok(room_version_id) = get_room_version_id(create_event) else { let Ok(room_version_id) = get_room_version_id(create_event) else {
back_off((*next_id).to_owned()); back_off((*next_id).to_owned());
continue; continue;
@@ -145,6 +146,9 @@ where
auth_event.clone().into(), auth_event.clone().into(),
) { ) {
| Ok(auth_event) => { | Ok(auth_event) => {
trace!(
"Found auth event id {auth_event} for event {next_id}"
);
todo_auth_events.push_back(auth_event); todo_auth_events.push_back(auth_event);
}, },
| _ => { | _ => {
@@ -160,7 +164,7 @@ where
events_all.insert(next_id); events_all.insert(next_id);
}, },
| Err(e) => { | Err(e) => {
debug_error!("Failed to fetch event {next_id}: {e}"); warn!("Failed to fetch auth event {next_id} from {origin}: {e}");
back_off((*next_id).to_owned()); back_off((*next_id).to_owned());
}, },
} }
@@ -175,7 +179,7 @@ where
// b. Look at outlier pdu tree // b. Look at outlier pdu tree
// (get_pdu_json checks both) // (get_pdu_json checks both)
if let Some(local_pdu) = local_pdu { if let Some(local_pdu) = local_pdu {
trace!("Found {id} in db"); trace!("Found {id} in main timeline or outlier tree");
pdus.push((local_pdu.clone(), None)); pdus.push((local_pdu.clone(), None));
} }
@@ -201,6 +205,7 @@ where
} }
} }
trace!("Handling outlier {next_id}");
match Box::pin(self.handle_outlier_pdu( match Box::pin(self.handle_outlier_pdu(
origin, origin,
create_event, create_event,
@@ -213,6 +218,7 @@ where
{ {
| Ok((pdu, json)) => | Ok((pdu, json)) =>
if next_id == *id { if next_id == *id {
trace!("Handled outlier {next_id} (original request)");
pdus.push((pdu, Some(json))); pdus.push((pdu, Some(json)));
}, },
| Err(e) => { | Err(e) => {
@@ -222,6 +228,6 @@ where
} }
} }
} }
trace!("Fetched and handled {} outlier pdus", pdus.len());
pdus pdus
} }
@@ -1,11 +1,12 @@
use std::collections::{BTreeMap, HashMap, hash_map}; use std::collections::{BTreeMap, HashMap, hash_map};
use conduwuit::{ use conduwuit::{
Err, Event, PduEvent, Result, debug, debug_info, err, implement, state_res, trace, warn, Err, Event, PduEvent, Result, debug, debug_info, debug_warn, err, implement, state_res, trace,
}; };
use futures::future::ready; use futures::future::ready;
use ruma::{ use ruma::{
CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, ServerName, events::StateEventType, CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName,
events::StateEventType,
}; };
use super::{check_room_id, get_room_version_id, to_room_version}; use super::{check_room_id, get_room_version_id, to_room_version};
@@ -74,36 +75,73 @@ where
check_room_id(room_id, &pdu_event)?; check_room_id(room_id, &pdu_event)?;
if !auth_events_known { // Fetch all auth events
// 4. fetch any missing auth events doing all checks listed here starting at 1. let mut auth_events: HashMap<OwnedEventId, PduEvent> = HashMap::new();
// These are not timeline events
// 5. Reject "due to auth events" if can't get all the auth events or some of for aid in pdu_event.auth_events() {
// the auth events are also rejected "due to auth events" if let Ok(auth_event) = self.services.timeline.get_pdu(aid).await {
// NOTE: Step 5 is not applied anymore because it failed too often check_room_id(room_id, &auth_event)?;
debug!("Fetching auth events"); trace!("Found auth event {aid} for outlier event {event_id} locally");
Box::pin(self.fetch_and_handle_outliers( auth_events.insert(aid.to_owned(), auth_event);
origin, } else {
pdu_event.auth_events(), debug_warn!("Could not find auth event {aid} for outlier event {event_id} locally");
create_event, }
room_id, }
))
.await; // Fetch any missing ones & reject invalid ones
let missing_auth_events = if auth_events_known {
pdu_event
.auth_events()
.filter(|id| !auth_events.contains_key(*id))
.collect::<Vec<_>>()
} else {
pdu_event.auth_events().collect::<Vec<_>>()
};
if !missing_auth_events.is_empty() || !auth_events_known {
debug_info!(
"Fetching {} missing auth events for outlier event {event_id}",
missing_auth_events.len()
);
for (pdu, _) in self
.fetch_and_handle_outliers(
origin,
missing_auth_events.iter().copied(),
create_event,
room_id,
)
.await
{
auth_events.insert(pdu.event_id().to_owned(), pdu);
}
} else {
debug!("No missing auth events for outlier event {event_id}");
}
// reject if we are still missing some
let still_missing = pdu_event
.auth_events()
.filter(|id| !auth_events.contains_key(*id))
.collect::<Vec<_>>();
if !still_missing.is_empty() {
return Err!(Request(InvalidParam(
"Could not fetch all auth events for outlier event {event_id}, still missing: \
{still_missing:?}"
)));
} }
// 6. Reject "due to auth events" if the event doesn't pass auth based on the // 6. Reject "due to auth events" if the event doesn't pass auth based on the
// auth events // auth events
debug!("Checking based on auth events"); debug!("Checking based on auth events");
let mut auth_events_by_key: HashMap<_, _> = HashMap::with_capacity(auth_events.len());
// Build map of auth events // Build map of auth events
let mut auth_events = HashMap::with_capacity(pdu_event.auth_events().count());
for id in pdu_event.auth_events() { for id in pdu_event.auth_events() {
let Ok(auth_event) = self.services.timeline.get_pdu(id).await else { let auth_event = auth_events
warn!("Could not find auth event {id}"); .get(id)
continue; .expect("we just checked that we have all auth events")
}; .to_owned();
check_room_id(room_id, &auth_event)?; check_room_id(room_id, &auth_event)?;
match auth_events.entry(( match auth_events_by_key.entry((
auth_event.kind.to_string().into(), auth_event.kind.to_string().into(),
auth_event auth_event
.state_key .state_key
@@ -123,7 +161,7 @@ where
// The original create event must be in the auth events // The original create event must be in the auth events
if !matches!( if !matches!(
auth_events.get(&(StateEventType::RoomCreate, String::new().into())), auth_events_by_key.get(&(StateEventType::RoomCreate, String::new().into())),
Some(_) | None Some(_) | None
) { ) {
return Err!(Request(InvalidParam("Incoming event refers to wrong create event."))); return Err!(Request(InvalidParam("Incoming event refers to wrong create event.")));
@@ -131,7 +169,7 @@ where
let state_fetch = |ty: &StateEventType, sk: &str| { let state_fetch = |ty: &StateEventType, sk: &str| {
let key = (ty.to_owned(), sk.into()); let key = (ty.to_owned(), sk.into());
ready(auth_events.get(&key).map(ToOwned::to_owned)) ready(auth_events_by_key.get(&key).map(ToOwned::to_owned))
}; };
let auth_check = state_res::event_auth::auth_check( let auth_check = state_res::event_auth::auth_check(
-2
View File
@@ -274,8 +274,6 @@ pub async fn create_hash_and_sign_event(
pdu_json.insert("event_id".into(), CanonicalJsonValue::String(pdu.event_id.clone().into())); pdu_json.insert("event_id".into(), CanonicalJsonValue::String(pdu.event_id.clone().into()));
// Check with the policy server // Check with the policy server
// TODO(hydra): Skip this check for create events (why didnt we do this
// already?)
if room_id.is_some() { if room_id.is_some() {
trace!( trace!(
"Checking event {} in room {} with policy server", "Checking event {} in room {} with policy server",