33from fastapi import Depends , HTTPException , Query , Request
44from loguru import logger
55import re
6+ import zoneinfo
67
78from lnbits .core .crud import get_user , update_payment_extra
89from lnbits .decorators import (
3031async def api_list_currencies_available ():
3132 return list (currencies .keys ())
3233
34+ @devicetimer_ext .get ("/api/v1/timezones" )
35+ async def api_list_timezones_available ():
36+ return sorted (zoneinfo .available_timezones (),key = str .lower )
3337
3438@devicetimer_ext .post ("/api/v1/device" , dependencies = [Depends (require_admin_key )])
3539async def api_lnurldevice_create (data : CreateLnurldevice , req : Request ):
@@ -38,6 +42,11 @@ async def api_lnurldevice_create(data: CreateLnurldevice, req: Request):
3842 raise HTTPException (
3943 status_code = HTTPStatus .BAD_REQUEST , detail = "Opening time format must be hh:mm"
4044 )
45+
46+ if data .timezone not in zoneinfo .available_timezones ():
47+ raise HTTPException (
48+ status_code = HTTPStatus .BAD_REQUEST , detail = "Illegal timezone"
49+ )
4150
4251 result = re .search ("^\d{2}\:\d{2}$" ,data .available_stop )
4352 if not result :
@@ -64,6 +73,11 @@ async def api_lnurldevice_update(
6473 raise HTTPException (
6574 status_code = HTTPStatus .BAD_REQUEST , detail = "Opening time format must be hh:mm"
6675 )
76+
77+ if data .timezone not in zoneinfo .available_timezones ():
78+ raise HTTPException (
79+ status_code = HTTPStatus .BAD_REQUEST , detail = "Illegal timezone"
80+ )
6781
6882 result = re .search ("^\d{2}\:\d{2}$" ,data .available_stop )
6983 if not result :
0 commit comments