mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-06-06 19:25:24 +00:00
feat: support only trigger webhook
This commit is contained in:
parent
d3d1157a4e
commit
7212a2f65b
@ -12,8 +12,10 @@ from tqdm import tqdm
|
||||
from magika import Magika
|
||||
|
||||
app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})
|
||||
|
||||
lib_app = typer.Typer()
|
||||
plugin_app = typer.Typer()
|
||||
|
||||
app.add_typer(plugin_app, name="plugin")
|
||||
app.add_typer(lib_app, name="lib")
|
||||
|
||||
|
@ -146,8 +146,11 @@ def add_plugin_to_library(library_id: int, plugin_id: int, db: Session):
|
||||
db.refresh(library_plugin)
|
||||
|
||||
|
||||
def get_entity_by_id(entity_id: int, db: Session) -> Entity | None:
|
||||
return db.query(EntityModel).filter(EntityModel.id == entity_id).first()
|
||||
def find_entity_by_id(entity_id: int, db: Session) -> Entity | None:
|
||||
db_entity = db.query(EntityModel).filter(EntityModel.id == entity_id).first()
|
||||
if db_entity is None:
|
||||
return None
|
||||
return Entity(**db_entity.__dict__)
|
||||
|
||||
|
||||
def update_entity(
|
||||
|
@ -270,20 +270,22 @@ def get_entity_by_id_in_library(
|
||||
@app.put("/entities/{entity_id}", response_model=Entity, tags=["entity"])
|
||||
async def update_entity(
|
||||
entity_id: int,
|
||||
updated_entity: UpdateEntityParam,
|
||||
request: Request,
|
||||
updated_entity: UpdateEntityParam = None,
|
||||
db: Session = Depends(get_db),
|
||||
trigger_webhooks_flag: bool = False,
|
||||
plugins: Annotated[List[int] | None, Query()] = None,
|
||||
):
|
||||
entity = crud.get_entity_by_id(entity_id, db)
|
||||
entity = crud.find_entity_by_id(entity_id, db)
|
||||
if entity is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Entity not found",
|
||||
)
|
||||
|
||||
entity = crud.update_entity(entity_id, updated_entity, db)
|
||||
if updated_entity:
|
||||
entity = crud.update_entity(entity_id, updated_entity, db)
|
||||
|
||||
if trigger_webhooks_flag:
|
||||
library = crud.get_library_by_id(entity.library_id, db)
|
||||
if library is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user