Skip to content

Commit c627bfc

Browse files
committed
feat: add linkedin account to profiles
1 parent 6f8b8d8 commit c627bfc

17 files changed

Lines changed: 309 additions & 23 deletions

backend/.sqlx/query-d8259958a9c38fd2c6b0ad35793c51a9cb3d50d557d90c55b95195b1dbbd09b2.json renamed to backend/.sqlx/query-18a941abe96017e4e2821c4fb19b6a0507fc3079724bec3eddb594dffc35b7bc.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-ba666476f8eec313de6b35bd1066f501cd3cc1ad7eb72b0ed7edc853035b14c9.json renamed to backend/.sqlx/query-256e9ed74cc3b0d545a12a411d15ba4d930f3708ddcdefba47232de3c9f3299c.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-a582b89bc07b2332c1b196a4ade6ec7583e1b104a6ba83184a7841b2f198520d.json renamed to backend/.sqlx/query-c32c56360547eeb07fcdf55eeb19707525105d413d39a212c5fc9303cf93c5b8.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-1acdd97ec41e3fa9cc9319bf680c5952a127f82436d0ddc0b71f7afb3b530462.json renamed to backend/.sqlx/query-ca1107c288ed29a6f6b515ba55bf0ab01b72d06f4546d23a457bce446c816364.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-d70adcade77f15e4b624296cbfe36c7710eac0b12924c32843d201def30961e6.json renamed to backend/.sqlx/query-d1cd034daa1d27503453e39e1798993b0705c357513333d11f85478f93d2d068.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-e179be7ac3fb9f92e828aaf23d61271cef2248c19fec642fb39d9e69af81bc74.json

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/.sqlx/query-7a8afc2b7d71942781088cdd0a2b2bc19ea56fc80bcaaf030a058c85414ea2a7.json renamed to backend/.sqlx/query-e3ae1657b22e7882866d43271cbcc5c15807573a8fa73c11fedb53b00c5c4509.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE profiles ADD COLUMN IF NOT EXISTS linkedin_account TEXT;
2+
CREATE UNIQUE INDEX IF NOT EXISTS unique_linkedin_account_lower ON profiles (LOWER(linkedin_account));

backend/src/application/commands/create_profile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub async fn create_profile(
3636
avatar_url: profile.avatar_url,
3737
github_login: profile.github_login,
3838
twitter_handle: profile.twitter_handle,
39+
linkedin_account: profile.linkedin_account,
3940
created_at: profile.created_at,
4041
updated_at: profile.updated_at,
4142
})

backend/src/application/commands/update_profile.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ pub async fn update_profile(
6868
profile.twitter_handle = Some(trimmed.to_string());
6969
}
7070
}
71+
if let Some(ref account) = request.linkedin_account {
72+
let trimmed = account.trim();
73+
74+
// Allow empty accounts (set to None)
75+
if trimmed.is_empty() {
76+
profile.linkedin_account = None;
77+
} else {
78+
// Validate format for non-empty LinkedIn accounts
79+
let valid_format = regex::Regex::new(r"^[a-zA-Z0-9-]{3,100}$").unwrap();
80+
if !valid_format.is_match(trimmed) {
81+
return Err("Invalid LinkedIn account format".to_string());
82+
}
83+
84+
let normalized = trimmed.to_lowercase();
85+
if let Some(conflicting_profile) = profile_repository
86+
.find_by_linkedin_account(normalized.as_str())
87+
.await
88+
.map_err(|e| e.to_string())?
89+
{
90+
if conflicting_profile.address != wallet_address {
91+
return Err("LinkedIn account already taken".to_string());
92+
}
93+
}
94+
95+
profile.linkedin_account = Some(trimmed.to_string());
96+
}
97+
}
7198
profile_repository
7299
.update(&profile)
73100
.await
@@ -80,6 +107,7 @@ pub async fn update_profile(
80107
avatar_url: profile.avatar_url,
81108
github_login: profile.github_login,
82109
twitter_handle: profile.twitter_handle,
110+
linkedin_account: profile.linkedin_account,
83111
created_at: profile.created_at,
84112
updated_at: profile.updated_at,
85113
})

0 commit comments

Comments
 (0)