Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
V
vidai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
vidai
Commits
ef456d30
Commit
ef456d30
authored
Oct 08, 2025
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timestamp to avatar URLs to prevent browser caching of updated avatars
parent
033787b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
.gitignore
.gitignore
+1
-0
utils.py
vidai/utils.py
+2
-1
web.py
vidai/web.py
+11
-6
No files found.
.gitignore
View file @
ef456d30
...
@@ -124,6 +124,7 @@ Thumbs.db
...
@@ -124,6 +124,7 @@ Thumbs.db
# Project specific
# Project specific
static/uploads/
static/uploads/
static/temp/
static/temp/
static/avatars/
*.db
*.db
*.sqlite
*.sqlite
*.sqlite3
*.sqlite3
...
...
vidai/utils.py
View file @
ef456d30
...
@@ -29,11 +29,12 @@ def get_current_user_session():
...
@@ -29,11 +29,12 @@ def get_current_user_session():
user
=
get_current_user
(
session_id
)
user
=
get_current_user
(
session_id
)
if
user
and
user
.
get
(
'email'
):
if
user
and
user
.
get
(
'email'
):
import
hashlib
import
hashlib
import
time
email_hash
=
hashlib
.
md5
(
user
[
'email'
]
.
lower
()
.
encode
())
.
hexdigest
()
email_hash
=
hashlib
.
md5
(
user
[
'email'
]
.
lower
()
.
encode
())
.
hexdigest
()
user
[
'gravatar_url'
]
=
f
"https://www.gravatar.com/avatar/{email_hash}?s=32&d=404"
user
[
'gravatar_url'
]
=
f
"https://www.gravatar.com/avatar/{email_hash}?s=32&d=404"
# If custom avatar, use that instead
# If custom avatar, use that instead
if
user
.
get
(
'avatar'
):
if
user
.
get
(
'avatar'
):
user
[
'avatar_url'
]
=
f
"/static/avatars/{user['avatar']}"
user
[
'avatar_url'
]
=
f
"/static/avatars/{user['avatar']}
?t={int(time.time())}
"
else
:
else
:
user
[
'avatar_url'
]
=
user
[
'gravatar_url'
]
user
[
'avatar_url'
]
=
user
[
'gravatar_url'
]
return
user
return
user
...
...
vidai/web.py
View file @
ef456d30
...
@@ -1032,15 +1032,17 @@ def upload_avatar():
...
@@ -1032,15 +1032,17 @@ def upload_avatar():
if
file
and
allowed_file
(
file
.
filename
,
{
'png'
,
'jpg'
,
'jpeg'
,
'gif'
}):
if
file
and
allowed_file
(
file
.
filename
,
{
'png'
,
'jpg'
,
'jpeg'
,
'gif'
}):
# Generate unique filename
# Generate unique filename
import
uuid
import
uuid
filename
=
f
"{user['id']}_{uuid.uuid4().hex}.{file.filename.rsplit('.', 1)[1].lower()}"
ext
=
file
.
filename
.
rsplit
(
'.'
,
1
)[
1
]
.
lower
()
if
'.'
in
file
.
filename
else
'jpg'
filename
=
f
"{user['id']}_{uuid.uuid4().hex}.{ext}"
filepath
=
os
.
path
.
join
(
avatars_dir
,
filename
)
filepath
=
os
.
path
.
join
(
avatars_dir
,
filename
)
# Resize and save image
# Read file data
file_data
=
file
.
read
()
from
io
import
BytesIO
from
PIL
import
Image
from
PIL
import
Image
import
io
#
Read
image
#
Open
image
image
=
Image
.
open
(
file
.
stream
)
image
=
Image
.
open
(
BytesIO
(
file_data
)
)
# Convert to RGB if necessary
# Convert to RGB if necessary
if
image
.
mode
in
(
"RGBA"
,
"P"
):
if
image
.
mode
in
(
"RGBA"
,
"P"
):
...
@@ -1050,7 +1052,10 @@ def upload_avatar():
...
@@ -1050,7 +1052,10 @@ def upload_avatar():
image
.
thumbnail
((
128
,
128
),
Image
.
Resampling
.
LANCZOS
)
image
.
thumbnail
((
128
,
128
),
Image
.
Resampling
.
LANCZOS
)
# Save
# Save
image
.
save
(
filepath
,
optimize
=
True
,
quality
=
85
)
if
ext
==
'png'
:
image
.
save
(
filepath
,
optimize
=
True
)
else
:
image
.
save
(
filepath
,
optimize
=
True
,
quality
=
85
)
# Update user avatar in database
# Update user avatar in database
from
.database
import
update_user_avatar
from
.database
import
update_user_avatar
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment