Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vaultwarden
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
Container Registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vaultwarden
Commits
551810c4
Unverified
Commit
551810c4
authored
4 years ago
by
Daniel García
Browse files
Options
Downloads
Patches
Plain Diff
Fix updating file send
parent
b987ba50
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/core/sends.rs
+12
-16
12 additions, 16 deletions
src/api/core/sends.rs
with
12 additions
and
16 deletions
src/api/core/sends.rs
+
12
−
16
View file @
551810c4
...
...
@@ -48,7 +48,7 @@ pub struct SendData {
/// modify existing ones, but is allowed to delete them.
///
/// Ref: https://bitwarden.com/help/article/policies/#disable-send
fn
enforce_disable_send_policy
(
headers
:
&
Headers
,
conn
:
&
DbConn
)
->
EmptyResult
{
fn
enforce_disable_send_policy
(
headers
:
&
Headers
,
conn
:
&
DbConn
)
->
EmptyResult
{
let
user_uuid
=
&
headers
.user.uuid
;
let
policy_type
=
OrgPolicyType
::
DisableSend
;
if
OrgPolicy
::
is_applicable_to_user
(
user_uuid
,
policy_type
,
conn
)
{
...
...
@@ -323,27 +323,23 @@ fn put_send(id: String, data: JsonUpcase<SendData>, headers: Headers, conn: DbCo
err!
(
"Sends can't change type"
)
}
let
data_val
=
if
data
.Type
==
SendType
::
Text
as
i32
{
data
.Text
}
else
if
data
.Type
==
SendType
::
File
as
i32
{
data
.File
}
else
{
err!
(
"Invalid Send type"
)
};
let
data_str
=
if
let
Some
(
mut
d
)
=
data_val
{
d
.as_object_mut
()
.and_then
(|
d
|
d
.remove
(
"Response"
));
serde_json
::
to_string
(
&
d
)
?
}
else
{
err!
(
"Send data not provided"
);
};
// When updating a file Send, we receive nulls in the File field, as it's immutable,
// so we only need to update the data field in the Text case
if
data
.Type
==
SendType
::
Text
as
i32
{
let
data_str
=
if
let
Some
(
mut
d
)
=
data
.Text
{
d
.as_object_mut
()
.and_then
(|
d
|
d
.remove
(
"Response"
));
serde_json
::
to_string
(
&
d
)
?
}
else
{
err!
(
"Send data not provided"
);
};
send
.data
=
data_str
;
}
if
data
.DeletionDate
>
Utc
::
now
()
+
Duration
::
days
(
31
)
{
err!
(
"You cannot have a Send with a deletion date that far into the future. Adjust the Deletion Date to a value less than 31 days from now and try again."
);
}
send
.data
=
data_str
;
send
.name
=
data
.Name
;
send
.akey
=
data
.Key
;
send
.deletion_date
=
data
.DeletionDate
.naive_utc
();
...
...
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