mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-30 04:17:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7345c241a9 |
No files matched your search
@@ -586,13 +586,10 @@
|
|||||||
#allow_unstable_room_versions = true
|
#allow_unstable_room_versions = true
|
||||||
|
|
||||||
# Default room version continuwuity will create rooms with.
|
# Default room version continuwuity will create rooms with.
|
||||||
# Note that this has to be a string since the room version is a string
|
|
||||||
# rather than an integer. Forgetting the quotes will make the server fail
|
|
||||||
# to start!
|
|
||||||
#
|
#
|
||||||
# Per spec, room version "11" is the default.
|
# Per spec, room version 11 is the default.
|
||||||
#
|
#
|
||||||
#default_room_version = "11"
|
#default_room_version = 11
|
||||||
|
|
||||||
# Enable OpenTelemetry OTLP tracing export. This replaces the deprecated
|
# Enable OpenTelemetry OTLP tracing export. This replaces the deprecated
|
||||||
# Jaeger exporter. Traces will be sent via OTLP to a collector (such as
|
# Jaeger exporter. Traces will be sent via OTLP to a collector (such as
|
||||||
|
|||||||
+92
-118
@@ -6,69 +6,6 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
baseTestScript =
|
|
||||||
pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; }
|
|
||||||
''
|
|
||||||
import asyncio
|
|
||||||
import nio
|
|
||||||
|
|
||||||
|
|
||||||
async def main() -> None:
|
|
||||||
# Connect to continuwuity
|
|
||||||
client = nio.AsyncClient("http://continuwuity:6167", "alice")
|
|
||||||
|
|
||||||
# Register as user alice
|
|
||||||
response = await client.register("alice", "my-secret-password")
|
|
||||||
|
|
||||||
# Log in as user alice
|
|
||||||
response = await client.login("my-secret-password")
|
|
||||||
|
|
||||||
# Create a new room
|
|
||||||
response = await client.room_create(federate=False)
|
|
||||||
print("Matrix room create response:", response)
|
|
||||||
assert isinstance(response, nio.RoomCreateResponse)
|
|
||||||
room_id = response.room_id
|
|
||||||
|
|
||||||
# Join the room
|
|
||||||
response = await client.join(room_id)
|
|
||||||
print("Matrix join response:", response)
|
|
||||||
assert isinstance(response, nio.JoinResponse)
|
|
||||||
|
|
||||||
# Send a message to the room
|
|
||||||
response = await client.room_send(
|
|
||||||
room_id=room_id,
|
|
||||||
message_type="m.room.message",
|
|
||||||
content={
|
|
||||||
"msgtype": "m.text",
|
|
||||||
"body": "Hello continuwuity!"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
print("Matrix room send response:", response)
|
|
||||||
assert isinstance(response, nio.RoomSendResponse)
|
|
||||||
|
|
||||||
# Sync responses
|
|
||||||
response = await client.sync(timeout=30000)
|
|
||||||
print("Matrix sync response:", response)
|
|
||||||
assert isinstance(response, nio.SyncResponse)
|
|
||||||
|
|
||||||
# Check the message was received by continuwuity
|
|
||||||
last_message = response.rooms.join[room_id].timeline.events[-1].body
|
|
||||||
assert last_message == "Hello continuwuity!"
|
|
||||||
|
|
||||||
# Leave the room
|
|
||||||
response = await client.room_leave(room_id)
|
|
||||||
print("Matrix room leave response:", response)
|
|
||||||
assert isinstance(response, nio.RoomLeaveResponse)
|
|
||||||
|
|
||||||
# Close the client
|
|
||||||
await client.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
asyncio.run(main())
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
# run some nixos tests as checks
|
# run some nixos tests as checks
|
||||||
checks = lib.pipe self'.packages [
|
checks = lib.pipe self'.packages [
|
||||||
@@ -81,69 +18,106 @@
|
|||||||
# this test was initially yoinked from
|
# this test was initially yoinked from
|
||||||
#
|
#
|
||||||
# https://github.com/NixOS/nixpkgs/blob/960ce26339661b1b69c6f12b9063ca51b688615f/nixos/tests/matrix/continuwuity.nix
|
# https://github.com/NixOS/nixpkgs/blob/960ce26339661b1b69c6f12b9063ca51b688615f/nixos/tests/matrix/continuwuity.nix
|
||||||
(builtins.concatMap (
|
(builtins.map (name: {
|
||||||
name:
|
name = "test-${name}";
|
||||||
builtins.map
|
value = pkgs.testers.runNixOSTest {
|
||||||
(
|
inherit name;
|
||||||
{ config, suffix }:
|
|
||||||
{
|
|
||||||
name = "test-${name}-${suffix}";
|
|
||||||
value = pkgs.testers.runNixOSTest {
|
|
||||||
inherit name;
|
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
continuwuity = {
|
continuwuity = {
|
||||||
services.matrix-continuwuity = {
|
services.matrix-continuwuity = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = self'.packages.${name};
|
package = self'.packages.${name};
|
||||||
settings = config;
|
settings.global = {
|
||||||
extraEnvironment.RUST_BACKTRACE = "yes";
|
|
||||||
};
|
|
||||||
networking.firewall.allowedTCPPorts = [ 6167 ];
|
|
||||||
};
|
|
||||||
client.environment.systemPackages = [ baseTestScript ];
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
|
||||||
start_all()
|
|
||||||
|
|
||||||
with subtest("start continuwuity"):
|
|
||||||
continuwuity.wait_for_unit("continuwuity.service")
|
|
||||||
continuwuity.wait_for_open_port(6167)
|
|
||||||
|
|
||||||
with subtest("ensure messages can be exchanged"):
|
|
||||||
client.succeed("${lib.getExe baseTestScript} >&2")
|
|
||||||
'';
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
[
|
|
||||||
{
|
|
||||||
suffix = "base";
|
|
||||||
config = {
|
|
||||||
global = {
|
|
||||||
server_name = name;
|
server_name = name;
|
||||||
address = [ "0.0.0.0" ];
|
address = [ "0.0.0.0" ];
|
||||||
allow_registration = true;
|
allow_registration = true;
|
||||||
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true;
|
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true;
|
||||||
};
|
};
|
||||||
|
extraEnvironment.RUST_BACKTRACE = "yes";
|
||||||
};
|
};
|
||||||
}
|
networking.firewall.allowedTCPPorts = [ 6167 ];
|
||||||
{
|
};
|
||||||
suffix = "with-room-version";
|
client =
|
||||||
config = {
|
{ pkgs, ... }:
|
||||||
global = {
|
{
|
||||||
server_name = name;
|
environment.systemPackages = [
|
||||||
address = [ "0.0.0.0" ];
|
(pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; } ''
|
||||||
allow_registration = true;
|
import asyncio
|
||||||
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true;
|
import nio
|
||||||
default_room_version = "12";
|
|
||||||
};
|
|
||||||
|
async def main() -> None:
|
||||||
|
# Connect to continuwuity
|
||||||
|
client = nio.AsyncClient("http://continuwuity:6167", "alice")
|
||||||
|
|
||||||
|
# Register as user alice
|
||||||
|
response = await client.register("alice", "my-secret-password")
|
||||||
|
|
||||||
|
# Log in as user alice
|
||||||
|
response = await client.login("my-secret-password")
|
||||||
|
|
||||||
|
# Create a new room
|
||||||
|
response = await client.room_create(federate=False)
|
||||||
|
print("Matrix room create response:", response)
|
||||||
|
assert isinstance(response, nio.RoomCreateResponse)
|
||||||
|
room_id = response.room_id
|
||||||
|
|
||||||
|
# Join the room
|
||||||
|
response = await client.join(room_id)
|
||||||
|
print("Matrix join response:", response)
|
||||||
|
assert isinstance(response, nio.JoinResponse)
|
||||||
|
|
||||||
|
# Send a message to the room
|
||||||
|
response = await client.room_send(
|
||||||
|
room_id=room_id,
|
||||||
|
message_type="m.room.message",
|
||||||
|
content={
|
||||||
|
"msgtype": "m.text",
|
||||||
|
"body": "Hello continuwuity!"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
print("Matrix room send response:", response)
|
||||||
|
assert isinstance(response, nio.RoomSendResponse)
|
||||||
|
|
||||||
|
# Sync responses
|
||||||
|
response = await client.sync(timeout=30000)
|
||||||
|
print("Matrix sync response:", response)
|
||||||
|
assert isinstance(response, nio.SyncResponse)
|
||||||
|
|
||||||
|
# Check the message was received by continuwuity
|
||||||
|
last_message = response.rooms.join[room_id].timeline.events[-1].body
|
||||||
|
assert last_message == "Hello continuwuity!"
|
||||||
|
|
||||||
|
# Leave the room
|
||||||
|
response = await client.room_leave(room_id)
|
||||||
|
print("Matrix room leave response:", response)
|
||||||
|
assert isinstance(response, nio.RoomLeaveResponse)
|
||||||
|
|
||||||
|
# Close the client
|
||||||
|
await client.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
|
'')
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
]
|
|
||||||
))
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
|
||||||
|
with subtest("start continuwuity"):
|
||||||
|
continuwuity.wait_for_unit("continuwuity.service")
|
||||||
|
continuwuity.wait_for_open_port(6167)
|
||||||
|
|
||||||
|
with subtest("ensure messages can be exchanged"):
|
||||||
|
client.succeed("do_test >&2")
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
}))
|
||||||
builtins.listToAttrs
|
builtins.listToAttrs
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -703,13 +703,10 @@ pub struct Config {
|
|||||||
pub allow_unstable_room_versions: bool,
|
pub allow_unstable_room_versions: bool,
|
||||||
|
|
||||||
/// Default room version continuwuity will create rooms with.
|
/// Default room version continuwuity will create rooms with.
|
||||||
/// Note that this has to be a string since the room version is a string
|
|
||||||
/// rather than an integer. Forgetting the quotes will make the server fail
|
|
||||||
/// to start!
|
|
||||||
///
|
///
|
||||||
/// Per spec, room version "11" is the default.
|
/// Per spec, room version 11 is the default.
|
||||||
///
|
///
|
||||||
/// default: "11"
|
/// default: 11
|
||||||
#[serde(default = "default_default_room_version")]
|
#[serde(default = "default_default_room_version")]
|
||||||
pub default_room_version: RoomVersionId,
|
pub default_room_version: RoomVersionId,
|
||||||
|
|
||||||
|
|||||||
+24
-16
@@ -590,6 +590,10 @@ async fn fix_readreceiptid_readreceipt_duplicates(services: &Services) -> Result
|
|||||||
|
|
||||||
const FIXED_CORRUPT_MSC4133_FIELDS_MARKER: &[u8] = b"fix_corrupt_msc4133_fields";
|
const FIXED_CORRUPT_MSC4133_FIELDS_MARKER: &[u8] = b"fix_corrupt_msc4133_fields";
|
||||||
async fn fix_corrupt_msc4133_fields(services: &Services) -> Result {
|
async fn fix_corrupt_msc4133_fields(services: &Services) -> Result {
|
||||||
|
// Due to an old bug, some conduwuit databases have `us.cloke.msc4175.tz` user
|
||||||
|
// profile fields with raw strings instead of quoted JSON ones.
|
||||||
|
// This migration fixes that.
|
||||||
|
|
||||||
use serde_json::{Value, from_slice};
|
use serde_json::{Value, from_slice};
|
||||||
type KeyVal<'a> = ((OwnedUserId, String), &'a [u8]);
|
type KeyVal<'a> = ((OwnedUserId, String), &'a [u8]);
|
||||||
|
|
||||||
@@ -606,24 +610,28 @@ async fn fix_corrupt_msc4133_fields(services: &Services) -> Result {
|
|||||||
async |(mut total, mut fixed),
|
async |(mut total, mut fixed),
|
||||||
((user, key), value): KeyVal<'_>|
|
((user, key), value): KeyVal<'_>|
|
||||||
-> Result<(usize, usize)> {
|
-> Result<(usize, usize)> {
|
||||||
if let Err(error) = from_slice::<Value>(value) {
|
match from_slice::<Value>(value) {
|
||||||
// Due to an old bug, some conduwuit databases have `us.cloke.msc4175.tz` user
|
// corrupted timezone field
|
||||||
// profile fields with raw strings instead of quoted JSON ones.
|
| Err(_) if key == "us.cloke.msc4175.tz" => {
|
||||||
// This migration fixes that.
|
let new_value = Value::String(String::from_utf8(value.to_vec())?);
|
||||||
let new_value = if key == "us.cloke.msc4175.tz" {
|
useridprofilekey_value.put((user, key), Json(new_value));
|
||||||
Value::String(String::from_utf8(value.to_vec())?)
|
fixed = fixed.saturating_add(1);
|
||||||
} else {
|
},
|
||||||
return Err!(
|
// corrupted value for some other key
|
||||||
"failed to deserialize msc4133 key {} of user {}: {}",
|
| Err(error) => {
|
||||||
key,
|
warn!(
|
||||||
user,
|
"deleting MSC4133 key {} for user {} due to deserialization \
|
||||||
error
|
failure: {}",
|
||||||
|
key, user, error
|
||||||
);
|
);
|
||||||
};
|
useridprofilekey_value.del((user, key));
|
||||||
|
},
|
||||||
useridprofilekey_value.put((user, key), Json(new_value));
|
// other key with no issues
|
||||||
fixed = fixed.saturating_add(1);
|
| Ok(_) => {
|
||||||
|
// do nothing
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
total = total.saturating_add(1);
|
total = total.saturating_add(1);
|
||||||
|
|
||||||
Ok((total, fixed))
|
Ok((total, fixed))
|
||||||
|
|||||||
Reference in new issue
Block a user