From ee4fc997ddf0268c7865ea75ac08aedd756f5267 Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Sun, 12 Jan 2025 22:07:44 +0900 Subject: [PATCH 1/4] feat: add bluesky as a new AccountType --- docs/swagger/traPortfolio.v1.yaml | 3 +++ internal/domain/user.go | 2 ++ internal/pkgs/random/random.go | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/docs/swagger/traPortfolio.v1.yaml b/docs/swagger/traPortfolio.v1.yaml index d8457692..bbbf0de5 100644 --- a/docs/swagger/traPortfolio.v1.yaml +++ b/docs/swagger/traPortfolio.v1.yaml @@ -858,6 +858,7 @@ components: - 9 - 10 - 11 + - 12 x-enum-varnames: - homepage - blog @@ -871,6 +872,7 @@ components: - soundcloud - hackthebox - ctftime + - bluesky x-enum-descriptions: - ホームページ (IDはリンクのURLそのまま) - ブログ (IDはリンクのURLそのまま) @@ -884,6 +886,7 @@ components: - SoundCloud - HackTheBox - CTFtime + - Bluesky x-go-type: uint8 Project: title: Project diff --git a/internal/domain/user.go b/internal/domain/user.go index cdb95968..f34e562e 100644 --- a/internal/domain/user.go +++ b/internal/domain/user.go @@ -96,6 +96,7 @@ const ( SOUNDCLOUD HACKTHEBOX CTFTIME + BLUESKY AccountLimit ) @@ -139,6 +140,7 @@ func IsValidAccountURL(accountType AccountType, URL string) bool { SOUNDCLOUD: regexp.MustCompile(`^https://soundcloud\.com/[a-z0-9-_]+$`), HACKTHEBOX: regexp.MustCompile(`^https://app\.hackthebox\.com/users/[a-zA-Z0-9]+$`), CTFTIME: regexp.MustCompile(`^https://ctftime\.org/user/[0-9]+$`), + BLUESKY: regexp.MustCompile(`^https://bsky.app/profile/[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z0-9.]+$`), } if r, ok := urlRegexp[accountType]; ok { diff --git a/internal/pkgs/random/random.go b/internal/pkgs/random/random.go index fcbb77f4..e70da966 100644 --- a/internal/pkgs/random/random.go +++ b/internal/pkgs/random/random.go @@ -140,6 +140,11 @@ func AccountURLString(accountType domain.AccountType) string { "https://ctftime.org/user/4285429253", "https://ctftime.org/user/8295210365", }, + domain.BLUESKY: { + "https://bsky.app/profile/bluesky.bsky.social", + "https://bsky.app/profile/tpf.bsky.social", + "https://bsky.app/profile/portfolio.trap.jp", + }, } if accountType == domain.HOMEPAGE || accountType == domain.BLOG { return fmt.Sprintf("https://%s", AlphaNumeric()) From efe79d7cac183dcd4844e4220245339782a70001 Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Sun, 12 Jan 2025 22:16:25 +0900 Subject: [PATCH 2/4] fix: wrong regexp of bluesky profile link --- internal/domain/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/domain/user.go b/internal/domain/user.go index f34e562e..370c0ad0 100644 --- a/internal/domain/user.go +++ b/internal/domain/user.go @@ -140,7 +140,7 @@ func IsValidAccountURL(accountType AccountType, URL string) bool { SOUNDCLOUD: regexp.MustCompile(`^https://soundcloud\.com/[a-z0-9-_]+$`), HACKTHEBOX: regexp.MustCompile(`^https://app\.hackthebox\.com/users/[a-zA-Z0-9]+$`), CTFTIME: regexp.MustCompile(`^https://ctftime\.org/user/[0-9]+$`), - BLUESKY: regexp.MustCompile(`^https://bsky.app/profile/[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z0-9.]+$`), + BLUESKY: regexp.MustCompile(`^https://bsky\.app/profile/[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](\.[a-zA-Z0-9]+)+$`), } if r, ok := urlRegexp[accountType]; ok { From 6e3f87edc8476b56450c7e3434f173eba7079d88 Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Sun, 12 Jan 2025 22:26:29 +0900 Subject: [PATCH 3/4] fix: hard-coded account limit error message --- integration_tests/handler/user_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration_tests/handler/user_test.go b/integration_tests/handler/user_test.go index 040c0520..c726e44c 100644 --- a/integration_tests/handler/user_test.go +++ b/integration_tests/handler/user_test.go @@ -2,6 +2,7 @@ package handler import ( "encoding/json" + "fmt" "net/http" "strings" "testing" @@ -404,7 +405,7 @@ func TestAddUserAccount(t *testing.T) { Type: schema.AccountType(domain.AccountLimit), Url: accountURL, }, - httpError(t, "Bad Request: validate error: type: must be no greater than 11."), + httpError(t, fmt.Sprintf("Bad Request: validate error: type: must be no greater than %d.", domain.AccountLimit-1)), }, "409 conflict already exists": { http.StatusConflict, From b737476eaa9cf7b9155a973f9a45a260b58d301a Mon Sep 17 00:00:00 2001 From: Tennessine699 Date: Fri, 7 Feb 2025 21:30:24 +0900 Subject: [PATCH 4/4] =?UTF-8?q?update:=20=E7=84=A1=E9=9B=A3=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkgs/random/random.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkgs/random/random.go b/internal/pkgs/random/random.go index e70da966..b3b9f1b4 100644 --- a/internal/pkgs/random/random.go +++ b/internal/pkgs/random/random.go @@ -143,7 +143,7 @@ func AccountURLString(accountType domain.AccountType) string { domain.BLUESKY: { "https://bsky.app/profile/bluesky.bsky.social", "https://bsky.app/profile/tpf.bsky.social", - "https://bsky.app/profile/portfolio.trap.jp", + "https://bsky.app/profile/tpf.example.com", }, } if accountType == domain.HOMEPAGE || accountType == domain.BLOG {