fix: use canvas email instead of gitea user (#21)

This commit is contained in:
King 2023-05-23 01:17:15 +08:00 committed by GitHub
parent ac54d14aee
commit fb2b866667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,10 +68,9 @@ class Gitea:
@lru_cache() @lru_cache()
def _get_username_by_canvas_student(self, student: User) -> str: def _get_username_by_canvas_student(self, student: User) -> str:
res = self.user_api.user_search(q=student.login_id, limit=1) if student.email == None or student.email.find("@") == -1:
if len(res["data"]) == 0:
raise Exception(f"{student} not found in Gitea") raise Exception(f"{student} not found in Gitea")
return res["data"][0]["username"] return student.email.split("@")[0]
def add_canvas_students_to_teams( def add_canvas_students_to_teams(
self, students: PaginatedList, team_names: List[str] self, students: PaginatedList, team_names: List[str]