99from app .schemas .schemas import (
1010 CameraGroupCreate ,
1111 RecordingSettings ,
12- NotificationSettings ,
1312)
1413
1514router = APIRouter (prefix = "/api" , tags = ["api" ])
@@ -211,36 +210,7 @@ async def get_all_settings(
211210):
212211 """Get all settings for the user's organization."""
213212 return {
214- "notifications" : {
215- "motion_notifications" : Setting .get (
216- db , user .org_id , "motion_notifications" , "true"
217- )
218- == "true" ,
219- "face_notifications" : Setting .get (
220- db , user .org_id , "face_notifications" , "true"
221- )
222- == "true" ,
223- "object_notifications" : Setting .get (
224- db , user .org_id , "object_notifications" , "true"
225- )
226- == "true" ,
227- "toast_notifications" : Setting .get (
228- db , user .org_id , "toast_notifications" , "true"
229- )
230- == "true" ,
231- },
232213 "recording" : {
233- "motion_recording" : Setting .get (
234- db , user .org_id , "motion_recording" , "false"
235- )
236- == "true" ,
237- "face_recording" : Setting .get (db , user .org_id , "face_recording" , "false" )
238- == "true" ,
239- "object_recording" : Setting .get (
240- db , user .org_id , "object_recording" , "false"
241- )
242- == "true" ,
243- "post_buffer" : int (Setting .get (db , user .org_id , "post_buffer" , "5" )),
244214 "scheduled_recording" : Setting .get (
245215 db , user .org_id , "scheduled_recording" , "false"
246216 )
@@ -253,64 +223,12 @@ async def get_all_settings(
253223 }
254224
255225
256- @router .get ("/settings/notifications" )
257- async def get_notification_settings (
258- user : AuthUser = Depends (require_view ), db : Session = Depends (get_db )
259- ):
260- """Get notification settings."""
261- return {
262- "motion_notifications" : Setting .get (
263- db , user .org_id , "motion_notifications" , "true"
264- )
265- == "true" ,
266- "face_notifications" : Setting .get (db , user .org_id , "face_notifications" , "true" )
267- == "true" ,
268- "object_notifications" : Setting .get (
269- db , user .org_id , "object_notifications" , "true"
270- )
271- == "true" ,
272- "toast_notifications" : Setting .get (
273- db , user .org_id , "toast_notifications" , "true"
274- )
275- == "true" ,
276- }
277-
278-
279- @router .post ("/settings/notifications" )
280- async def update_notification_settings (
281- data : NotificationSettings ,
282- user : AuthUser = Depends (require_admin ),
283- db : Session = Depends (get_db ),
284- ):
285- """Update notification settings. Requires admin."""
286- Setting .set (
287- db , user .org_id , "motion_notifications" , str (data .motion_notifications ).lower ()
288- )
289- Setting .set (
290- db , user .org_id , "face_notifications" , str (data .face_notifications ).lower ()
291- )
292- Setting .set (
293- db , user .org_id , "object_notifications" , str (data .object_notifications ).lower ()
294- )
295- Setting .set (
296- db , user .org_id , "toast_notifications" , str (data .toast_notifications ).lower ()
297- )
298- return {"success" : True }
299-
300-
301226@router .get ("/settings/recording" )
302227async def get_recording_settings (
303228 user : AuthUser = Depends (require_view ), db : Session = Depends (get_db )
304229):
305230 """Get recording settings."""
306231 return {
307- "motion_recording" : Setting .get (db , user .org_id , "motion_recording" , "false" )
308- == "true" ,
309- "face_recording" : Setting .get (db , user .org_id , "face_recording" , "false" )
310- == "true" ,
311- "object_recording" : Setting .get (db , user .org_id , "object_recording" , "false" )
312- == "true" ,
313- "post_buffer" : int (Setting .get (db , user .org_id , "post_buffer" , "5" )),
314232 "scheduled_recording" : Setting .get (
315233 db , user .org_id , "scheduled_recording" , "false"
316234 )
@@ -329,10 +247,6 @@ async def update_recording_settings(
329247 db : Session = Depends (get_db ),
330248):
331249 """Update recording settings. Requires admin."""
332- Setting .set (db , user .org_id , "motion_recording" , str (data .motion_recording ).lower ())
333- Setting .set (db , user .org_id , "face_recording" , str (data .face_recording ).lower ())
334- Setting .set (db , user .org_id , "object_recording" , str (data .object_recording ).lower ())
335- Setting .set (db , user .org_id , "post_buffer" , str (data .post_buffer ))
336250 Setting .set (
337251 db , user .org_id , "scheduled_recording" , str (data .scheduled_recording ).lower ()
338252 )
0 commit comments