Skip to content

Commit

Permalink
increase/decrease install count only if not private
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmohsin7 committed Nov 14, 2024
1 parent 76562e2 commit f0de739
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions backend/routers/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def enable_app(app_id: str, uid: str = Depends(auth.get_current_user_uid)):
print('enable_app_endpoint', res.status_code, res.content)
if res.status_code != 200 or not res.json().get('is_setup_completed', False):
raise HTTPException(status_code=400, detail='App setup is not completed')
increase_plugin_installs_count(app_id)
if app.private is None or app.private is False:
increase_plugin_installs_count(app_id)
enable_plugin(uid, app_id)
return {'status': 'ok'}

Expand All @@ -206,7 +207,8 @@ def disable_app(app_id: str, uid: str = Depends(auth.get_current_user_uid)):
if app.private and app.uid != uid:
raise HTTPException(status_code=403, detail='You are not authorized to perform this action')
disable_plugin(uid, app_id)
decrease_plugin_installs_count(app_id)
if app.private is None or app.private is False:
decrease_plugin_installs_count(app_id)
return {'status': 'ok'}


Expand Down
6 changes: 4 additions & 2 deletions backend/routers/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def enable_plugin_endpoint(plugin_id: str, uid: str = Depends(auth.get_current_u
print('enable_plugin_endpoint', res.status_code, res.content)
if res.status_code != 200 or not res.json().get('is_setup_completed', False):
raise HTTPException(status_code=400, detail='Plugin setup is not completed')
increase_plugin_installs_count(plugin_id)
if plugin.private is not None and plugin.private is False:
increase_plugin_installs_count(plugin_id)
enable_plugin(uid, plugin_id)
return {'status': 'ok'}

Expand All @@ -48,7 +49,8 @@ def disable_plugin_endpoint(plugin_id: str, uid: str = Depends(auth.get_current_
if not plugin:
raise HTTPException(status_code=404, detail='App not found')
disable_plugin(uid, plugin_id)
decrease_plugin_installs_count(plugin_id)
if plugin.private is not None and plugin.private is False:
decrease_plugin_installs_count(plugin_id)
return {'status': 'ok'}


Expand Down

0 comments on commit f0de739

Please sign in to comment.