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

ユーザーアカウントAPIのprPermittedに当たる要素を全て消した #739

Open
wants to merge 2 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
1 change: 0 additions & 1 deletion .tbls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ comments:
name: アカウント名
url: アカウントのURL
user_id: ユーザーUUID
check: 公開可能かどうか
- table: projects
tableComment: プロジェクトテーブル
columnComments:
Expand Down
12 changes: 0 additions & 12 deletions docs/swagger/traPortfolio.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,13 @@ components:
description: 外部アカウントの表示名
type:
$ref: "#/components/schemas/AccountType"
prPermitted:
$ref: "#/components/schemas/PrPermitted"
url:
type: string
description: アカウントurl
required:
- id
- displayName
- type
- prPermitted
- url
AccountType:
type: integer
Expand Down Expand Up @@ -1207,10 +1204,6 @@ components:
required:
- link
- description
PrPermitted:
title: PrPermitted
type: boolean
description: 広報での利用が許可されているかどうか
Duration:
title: Duration
type: object
Expand Down Expand Up @@ -1306,8 +1299,6 @@ components:
properties:
type:
$ref: "#/components/schemas/AccountType"
prPermitted:
$ref: "#/components/schemas/PrPermitted"
url:
type: string
description: アカウントurl
Expand All @@ -1317,7 +1308,6 @@ components:
description: 外部アカウントの表示名
required:
- type
- prPermitted
- url
- displayName
EditUserAccountRequest:
Expand All @@ -1327,8 +1317,6 @@ components:
properties:
type:
$ref: "#/components/schemas/AccountType"
prPermitted:
$ref: "#/components/schemas/PrPermitted"
url:
type: string
description: アカウントurl
Expand Down
19 changes: 0 additions & 19 deletions integration_tests/handler/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ func TestAddUserAccount(t *testing.T) {
displayName = random.AlphaNumeric()
justCountDisplayName = strings.Repeat("亜", 256)
tooLongDisplayName = strings.Repeat("亜", 257)
prPermitted = schema.PrPermitted(random.Bool())
testUserID = mockdata.UserID1()
accountType = schema.AccountType(mockdata.AccountTypesMockUserDoesntHave(testUserID)[0])
accountURL = random.AccountURLString(domain.AccountType(accountType))
Expand All @@ -349,14 +348,12 @@ func TestAddUserAccount(t *testing.T) {
testUserID,
schema.AddAccountRequest{
DisplayName: displayName,
PrPermitted: prPermitted,
Type: accountType,
Url: accountURL,
},
schema.Account{
Id: uuid.Nil,
DisplayName: displayName,
PrPermitted: prPermitted,
Type: accountType,
Url: accountURL,
},
Expand All @@ -366,14 +363,12 @@ func TestAddUserAccount(t *testing.T) {
testUserID2,
schema.AddAccountRequest{
DisplayName: justCountDisplayName,
PrPermitted: prPermitted,
Type: accountType2,
Url: accountURL2,
},
schema.Account{
Id: uuid.Nil,
DisplayName: justCountDisplayName,
PrPermitted: prPermitted,
Type: accountType2,
Url: accountURL2,
},
Expand All @@ -389,7 +384,6 @@ func TestAddUserAccount(t *testing.T) {
testUserID,
schema.AddAccountRequest{
DisplayName: displayName,
PrPermitted: prPermitted,
Type: accountType,
Url: "invalid url",
},
Expand All @@ -400,7 +394,6 @@ func TestAddUserAccount(t *testing.T) {
testUserID,
schema.AddAccountRequest{
DisplayName: displayName,
PrPermitted: prPermitted,
Type: schema.AccountType(domain.AccountLimit),
Url: accountURL,
},
Expand All @@ -411,7 +404,6 @@ func TestAddUserAccount(t *testing.T) {
testUserID,
schema.AddAccountRequest{
DisplayName: displayName,
PrPermitted: prPermitted,
Type: conflictType,
Url: random.AccountURLString(domain.AccountType(conflictType)),
},
Expand All @@ -422,7 +414,6 @@ func TestAddUserAccount(t *testing.T) {
testUserID,
schema.AddAccountRequest{
DisplayName: tooLongDisplayName,
PrPermitted: prPermitted,
Type: accountType,
Url: accountURL,
},
Expand Down Expand Up @@ -450,7 +441,6 @@ func TestAddUserAccount(t *testing.T) {
func TestEditUserAccount(t *testing.T) {
var (
displayName = random.AlphaNumeric()
prPermitted = schema.PrPermitted(random.Bool())
testAccount = mockdata.UserID1()
accountType = schema.AccountType(mockdata.AccountTypesMockUserHas(testAccount)[0])
accountURL = random.AccountURLString(domain.AccountType(accountType))
Expand All @@ -474,7 +464,6 @@ func TestEditUserAccount(t *testing.T) {
mockdata.AccountID1(),
schema.EditUserAccountRequest{
DisplayName: &displayName,
PrPermitted: &prPermitted,
Type: &accountType,
Url: &accountURL,
},
Expand Down Expand Up @@ -551,7 +540,6 @@ func TestEditUserAccount(t *testing.T) {
mockdata.AccountID1(),
schema.EditUserAccountRequest{
DisplayName: &displayName,
PrPermitted: &prPermitted,
Type: &accountType,
Url: &accountURL,
},
Expand All @@ -570,13 +558,11 @@ func TestEditUserAccount(t *testing.T) {
// Insert & Assert
account = schema.Account{
DisplayName: random.AlphaNumeric(),
PrPermitted: schema.PrPermitted(random.Bool()),
Type: schema.AccountType(initialAccountType),
Url: random.AccountURLString(initialAccountType),
}
res := doRequest(t, e, http.MethodPost, e.URL(api.User.AddUserAccount, tt.userID), schema.AddAccountRequest{
DisplayName: account.DisplayName,
PrPermitted: account.PrPermitted,
Type: account.Type,
Url: account.Url,
})
Expand All @@ -595,9 +581,6 @@ func TestEditUserAccount(t *testing.T) {
if tt.reqBody.DisplayName != nil {
account.DisplayName = *tt.reqBody.DisplayName
}
if tt.reqBody.PrPermitted != nil {
account.PrPermitted = *tt.reqBody.PrPermitted
}
if tt.reqBody.Type != nil {
account.Type = *tt.reqBody.Type
}
Expand Down Expand Up @@ -660,14 +643,12 @@ func TestDeleteUserAccount(t *testing.T) {
accountType := mockdata.AccountTypesMockUserDoesntHave(tt.userID)[0]
reqBody := schema.AddAccountRequest{
DisplayName: random.AlphaNumeric(),
PrPermitted: schema.PrPermitted(random.Bool()),
Type: accountType,
Url: random.AccountURLString(domain.AccountType(accountType)),
}
res := doRequest(t, e, http.MethodPost, e.URL(api.User.AddUserAccount, tt.userID), &reqBody)
assertResponse(t, http.StatusCreated, schema.Account{
DisplayName: reqBody.DisplayName,
PrPermitted: reqBody.PrPermitted,
Type: reqBody.Type,
Url: reqBody.Url,
}, res, optSyncID, optRetrieveID(&tt.accountID))
Expand Down
1 change: 0 additions & 1 deletion internal/domain/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type Account struct {
ID uuid.UUID
DisplayName string
Type AccountType
PrPermitted bool
URL string
}

Expand Down
14 changes: 1 addition & 13 deletions internal/handler/schema/schema_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions internal/handler/schema/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (p GetUsersParams) Validate() error {
func (r AddAccountRequest) Validate() error {
return vd.ValidateStruct(&r,
vd.Field(&r.DisplayName, vd.Required, vdRuleDisplayNameLength),
vd.Field(&r.PrPermitted),
vd.Field(&r.Type, vdRuleAccountTypeMax),
vd.Field(&r.Url, vd.Required, is.URL),
)
Expand Down Expand Up @@ -78,7 +77,6 @@ func (r CreateProjectRequest) Validate() error {
func (r EditUserAccountRequest) Validate() error {
return vd.ValidateStruct(&r,
vd.Field(&r.DisplayName, vd.NilOrNotEmpty, vdRuleDisplayNameLength),
vd.Field(&r.PrPermitted),
vd.Field(&r.Type, vdRuleAccountTypeMax),
vd.Field(&r.Url, vd.NilOrNotEmpty, is.URL),
)
Expand Down
15 changes: 6 additions & 9 deletions internal/handler/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (h *UserHandler) GetUser(c echo.Context) error {

accounts := make([]schema.Account, len(user.Accounts))
for i, v := range user.Accounts {
accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted)
accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL)
}

return c.JSON(http.StatusOK, newUserDetail(
Expand Down Expand Up @@ -123,7 +123,7 @@ func (h *UserHandler) GetUserAccounts(c echo.Context) error {

res := make([]schema.Account, len(accounts))
for i, v := range accounts {
res[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted)
res[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL)
}

return c.JSON(http.StatusOK, res)
Expand All @@ -147,7 +147,7 @@ func (h *UserHandler) GetUserAccount(c echo.Context) error {
return err
}

return c.JSON(http.StatusOK, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL, account.PrPermitted))
return c.JSON(http.StatusOK, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL))
}

// AddUserAccount POST /users/:userID/accounts
Expand All @@ -166,15 +166,14 @@ func (h *UserHandler) AddUserAccount(c echo.Context) error {
args := repository.CreateAccountArgs{
DisplayName: req.DisplayName,
Type: domain.AccountType(req.Type),
PrPermitted: bool(req.PrPermitted),
URL: req.Url,
}
account, err := h.user.CreateAccount(ctx, userID, &args)
if err != nil {
return err
}

return c.JSON(http.StatusCreated, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL, account.PrPermitted))
return c.JSON(http.StatusCreated, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL))
}

// EditUserAccount PATCH /users/:userID/accounts/:accountID
Expand All @@ -200,7 +199,6 @@ func (h *UserHandler) EditUserAccount(c echo.Context) error {
DisplayName: optional.FromPtr(req.DisplayName),
Type: optional.FromPtr((*domain.AccountType)(req.Type)),
URL: optional.FromPtr(req.Url),
PrPermitted: optional.FromPtr(req.PrPermitted),
}

err = h.user.UpdateAccount(ctx, userID, accountID, &args)
Expand Down Expand Up @@ -356,7 +354,7 @@ func (h *UserHandler) GetMe(c echo.Context) error {

accounts := make([]schema.Account, len(user.Accounts))
for i, v := range user.Accounts {
accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted)
accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL)
}

return c.JSON(http.StatusOK, newUserDetail(
Expand Down Expand Up @@ -386,13 +384,12 @@ func newUserDetail(user schema.User, accounts []schema.Account, bio string, stat
}
}

func newAccount(id uuid.UUID, displayName string, atype schema.AccountType, url string, prPermitted bool) schema.Account {
func newAccount(id uuid.UUID, displayName string, atype schema.AccountType, url string) schema.Account {
return schema.Account{
Id: id,
DisplayName: displayName,
Type: atype,
Url: url,
PrPermitted: schema.PrPermitted(prPermitted),
}
}

Expand Down
Loading
Loading