Skip to content

Commit

Permalink
Use only ULID for App ID (#1431)
Browse files Browse the repository at this point in the history
Slugifying the name and including ULID was perhaps a mistake I believe
because with the slugified names, the IDs become too long sometimes and
the length is not always consistent, so only using ULID from now onwards
  • Loading branch information
beastoin authored Dec 1, 2024
2 parents ef8b800 + e19670e commit 4d504d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions backend/routers/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import requests
from ulid import ULID
from fastapi import APIRouter, Depends, Form, UploadFile, File, HTTPException, Header
from slugify import slugify

from database.apps import change_app_approval_status, get_unapproved_public_apps_db, \
add_app_to_db, update_app_in_db, delete_app_from_db, update_app_visibility_in_db
Expand Down Expand Up @@ -43,8 +42,7 @@ def submit_app(app_data: str = Form(...), file: UploadFile = File(...), uid=Depe
data['deleted'] = False
data['status'] = 'under-review'
data['name'] = data['name'].strip()
new_app_id = slugify(data['name']) + '-' + str(ULID())
data['id'] = new_app_id
data['id'] = str(ULID())
if external_integration := data.get('external_integration'):
if external_integration.get('triggers_on') is None:
raise HTTPException(status_code=422, detail='Triggers on is required')
Expand Down
4 changes: 1 addition & 3 deletions backend/routers/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import requests
from fastapi import APIRouter, HTTPException, Depends, UploadFile
from fastapi.params import File, Form
from slugify import slugify
from ulid import ULID

from database.apps import add_app_to_db
Expand Down Expand Up @@ -116,8 +115,7 @@ def add_plugin(plugin_data: str = Form(...), file: UploadFile = File(...), uid=D
data = json.loads(plugin_data)
data['approved'] = False
data['name'] = data['name'].strip()
new_app_id = slugify(data['name']) + '-' + str(ULID())
data['id'] = new_app_id
data['id'] = str(ULID())
os.makedirs(f'_temp/plugins', exist_ok=True)
file_path = f"_temp/plugins/{file.filename}"
with open(file_path, 'wb') as f:
Expand Down

0 comments on commit 4d504d7

Please sign in to comment.