Skip to content

Commit

Permalink
fix: use OCS api to get app enabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Jul 8, 2024
1 parent 0af0496 commit 4f320e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ex_app/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# os.environ["APP_SECRET"] = "12345"
# os.environ["APP_PORT"] = "23000"

DEFAULT_USER_NAME = "[email protected]"
USERS_STORAGE_PATH = Path(persistent_storage()).joinpath("windmill_users_config.json")
USERS_STORAGE = {}
print(str(USERS_STORAGE_PATH), flush=True)
Expand Down Expand Up @@ -143,10 +144,8 @@ async def init_callback(b_tasks: BackgroundTasks, nc: typing.Annotated[Nextcloud
return responses.JSONResponse(content={})


APP_ENABLED = False
@APP.put("/enabled")
def enabled_callback(enabled: bool, nc: typing.Annotated[NextcloudApp, Depends(nc_app)]):
APP_ENABLED = enabled
return responses.JSONResponse(content={"error": enabled_handler(enabled, nc)})


Expand Down Expand Up @@ -224,7 +223,7 @@ def initialize_windmill() -> None:
)
if r.status_code >= 400:
raise RuntimeError(f"initialize_windmill: can not change default credentials password, {r.text}")
add_user_to_storage("[email protected]", new_default_password, default_token)
add_user_to_storage(DEFAULT_USER_NAME, new_default_password, default_token)
r = httpx.post(
url="http://127.0.0.1:8000/api/workspaces/create",
json={"id": "nextcloud", "name": "nextcloud"},
Expand All @@ -248,10 +247,12 @@ def generate_random_string(length=10):

async def sync_timer():
while True:
if APP_ENABLED:
nc = NextcloudApp()
enabled_flag = nc.ocs("GET", "/ocs/v1.php/apps/app_api/ex-app/state")
if enabled_flag:
print("Running workflow sync")
workspace = 'nextcloud'
token = 'YOUR_TOKEN_HERE'
token = USERS_STORAGE[DEFAULT_USER_NAME]['token']
flow_paths = await get_flow_paths(workspace, token)
expected_listeners = await get_expected_listeners(workspace, token, flow_paths)
print(json.dumps(expected_listeners, indent=4), flush=True)
Expand Down

0 comments on commit 4f320e7

Please sign in to comment.