Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
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
matrix-media-repo
Commits
fe1550c2
Commit
fe1550c2
authored
1 year ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Update MSC4034 implementation
parent
ed3a0a54
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
api/unstable/public_usage.go
+5
-17
5 additions, 17 deletions
api/unstable/public_usage.go
with
5 additions
and
17 deletions
api/unstable/public_usage.go
+
5
−
17
View file @
fe1550c2
...
@@ -10,30 +10,18 @@ import (
...
@@ -10,30 +10,18 @@ import (
)
)
type
PublicUsageResponse
struct
{
type
PublicUsageResponse
struct
{
Storage
Free
int64
`json:"org.matrix.msc4034.storage.
free
,omitempty"`
Storage
Used
int64
`json:"org.matrix.msc4034.storage.
used
,omitempty"`
StorageFiles
int64
`json:"org.matrix.msc4034.storage.files,omitempty"`
StorageFiles
int64
`json:"org.matrix.msc4034.storage.files,omitempty"`
}
}
func
PublicUsage
(
r
*
http
.
Request
,
rctx
rcontext
.
RequestContext
,
user
_apimeta
.
UserInfo
)
interface
{}
{
func
PublicUsage
(
r
*
http
.
Request
,
rctx
rcontext
.
RequestContext
,
user
_apimeta
.
UserInfo
)
interface
{}
{
storageUsed
:=
int64
(
0
)
storageUsed
:=
int64
(
0
)
storageLimit
:=
int64
(
0
)
current
,
err
:=
quota
.
Current
(
rctx
,
user
.
UserId
,
quota
.
MaxBytes
)
limit
,
err
:=
quota
.
Limit
(
rctx
,
user
.
UserId
,
quota
.
MaxBytes
)
if
err
!=
nil
{
if
err
!=
nil
{
rctx
.
Log
.
Warn
(
"Non-fatal error getting per-user quota
limit
(max bytes): "
,
err
)
rctx
.
Log
.
Warn
(
"Non-fatal error getting per-user quota
usage
(max bytes
@ now
): "
,
err
)
sentry
.
CaptureException
(
err
)
sentry
.
CaptureException
(
err
)
}
else
if
limit
>
0
{
storageLimit
=
limit
}
if
storageLimit
>
0
{
current
,
err
:=
quota
.
Current
(
rctx
,
user
.
UserId
,
quota
.
MaxBytes
)
if
err
!=
nil
{
rctx
.
Log
.
Warn
(
"Non-fatal error getting per-user quota usage (max bytes @ now): "
,
err
)
sentry
.
CaptureException
(
err
)
}
else
{
storageUsed
=
current
}
}
else
{
}
else
{
storage
Limit
=
0
storage
Used
=
current
}
}
fileCount
,
err
:=
quota
.
Current
(
rctx
,
user
.
UserId
,
quota
.
MaxCount
)
fileCount
,
err
:=
quota
.
Current
(
rctx
,
user
.
UserId
,
quota
.
MaxCount
)
...
@@ -43,7 +31,7 @@ func PublicUsage(r *http.Request, rctx rcontext.RequestContext, user _apimeta.Us
...
@@ -43,7 +31,7 @@ func PublicUsage(r *http.Request, rctx rcontext.RequestContext, user _apimeta.Us
}
}
return
&
PublicUsageResponse
{
return
&
PublicUsageResponse
{
Storage
Free
:
storageLimit
-
storageUsed
,
Storage
Used
:
storageUsed
,
StorageFiles
:
fileCount
,
StorageFiles
:
fileCount
,
}
}
}
}
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