From f0de73940c86f74e8820fead238adc8901a57584 Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:51:38 +0530 Subject: [PATCH] increase/decrease install count only if not private --- backend/routers/apps.py | 6 ++++-- backend/routers/plugins.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/routers/apps.py b/backend/routers/apps.py index 9f146962c..c9c92412f 100644 --- a/backend/routers/apps.py +++ b/backend/routers/apps.py @@ -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'} @@ -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'} diff --git a/backend/routers/plugins.py b/backend/routers/plugins.py index 134066805..d2e05cf01 100644 --- a/backend/routers/plugins.py +++ b/backend/routers/plugins.py @@ -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'} @@ -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'}