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
4d21f9d9
Commit
4d21f9d9
authored
9 months ago
by
🥺
Committed by
🥺
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
use ok_or_else instead of ok_or for function calls in server_server.rs
Signed-off-by:
strawberry
<
strawberry@puppygock.gay
>
parent
1013fe5a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/api/server_server.rs
+12
-14
12 additions, 14 deletions
src/api/server_server.rs
with
12 additions
and
14 deletions
src/api/server_server.rs
+
12
−
14
View file @
4d21f9d9
...
@@ -641,7 +641,7 @@ pub(crate) async fn get_backfill_route(body: Ruma<get_backfill::v1::Request>) ->
...
@@ -641,7 +641,7 @@ pub(crate) async fn get_backfill_route(body: Ruma<get_backfill::v1::Request>) ->
.map
(|
eventid
|
services
()
.rooms.timeline
.get_pdu_count
(
eventid
))
.map
(|
eventid
|
services
()
.rooms.timeline
.get_pdu_count
(
eventid
))
.filter_map
(|
r
|
r
.ok
()
.flatten
())
.filter_map
(|
r
|
r
.ok
()
.flatten
())
.max
()
.max
()
.ok_or
(
Error
::
BadRequest
(
ErrorKind
::
InvalidParam
,
"No known eventid in v"
))
?
;
.ok_or
_else
(||
Error
::
BadRequest
(
ErrorKind
::
InvalidParam
,
"No known eventid in v"
))
?
;
let
limit
=
body
.limit
.min
(
uint!
(
100
));
let
limit
=
body
.limit
.min
(
uint!
(
100
));
...
@@ -824,7 +824,7 @@ pub(crate) async fn get_room_state_route(
...
@@ -824,7 +824,7 @@ pub(crate) async fn get_room_state_route(
.rooms
.rooms
.state_accessor
.state_accessor
.pdu_shortstatehash
(
&
body
.event_id
)
?
.pdu_shortstatehash
(
&
body
.event_id
)
?
.ok_or
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Pdu state not found."
))
?
;
.ok_or
_else
(||
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Pdu state not found."
))
?
;
let
pdus
=
services
()
let
pdus
=
services
()
.rooms
.rooms
...
@@ -890,7 +890,7 @@ pub(crate) async fn get_room_state_ids_route(
...
@@ -890,7 +890,7 @@ pub(crate) async fn get_room_state_ids_route(
.rooms
.rooms
.state_accessor
.state_accessor
.pdu_shortstatehash
(
&
body
.event_id
)
?
.pdu_shortstatehash
(
&
body
.event_id
)
?
.ok_or
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Pdu state not found."
))
?
;
.ok_or
_else
(||
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Pdu state not found."
))
?
;
let
pdu_ids
=
services
()
let
pdu_ids
=
services
()
.rooms
.rooms
...
@@ -1158,7 +1158,7 @@ async fn create_join_event(
...
@@ -1158,7 +1158,7 @@ async fn create_join_event(
.rooms
.rooms
.state
.state
.get_room_shortstatehash
(
room_id
)
?
.get_room_shortstatehash
(
room_id
)
?
.ok_or
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Pdu state not found."
))
?
;
.ok_or
_else
(||
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Pdu state not found."
))
?
;
let
pub_key_map
=
RwLock
::
new
(
BTreeMap
::
new
());
let
pub_key_map
=
RwLock
::
new
(
BTreeMap
::
new
());
// let mut auth_cache = EventMap::new();
// let mut auth_cache = EventMap::new();
...
@@ -1291,10 +1291,9 @@ async fn create_join_event(
...
@@ -1291,10 +1291,9 @@ async fn create_join_event(
.event_handler
.event_handler
.handle_incoming_pdu
(
&
origin
,
room_id
,
&
event_id
,
value
.clone
(),
true
,
&
pub_key_map
)
.handle_incoming_pdu
(
&
origin
,
room_id
,
&
event_id
,
value
.clone
(),
true
,
&
pub_key_map
)
.await
?
.await
?
.ok_or
(
Error
::
BadRequest
(
.ok_or_else
(||
{
ErrorKind
::
InvalidParam
,
Error
::
BadRequest
(
ErrorKind
::
InvalidParam
,
"Could not accept incoming PDU as timeline event."
)
"Could not accept incoming PDU as timeline event."
,
})
?
;
))
?
;
drop
(
mutex_lock
);
drop
(
mutex_lock
);
let
state_ids
=
services
()
let
state_ids
=
services
()
...
@@ -1631,7 +1630,7 @@ async fn create_leave_event(origin: &ServerName, room_id: &RoomId, pdu: &RawJson
...
@@ -1631,7 +1630,7 @@ async fn create_leave_event(origin: &ServerName, room_id: &RoomId, pdu: &RawJson
serde_json
::
to_value
(
serde_json
::
to_value
(
value
value
.get
(
"origin"
)
.get
(
"origin"
)
.ok_or
(
Error
::
BadRequest
(
ErrorKind
::
InvalidParam
,
"Event needs an origin field."
))
?
,
.ok_or
_else
(||
Error
::
BadRequest
(
ErrorKind
::
InvalidParam
,
"Event needs an origin field."
))
?
,
)
)
.expect
(
"CanonicalJson is valid json value"
),
.expect
(
"CanonicalJson is valid json value"
),
)
)
...
@@ -1658,10 +1657,9 @@ async fn create_leave_event(origin: &ServerName, room_id: &RoomId, pdu: &RawJson
...
@@ -1658,10 +1657,9 @@ async fn create_leave_event(origin: &ServerName, room_id: &RoomId, pdu: &RawJson
.event_handler
.event_handler
.handle_incoming_pdu
(
&
origin
,
room_id
,
&
event_id
,
value
,
true
,
&
pub_key_map
)
.handle_incoming_pdu
(
&
origin
,
room_id
,
&
event_id
,
value
,
true
,
&
pub_key_map
)
.await
?
.await
?
.ok_or
(
Error
::
BadRequest
(
.ok_or_else
(||
{
ErrorKind
::
InvalidParam
,
Error
::
BadRequest
(
ErrorKind
::
InvalidParam
,
"Could not accept incoming PDU as timeline event."
)
"Could not accept incoming PDU as timeline event."
,
})
?
;
))
?
;
drop
(
mutex_lock
);
drop
(
mutex_lock
);
...
@@ -1914,7 +1912,7 @@ pub(crate) async fn get_room_information_route(
...
@@ -1914,7 +1912,7 @@ pub(crate) async fn get_room_information_route(
.rooms
.rooms
.alias
.alias
.resolve_local_alias
(
&
body
.room_alias
)
?
.resolve_local_alias
(
&
body
.room_alias
)
?
.ok_or
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Room alias not found."
))
?
;
.ok_or
_else
(||
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Room alias not found."
))
?
;
let
mut
servers
:
Vec
<
OwnedServerName
>
=
services
()
let
mut
servers
:
Vec
<
OwnedServerName
>
=
services
()
.rooms
.rooms
...
...
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