Skip to content

Commit

Permalink
fix: kanka.entity.permissions is crash-looping
Browse files Browse the repository at this point in the history
  • Loading branch information
ishtanzar committed Mar 5, 2024
1 parent cc064f8 commit da90414
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wm-worker/src/services/kanka.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ async def notify(self, entities: list = None, entity: dict = None):
elif entity:
author = await self.api.kanka.users.get(entity["updated_by"])

if api_user := (await self.api.users.findOne({'kanka.id': entity["updated_by"]}, {'value': None}))['value']:
if api_user := (await self.api.users.find_one({'kanka.id': entity["updated_by"]}, {'value': None}))['value']:
if discord_username := api_user.get("discord", {}).get("username"):
author = f'{discord_username} (kanka : {author})'

Expand Down Expand Up @@ -314,7 +314,7 @@ async def ownership(self, last_sync):
foundry_owners = [u for u in foundry_actor['permission'] if u != 'default' and foundry_actor['permission'][u] == 3]
kanka_owners_ids = kanka_acls['users'] if 'users' in kanka_acls else []
self.logger.debug(f'Searching for kanka users {kanka_owners_ids}')
users_from_kanka_owners = await self.api.users.search(json={"kanka.id": { "$in": kanka_owners_ids }})
users_from_kanka_owners = await self.api.users.find({"kanka.id": { "$in": kanka_owners_ids }})

for owner in foundry_owners:
found = False
Expand All @@ -326,7 +326,7 @@ async def ownership(self, last_sync):

if not found:
self.logger.debug(f'Searching for kanka user {owner}')
[new_user] = await self.api.users.search({"foundry._id": owner})
new_user = await self.api.users.find_one({"foundry._id": owner})
for action in [Permission.READ, Permission.EDIT, Permission.DELETE, Permission.PERMISSIONS]:
self.logger.info(f'Granting {action} for {kanka_character["name"]}[{kanka_character["id"]}] to {new_user["kanka"]["name"]}[{new_user["kanka"]["id"]}]')
await self.api.kanka.entity(kanka_character['id']).permissions.post(json={
Expand Down

0 comments on commit da90414

Please sign in to comment.