fix: lookup user object operator to pass to CrawlConfig.add_new_crawl (#1254)
fixes #1253 Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
This commit is contained in:
parent
fa86555eed
commit
748c86700d
@ -228,6 +228,7 @@ class BtrixOperator(K8sAPI):
|
||||
super().__init__()
|
||||
|
||||
self.crawl_config_ops = crawl_config_ops
|
||||
self.user_ops = crawl_config_ops.user_manager
|
||||
self.crawl_ops = crawl_ops
|
||||
self.org_ops = org_ops
|
||||
self.coll_ops = coll_ops
|
||||
@ -1261,8 +1262,9 @@ class BtrixOperator(K8sAPI):
|
||||
return {"attachments": []}
|
||||
|
||||
# db create
|
||||
user = await self.user_ops.get_user_by_id(uuid.UUID(userid))
|
||||
await self.crawl_config_ops.add_new_crawl(
|
||||
crawl_id, crawlconfig, uuid.UUID(userid), manual=False
|
||||
crawl_id, crawlconfig, user, manual=False
|
||||
)
|
||||
print("Scheduled Crawl Created: " + crawl_id)
|
||||
|
||||
|
||||
@ -121,6 +121,10 @@ class UserManager(BaseUserManager[UserCreate, UserDB]):
|
||||
)
|
||||
return await cursor.to_list(length=1000)
|
||||
|
||||
async def get_user_by_id(self, user_id: uuid.UUID):
|
||||
"""return user from user_id"""
|
||||
return await self.user_db.get(user_id)
|
||||
|
||||
async def get_superuser(self):
|
||||
"""return current superuser, if any"""
|
||||
return await self.user_db.collection.find_one({"is_superuser": True})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user