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
d57c1980
Unverified
Commit
d57c1980
authored
3 years ago
by
Timo Kösters
Browse files
Options
Downloads
Patches
Plain Diff
improvement: don't do state updates if the event was soft failed
parent
632a1343
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/server_server.rs
+41
-30
41 additions, 30 deletions
src/server_server.rs
with
41 additions
and
30 deletions
src/server_server.rs
+
41
−
30
View file @
d57c1980
...
...
@@ -1497,6 +1497,47 @@ async fn upgrade_outlier_to_timeline_pdu(
)
.map_err
(|
_
|
"Failed to get_auth_events."
.to_owned
())
?
;
let
state_ids_compressed
=
state_at_incoming_event
.iter
()
.map
(|(
shortstatekey
,
id
)|
{
db
.rooms
.compress_state_event
(
*
shortstatekey
,
&
id
,
&
db
.globals
)
.map_err
(|
_
|
"Failed to compress_state_event"
.to_owned
())
})
.collect
::
<
StdResult
<
_
,
String
>>
()
?
;
// 13. Check if the event passes auth based on the "current state" of the room, if not "soft fail" it
debug!
(
"starting soft fail auth check"
);
let
soft_fail
=
!
state_res
::
event_auth
::
auth_check
(
&
room_version
,
&
incoming_pdu
,
previous_create
,
None
,
|
k
,
s
|
auth_events
.get
(
&
(
k
.clone
(),
s
.to_owned
()))
.map
(
Arc
::
clone
),
)
.map_err
(|
_e
|
"Auth check failed."
.to_owned
())
?
;
if
soft_fail
{
append_incoming_pdu
(
&
db
,
&
incoming_pdu
,
val
,
extremities
,
state_ids_compressed
,
soft_fail
,
&
state_lock
)
.map_err
(|
_
|
"Failed to add pdu to db."
.to_owned
())
?
;
// Soft fail, we keep the event as an outlier but don't add it to the timeline
warn!
(
"Event was soft failed: {:?}"
,
incoming_pdu
);
db
.rooms
.mark_event_soft_failed
(
&
incoming_pdu
.event_id
)
.map_err
(|
_
|
"Failed to set soft failed flag"
.to_owned
())
?
;
return
Err
(
"Event has been soft failed"
.into
());
}
if
incoming_pdu
.state_key
.is_some
()
{
let
mut
extremity_sstatehashes
=
HashMap
::
new
();
...
...
@@ -1651,31 +1692,10 @@ async fn upgrade_outlier_to_timeline_pdu(
extremities
.insert
(
incoming_pdu
.event_id
.clone
());
// 13. Check if the event passes auth based on the "current state" of the room, if not "soft fail" it
debug!
(
"starting soft fail auth check"
);
let
soft_fail
=
!
state_res
::
event_auth
::
auth_check
(
&
room_version
,
&
incoming_pdu
,
previous_create
,
None
,
|
k
,
s
|
auth_events
.get
(
&
(
k
.clone
(),
s
.to_owned
()))
.map
(
Arc
::
clone
),
)
.map_err
(|
_e
|
"Auth check failed."
.to_owned
())
?
;
// Now that the event has passed all auth it is added into the timeline.
// We use the `state_at_event` instead of `state_after` so we accurately
// represent the state for this event.
let
state_ids_compressed
=
state_at_incoming_event
.iter
()
.map
(|(
shortstatekey
,
id
)|
{
db
.rooms
.compress_state_event
(
*
shortstatekey
,
&
id
,
&
db
.globals
)
.map_err
(|
_
|
"Failed to compress_state_event"
.to_owned
())
})
.collect
::
<
StdResult
<
_
,
String
>>
()
?
;
let
pdu_id
=
append_incoming_pdu
(
&
db
,
&
incoming_pdu
,
...
...
@@ -1689,15 +1709,6 @@ async fn upgrade_outlier_to_timeline_pdu(
debug!
(
"Appended incoming pdu."
);
if
soft_fail
{
// Soft fail, we keep the event as an outlier but don't add it to the timeline
warn!
(
"Event was soft failed: {:?}"
,
incoming_pdu
);
db
.rooms
.mark_event_soft_failed
(
&
incoming_pdu
.event_id
)
.map_err
(|
_
|
"Failed to set soft failed flag"
.to_owned
())
?
;
return
Err
(
"Event has been soft failed"
.into
());
}
// Event has passed all auth/stateres checks
drop
(
state_lock
);
Ok
(
pdu_id
)
...
...
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