Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
4be68eba
Unverified
Commit
4be68eba
authored
4 years ago
by
Timo
Browse files
Options
Downloads
Patches
Plain Diff
feat: allow querying conduit's room list over federation
parent
940f533d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.rs
+2
-0
2 additions, 0 deletions
src/main.rs
src/server_server.rs
+90
-5
90 additions, 5 deletions
src/server_server.rs
with
92 additions
and
5 deletions
src/main.rs
+
2
−
0
View file @
4be68eba
...
...
@@ -114,6 +114,8 @@ fn setup_rocket() -> rocket::Rocket {
server_server
::
get_server_version
,
server_server
::
get_server_keys
,
server_server
::
get_server_keys_deprecated
,
server_server
::
get_public_rooms_route
,
server_server
::
send_transaction_message_route
,
],
)
.attach
(
AdHoc
::
on_attach
(
"Config"
,
|
mut
rocket
|
async
{
...
...
This diff is collapsed.
Click to expand it.
src/server_server.rs
+
90
−
5
View file @
4be68eba
use
crate
::{
ConduitResult
,
Database
,
Result
};
use
crate
::{
client_server
,
ConduitResult
,
Database
,
Error
,
Result
,
Ruma
};
use
http
::
header
::{
HeaderValue
,
AUTHORIZATION
};
use
rocket
::{
get
,
response
::
content
::
Json
,
State
};
use
ruma
::
api
::
federation
::
discovery
::{
get_server_keys
,
get_server_version
::
v1
as
get_server_version
,
ServerKey
,
VerifyKey
,
use
rocket
::{
get
,
post
,
put
,
response
::
content
::
Json
,
State
};
use
ruma
::
api
::
federation
::{
directory
::
get_public_rooms
,
discovery
::{
get_server_keys
,
get_server_version
::
v1
as
get_server_version
,
ServerKey
,
VerifyKey
,
},
transactions
::
send_transaction_message
,
};
use
ruma
::
api
::
OutgoingRequest
;
use
ruma
::
api
::
{
client
,
OutgoingRequest
}
;
use
serde_json
::
json
;
use
std
::{
collections
::
BTreeMap
,
...
...
@@ -193,3 +197,84 @@ pub fn get_server_keys(db: State<'_, Database>) -> Json<String> {
pub
fn
get_server_keys_deprecated
(
db
:
State
<
'_
,
Database
>
)
->
Json
<
String
>
{
get_server_keys
(
db
)
}
#[cfg_attr(
feature
=
"conduit_bin"
,
post(
"/_matrix/federation/v1/publicRooms"
,
data
=
"<body>"
)
)]
pub
async
fn
get_public_rooms_route
(
db
:
State
<
'_
,
Database
>
,
body
:
Ruma
<
get_public_rooms
::
v1
::
Request
>
,
)
->
ConduitResult
<
get_public_rooms
::
v1
::
Response
>
{
let
Ruma
{
body
:
get_public_rooms
::
v1
::
Request
{
room_network
:
_room_network
,
// TODO
limit
,
since
,
},
sender_id
,
device_id
,
json_body
,
}
=
body
;
let
client
::
r0
::
directory
::
get_public_rooms_filtered
::
Response
{
chunk
,
prev_batch
,
next_batch
,
total_room_count_estimate
,
}
=
client_server
::
get_public_rooms_filtered_route
(
db
,
Ruma
{
body
:
client
::
r0
::
directory
::
get_public_rooms_filtered
::
IncomingRequest
{
filter
:
None
,
limit
,
room_network
:
client
::
r0
::
directory
::
get_public_rooms_filtered
::
RoomNetwork
::
Matrix
,
server
:
None
,
since
,
},
sender_id
,
device_id
,
json_body
,
},
)
.await
?
.0
;
Ok
(
get_public_rooms
::
v1
::
Response
{
chunk
:
chunk
.into_iter
()
.map
(|
c
|
{
// Convert ruma::api::federation::directory::get_public_rooms::v1::PublicRoomsChunk
// to ruma::api::client::r0::directory::PublicRoomsChunk
Ok
::
<
_
,
Error
>
(
serde_json
::
from_str
(
&
serde_json
::
to_string
(
&
c
)
.expect
(
"PublicRoomsChunk::to_string always works"
),
)
.expect
(
"federation and client-server PublicRoomsChunk are the same type"
),
)
})
.filter_map
(|
r
|
r
.ok
())
.collect
(),
prev_batch
,
next_batch
,
total_room_count_estimate
,
}
.into
())
}
#[cfg_attr(
feature
=
"conduit_bin"
,
put(
"/_matrix/federation/v1/send/<_>"
,
data
=
"<body>"
)
)]
pub
fn
send_transaction_message_route
(
db
:
State
<
'_
,
Database
>
,
body
:
Ruma
<
send_transaction_message
::
v1
::
Request
>
,
)
->
ConduitResult
<
send_transaction_message
::
v1
::
Response
>
{
dbg!
(
&*
body
);
Ok
(
send_transaction_message
::
v1
::
Response
{
pdus
:
BTreeMap
::
new
(),
}
.into
())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment