Skip to content

Commit

Permalink
Merge pull request #12 from abij/patch-1
Browse files Browse the repository at this point in the history
Find unique user based on lowercase email compare
  • Loading branch information
mvanholsteijn authored Jan 15, 2025
2 parents 3d049d8 + 87687cb commit 146ca33
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/wordpress_markdown_blog_loader/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,12 @@ def get_unique_user_by_name(self, name: str, email: Optional[str]) -> "User":
if len(users) == 0:
raise ValueError(f"author '{name}' not found on {self.endpoint.host}")
elif len(users) > 1:
user = next(filter(lambda u: email and u.email == email, users), None)
user = next(filter(lambda u: email and u.email.lower() == email.lower(), users), None)
if not user:
raise ValueError(
f"Multiple authors named '{name}' found, none with email {email}"
f"Multiple authors named '{name}' found, none with email {email} (possible: { {u.email for u in users} })."
)
return user
return users[0]

def posts(self, query: dict = None) -> Iterator["Post"]:
Expand Down Expand Up @@ -546,4 +547,4 @@ def get_tag_id_by_name(self, tag: str) -> str:
"invalid tag '{}' try one of\n {}".format(
tag, ",\n ".join(self.tags.keys())
)
)
)

0 comments on commit 146ca33

Please sign in to comment.