Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlueskyをAccountTypeに追加 #745

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/swagger/traPortfolio.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ components:
- 9
- 10
- 11
- 12
x-enum-varnames:
- homepage
- blog
Expand All @@ -871,6 +872,7 @@ components:
- soundcloud
- hackthebox
- ctftime
- bluesky
x-enum-descriptions:
- ホームページ (IDはリンクのURLそのまま)
- ブログ (IDはリンクのURLそのまま)
Expand All @@ -884,6 +886,7 @@ components:
- SoundCloud
- HackTheBox
- CTFtime
- Bluesky
x-go-type: uint8
Project:
title: Project
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/handler/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handler

import (
"encoding/json"
"fmt"
"net/http"
"strings"
"testing"
Expand Down Expand Up @@ -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)),
Comment on lines -407 to +408
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ハードコードしてたのか

Comment on lines -407 to +408
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ハードコードしてたのか

},
"409 conflict already exists": {
http.StatusConflict,
Expand Down
2 changes: 2 additions & 0 deletions internal/domain/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
SOUNDCLOUD
HACKTHEBOX
CTFTIME
BLUESKY
AccountLimit
)

Expand Down Expand Up @@ -139,6 +140,7 @@
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]+)+$`),

Check warning on line 143 in internal/domain/user.go

View check run for this annotation

Codecov / codecov/patch

internal/domain/user.go#L143

Added line #L143 was not covered by tests
}

if r, ok := urlRegexp[accountType]; ok {
Expand Down
5 changes: 5 additions & 0 deletions internal/pkgs/random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Comment on lines +144 to +146
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*.example.comを使うのが無難そうではある

},
}
if accountType == domain.HOMEPAGE || accountType == domain.BLOG {
return fmt.Sprintf("https://%s", AlphaNumeric())
Expand Down
Loading