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
ed86a4aa
Commit
ed86a4aa
authored
10 months ago
by
🥺
Committed by
🥺
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
slight misc adjustments
Signed-off-by:
strawberry
<
strawberry@puppygock.gay
>
parent
b282c1eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/api/client_server/keys.rs
+4
-10
4 additions, 10 deletions
src/api/client_server/keys.rs
src/api/client_server/media.rs
+7
-5
7 additions, 5 deletions
src/api/client_server/media.rs
with
11 additions
and
15 deletions
src/api/client_server/keys.rs
+
4
−
10
View file @
ed86a4aa
...
...
@@ -75,24 +75,20 @@ pub(crate) async fn upload_keys_route(body: Ruma<upload_keys::v3::Request>) -> R
pub
(
crate
)
async
fn
get_keys_route
(
body
:
Ruma
<
get_keys
::
v3
::
Request
>
)
->
Result
<
get_keys
::
v3
::
Response
>
{
let
sender_user
=
body
.sender_user
.as_ref
()
.expect
(
"user is authenticated"
);
let
response
=
get_keys_helper
(
get_keys_helper
(
Some
(
sender_user
),
&
body
.device_keys
,
|
u
|
u
==
sender_user
,
true
,
// Always allow local users to see device names of other local users
)
.await
?
;
Ok
(
response
)
.await
}
/// # `POST /_matrix/client/r0/keys/claim`
///
/// Claims one-time keys
pub
(
crate
)
async
fn
claim_keys_route
(
body
:
Ruma
<
claim_keys
::
v3
::
Request
>
)
->
Result
<
claim_keys
::
v3
::
Response
>
{
let
response
=
claim_keys_helper
(
&
body
.one_time_keys
)
.await
?
;
Ok
(
response
)
claim_keys_helper
(
&
body
.one_time_keys
)
.await
}
/// # `POST /_matrix/client/r0/keys/device_signing/upload`
...
...
@@ -262,8 +258,6 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
let
mut
get_over_federation
=
HashMap
::
new
();
for
(
user_id
,
device_ids
)
in
device_keys_input
{
let
user_id
:
&
UserId
=
user_id
;
if
!
user_is_local
(
user_id
)
{
get_over_federation
.entry
(
user_id
.server_name
())
...
...
@@ -322,7 +316,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
{
self_signing_keys
.insert
(
user_id
.to_owned
(),
self_signing_key
);
}
if
Some
(
user_id
)
==
sender_user
{
if
user_id
==
sender_user
.expect
(
"user is authenticated"
)
{
if
let
Some
(
user_signing_key
)
=
services
()
.users
.get_user_signing_key
(
user_id
)
?
{
user_signing_keys
.insert
(
user_id
.to_owned
(),
user_signing_key
);
}
...
...
This diff is collapsed.
Click to expand it.
src/api/client_server/media.rs
+
7
−
5
View file @
ed86a4aa
...
...
@@ -27,6 +27,8 @@
/// Cache control for immutable objects
const
CACHE_CONTROL_IMMUTABLE
:
&
str
=
"public, max-age=31536000, immutable"
;
const
CORP_CROSS_ORIGIN
:
&
str
=
"cross-origin"
;
/// # `GET /_matrix/media/v3/config`
///
/// Returns max upload size.
...
...
@@ -180,7 +182,7 @@ pub(crate) async fn get_content_route(body: Ruma<get_content::v3::Request>) -> R
file
,
content_type
,
content_disposition
,
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cross_origin_resource_policy
:
Some
(
CORP_CROSS_ORIGIN
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
if
!
server_is_ours
(
&
body
.server_name
)
&&
body
.allow_remote
{
...
...
@@ -242,7 +244,7 @@ pub(crate) async fn get_content_as_filename_route(
file
,
content_type
,
content_disposition
:
Some
(
format!
(
"inline; filename={}"
,
body
.filename
)),
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cross_origin_resource_policy
:
Some
(
CORP_CROSS_ORIGIN
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
if
!
server_is_ours
(
&
body
.server_name
)
&&
body
.allow_remote
{
...
...
@@ -259,7 +261,7 @@ pub(crate) async fn get_content_as_filename_route(
content_disposition
:
Some
(
format!
(
"inline: filename={}"
,
body
.filename
)),
content_type
:
remote_content_response
.content_type
,
file
:
remote_content_response
.file
,
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cross_origin_resource_policy
:
Some
(
CORP_CROSS_ORIGIN
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
}),
Err
(
e
)
=>
{
...
...
@@ -323,7 +325,7 @@ pub(crate) async fn get_content_thumbnail_route(
Ok
(
get_content_thumbnail
::
v3
::
Response
{
file
,
content_type
,
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cross_origin_resource_policy
:
Some
(
CORP_CROSS_ORIGIN
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
if
!
server_is_ours
(
&
body
.server_name
)
&&
body
.allow_remote
{
...
...
@@ -409,7 +411,7 @@ async fn get_remote_content(
{
// we'll lie to the client and say the blocked server's media was not found and
// log. the client has no way of telling anyways so this is a security bonus.
debug_warn!
(
"Received request for media `{}` on blocklisted server"
,
mxc
);
debug_warn!
(
"Received request for media `{
mxc
}` on blocklisted server"
);
return
Err
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Media not found."
));
}
...
...
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