From ca20609fb65dac37c883ef4e0dd4760b703fe5ae Mon Sep 17 00:00:00 2001 From: F-G Fernandez <26927750+frgfm@users.noreply.github.com> Date: Thu, 21 Dec 2023 18:22:37 +0100 Subject: [PATCH] fix: Fixes Slack notification formatting (#49) * fix: Fixes Slack notification formatting * feat: Adds safeguard on name formatting --- src/app/api/api_v1/endpoints/users.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/api/api_v1/endpoints/users.py b/src/app/api/api_v1/endpoints/users.py index 89bf242..b7b43e4 100644 --- a/src/app/api/api_v1/endpoints/users.py +++ b/src/app/api/api_v1/endpoints/users.py @@ -51,11 +51,16 @@ async def _create_user(payload: UserCreate, users: UserCRUD, requester: Union[Us slack_client.notify( "*New user* :partying_face:", [ - ("Name", gh_user["name"]), - ("Email", gh_user["email"]), - ("Company", f"`{gh_user['company']}`"), + ("Name", gh_user["name"] or "N/A"), + ("Email", gh_user["email"] or "N/A"), + ("Company", f"`{gh_user['company']}`" if gh_user["company"] else "N/A"), ("GitHub", f"<{gh_user['html_url']}|{gh_user['login']}> ({gh_user['followers']} followers)"), - ("Twitter", f""), + ( + "Twitter", + f"" + if gh_user["twitter_username"] + else "N/A", + ), ], ) return user