2022-01-10 15:20:47 +00:00
|
|
|
"""Nextcloud logic."""
|
|
|
|
|
|
|
|
import owncloud
|
|
|
|
|
|
|
|
|
|
|
|
async def init_resource_map(app):
|
|
|
|
"""Initialise resource map listing."""
|
|
|
|
from members_lumbung_space.config import (
|
|
|
|
NEXTCLOUD_API_BASE_URL,
|
2022-01-10 16:03:45 +00:00
|
|
|
NEXTCLOUD_APP_SECRET,
|
2022-01-10 15:20:47 +00:00
|
|
|
NEXTCLOUD_USER,
|
|
|
|
)
|
|
|
|
|
|
|
|
nextcloud = owncloud.Client(f"https://{NEXTCLOUD_API_BASE_URL}")
|
2022-01-10 16:00:56 +00:00
|
|
|
nextcloud.login(NEXTCLOUD_USER, NEXTCLOUD_APP_SECRET)
|
2022-01-10 15:20:47 +00:00
|
|
|
|
|
|
|
await app.state.redis.set(
|
|
|
|
"resource_map",
|
|
|
|
[f.get_name() for f in nextcloud.list("/", depth="infinity")],
|
|
|
|
)
|