Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
elixire
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ave
elixire
Commits
86300a97
Unverified
Commit
86300a97
authored
7 years ago
by
Ave O
Browse files
Options
Downloads
Patches
Plain Diff
Fix shorten, improve domains, make list work with multiple domain
parent
94d9ac94
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/bp/files.py
+19
-4
19 additions, 4 deletions
api/bp/files.py
api/bp/profile.py
+1
-3
1 addition, 3 deletions
api/bp/profile.py
api/bp/shorten.py
+6
-6
6 additions, 6 deletions
api/bp/shorten.py
with
26 additions
and
13 deletions
api/bp/files.py
+
19
−
4
View file @
86300a97
...
...
@@ -11,13 +11,23 @@ bp = Blueprint('files')
log
=
logging
.
getLogger
(
__name__
)
async
def
domain_list
(
request
):
"""
Returns a dictionary with domain IDs mapped to domain names
"""
domain_info
=
await
request
.
app
.
db
.
fetch
(
"""
SELECT domain_id, domain
FROM domains
"""
)
return
dict
(
domain_info
)
@bp.get
(
'
/api/list
'
)
async
def
list_handler
(
request
):
"""
Get list of files.
"""
user_id
=
await
token_check
(
request
)
domains
=
await
domain_list
(
request
)
user_files
=
await
request
.
app
.
db
.
fetch
(
"""
SELECT fspath
SELECT fspath
, domain
FROM files
WHERE uploader = $1
AND deleted = false
...
...
@@ -25,19 +35,24 @@ async def list_handler(request):
"""
,
user_id
)
user_shortens
=
await
request
.
app
.
db
.
fetch
(
"""
SELECT filename, redirto
SELECT filename, redirto
, domain
FROM shortens
WHERE uploader = $1
AND deleted = false
ORDER BY shorten_id DESC
"""
,
user_id
)
filenames
=
[
os
.
path
.
basename
(
ufile
[
'
fspath
'
])
for
ufile
in
user_files
]
filenames
=
[
f
"
https://
{
domains
[
ufile
[
'
domain
'
]]
}
/i/
"
f
"
{
os
.
path
.
basename
(
ufile
[
'
fspath
'
])
}
"
for
ufile
in
user_files
]
shortens
=
[{
f
"
https://
{
domains
[
ushorten
[
'
domain
'
]]
}
/s/
"
f
"
{
ushorten
[
'
filename
'
]
}
"
:
ushorten
[
"
redirto
"
]}
for
ushorten
in
user_shortens
]
return
response
.
json
({
'
success
'
:
True
,
'
files
'
:
filenames
,
'
shortens
'
:
user_
shortens
'
shortens
'
:
shortens
})
...
...
This diff is collapsed.
Click to expand it.
api/bp/profile.py
+
1
−
3
View file @
86300a97
...
...
@@ -21,9 +21,7 @@ async def domainlist_handler(request):
FROM domains
"""
+
adm_string
)
domains
=
[{
record
[
"
domain_id
"
]:
record
[
"
domain
"
]}
for
record
in
domain_records
]
return
response
.
json
({
"
domains
"
:
domains
})
return
response
.
json
({
"
domains
"
:
dict
(
domain_records
)})
@bp.get
(
'
/api/profile
'
)
...
...
This diff is collapsed.
Click to expand it.
api/bp/shorten.py
+
6
−
6
View file @
86300a97
...
...
@@ -75,12 +75,6 @@ async def shorten_handler(request):
redir_rname
=
await
gen_filename
(
request
)
redir_id
=
get_snowflake
()
await
request
.
app
.
db
.
execute
(
"""
INSERT INTO shortens (shorten_id, filename,
uploader, redirto)
VALUES ($1, $2, $3, $4)
"""
,
redir_id
,
redir_rname
,
user_id
,
url_toredir
)
# get domain ID from user and return it
domain_id
=
await
request
.
app
.
db
.
fetchval
(
"""
SELECT domain
...
...
@@ -88,6 +82,12 @@ async def shorten_handler(request):
WHERE user_id = $1
"""
,
user_id
)
await
request
.
app
.
db
.
execute
(
"""
INSERT INTO shortens (shorten_id, filename,
uploader, redirto, domain)
VALUES ($1, $2, $3, $4, $5)
"""
,
redir_id
,
redir_rname
,
user_id
,
url_toredir
,
domain_id
)
domain
=
await
request
.
app
.
db
.
fetchval
(
"""
SELECT domain
FROM domains
...
...
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