forked from forks/microblog.pub
Fix formatting
This commit is contained in:
parent
a4cfd65009
commit
0d7c121781
2 changed files with 7 additions and 4 deletions
10
app/media.py
10
app/media.py
|
@ -15,8 +15,8 @@ class InvalidProxySignatureError(Exception):
|
||||||
|
|
||||||
def proxied_media_sig(expires: int, url: str) -> str:
|
def proxied_media_sig(expires: int, url: str) -> str:
|
||||||
hm = hmac_sha256()
|
hm = hmac_sha256()
|
||||||
hm.update(f'{expires}'.encode())
|
hm.update(f"{expires}".encode())
|
||||||
hm.update(b'|')
|
hm.update(b"|")
|
||||||
hm.update(url.encode())
|
hm.update(url.encode())
|
||||||
return base64.urlsafe_b64encode(hm.digest()).decode()
|
return base64.urlsafe_b64encode(hm.digest()).decode()
|
||||||
|
|
||||||
|
@ -34,7 +34,11 @@ def proxied_media_url(url: str) -> str:
|
||||||
expires = int(time.time() / EXPIRY_PERIOD) + EXPIRY_LENGTH
|
expires = int(time.time() / EXPIRY_PERIOD) + EXPIRY_LENGTH
|
||||||
sig = proxied_media_sig(expires, url)
|
sig = proxied_media_sig(expires, url)
|
||||||
|
|
||||||
return BASE_URL + f"/proxy/media/{expires}/{sig}/" + base64.urlsafe_b64encode(url.encode()).decode()
|
return (
|
||||||
|
BASE_URL
|
||||||
|
+ f"/proxy/media/{expires}/{sig}/"
|
||||||
|
+ base64.urlsafe_b64encode(url.encode()).decode()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def resized_media_url(url: str, size: int) -> str:
|
def resized_media_url(url: str, size: int) -> str:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import base64
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
Loading…
Reference in a new issue