generated from nextcloud/app-skeleton-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use OCS api to get app enabled state
- Loading branch information
1 parent
0af0496
commit 4f320e7
Showing
1 changed file
with
6 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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)}) | ||
|
||
|
||
|
@@ -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"}, | ||
|
@@ -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) | ||
|