Restore doorboy slack endpoint
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
2023-08-10 19:03:33 +03:00
parent 2cfccc22a0
commit f53d670189
2 changed files with 41 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ db = MongoClient(const.MONGO_URI).get_default_database()
class User:
username: str = None
display_name: str = None
slack_id: str = None
groups: List[str] = field(default_factory=list)
def __getitem__(self, item):
@@ -35,10 +36,11 @@ def get_users():
for item in ret["items"]:
username = item['metadata']['name']
display_name = item.get("spec", {}).get("customProfile", {}).get("name", None)
slack_id = item.get("status", {}).get("slackId", None)
groups = []
for group in item.get("status", {}).get("groups", []):
groups.append(f"{group['prefix']}:{group['name']}")
yield User(username, display_name, groups)
yield User(username, display_name, slack_id, groups)
users = list(get_users())
users_lookup = {u.username : u for u in users}