Skip to content

Commit bd9c327

Browse files
authored
Merge pull request #739 from traPtitech/delete/account_pr-permitted
ユーザーアカウントAPIのprPermittedに当たる要素を全て消した
2 parents 9276fbb + acf37d2 commit bd9c327

30 files changed

+85
-125
lines changed

.tbls.yml

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ comments:
6969
name: アカウント名
7070
url: アカウントのURL
7171
user_id: ユーザーUUID
72-
check: 公開可能かどうか
7372
- table: projects
7473
tableComment: プロジェクトテーブル
7574
columnComments:

docs/dbschema/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Name | Columns | Comment | Type |
66
| ---- | ------- | ------- | ---- |
7-
| [accounts](accounts.md) | 8 | Twitterなどのアカウントテーブル | BASE TABLE |
7+
| [accounts](accounts.md) | 7 | Twitterなどのアカウントテーブル | BASE TABLE |
88
| [contests](contests.md) | 8 | コンテストテーブル | BASE TABLE |
99
| [contest_teams](contest_teams.md) | 8 | コンテスト参加チームテーブル | BASE TABLE |
1010
| [contest_team_user_belongings](contest_team_user_belongings.md) | 4 | コンテストチームとユーザー関係テーブル | BASE TABLE |
@@ -38,7 +38,6 @@ erDiagram
3838
varchar_256_ name
3939
text url
4040
char_36_ user_id FK
41-
tinyint_1_ check
4241
datetime_6_ created_at
4342
datetime_6_ updated_at
4443
}

docs/dbschema/accounts.md

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CREATE TABLE `accounts` (
1414
`name` varchar(256) DEFAULT NULL,
1515
`url` text DEFAULT NULL,
1616
`user_id` char(36) NOT NULL,
17-
`check` tinyint(1) NOT NULL DEFAULT 0,
1817
`created_at` datetime(6) DEFAULT NULL,
1918
`updated_at` datetime(6) DEFAULT NULL,
2019
PRIMARY KEY (`id`),
@@ -34,7 +33,6 @@ CREATE TABLE `accounts` (
3433
| name | varchar(256) | NULL | true | | | アカウント名 |
3534
| url | text | NULL | true | | | アカウントのURL |
3635
| user_id | char(36) | | false | | [users](users.md) | ユーザーUUID |
37-
| check | tinyint(1) | 0 | false | | | 公開可能かどうか |
3836
| created_at | datetime(6) | NULL | true | | | |
3937
| updated_at | datetime(6) | NULL | true | | | |
4038

@@ -65,7 +63,6 @@ erDiagram
6563
varchar_256_ name
6664
text url
6765
char_36_ user_id FK
68-
tinyint_1_ check
6966
datetime_6_ created_at
7067
datetime_6_ updated_at
7168
}

docs/dbschema/schema.json

+1-1
Large diffs are not rendered by default.

docs/dbschema/users.md

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ erDiagram
7474
varchar_256_ name
7575
text url
7676
char_36_ user_id FK
77-
tinyint_1_ check
7877
datetime_6_ created_at
7978
datetime_6_ updated_at
8079
}

docs/swagger/traPortfolio.v1.yaml

-12
Original file line numberDiff line numberDiff line change
@@ -830,16 +830,13 @@ components:
830830
description: 外部アカウントの表示名
831831
type:
832832
$ref: "#/components/schemas/AccountType"
833-
prPermitted:
834-
$ref: "#/components/schemas/PrPermitted"
835833
url:
836834
type: string
837835
description: アカウントurl
838836
required:
839837
- id
840838
- displayName
841839
- type
842-
- prPermitted
843840
- url
844841
AccountType:
845842
type: integer
@@ -1207,10 +1204,6 @@ components:
12071204
required:
12081205
- link
12091206
- description
1210-
PrPermitted:
1211-
title: PrPermitted
1212-
type: boolean
1213-
description: 広報での利用が許可されているかどうか
12141207
Duration:
12151208
title: Duration
12161209
type: object
@@ -1306,8 +1299,6 @@ components:
13061299
properties:
13071300
type:
13081301
$ref: "#/components/schemas/AccountType"
1309-
prPermitted:
1310-
$ref: "#/components/schemas/PrPermitted"
13111302
url:
13121303
type: string
13131304
description: アカウントurl
@@ -1317,7 +1308,6 @@ components:
13171308
description: 外部アカウントの表示名
13181309
required:
13191310
- type
1320-
- prPermitted
13211311
- url
13221312
- displayName
13231313
EditUserAccountRequest:
@@ -1327,8 +1317,6 @@ components:
13271317
properties:
13281318
type:
13291319
$ref: "#/components/schemas/AccountType"
1330-
prPermitted:
1331-
$ref: "#/components/schemas/PrPermitted"
13321320
url:
13331321
type: string
13341322
description: アカウントurl

integration_tests/handler/user_test.go

-19
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ func TestAddUserAccount(t *testing.T) {
327327
displayName = random.AlphaNumeric()
328328
justCountDisplayName = strings.Repeat("亜", 256)
329329
tooLongDisplayName = strings.Repeat("亜", 257)
330-
prPermitted = schema.PrPermitted(random.Bool())
331330
testUserID = mockdata.UserID1()
332331
accountType = schema.AccountType(mockdata.AccountTypesMockUserDoesntHave(testUserID)[0])
333332
accountURL = random.AccountURLString(domain.AccountType(accountType))
@@ -349,14 +348,12 @@ func TestAddUserAccount(t *testing.T) {
349348
testUserID,
350349
schema.AddAccountRequest{
351350
DisplayName: displayName,
352-
PrPermitted: prPermitted,
353351
Type: accountType,
354352
Url: accountURL,
355353
},
356354
schema.Account{
357355
Id: uuid.Nil,
358356
DisplayName: displayName,
359-
PrPermitted: prPermitted,
360357
Type: accountType,
361358
Url: accountURL,
362359
},
@@ -366,14 +363,12 @@ func TestAddUserAccount(t *testing.T) {
366363
testUserID2,
367364
schema.AddAccountRequest{
368365
DisplayName: justCountDisplayName,
369-
PrPermitted: prPermitted,
370366
Type: accountType2,
371367
Url: accountURL2,
372368
},
373369
schema.Account{
374370
Id: uuid.Nil,
375371
DisplayName: justCountDisplayName,
376-
PrPermitted: prPermitted,
377372
Type: accountType2,
378373
Url: accountURL2,
379374
},
@@ -389,7 +384,6 @@ func TestAddUserAccount(t *testing.T) {
389384
testUserID,
390385
schema.AddAccountRequest{
391386
DisplayName: displayName,
392-
PrPermitted: prPermitted,
393387
Type: accountType,
394388
Url: "invalid url",
395389
},
@@ -400,7 +394,6 @@ func TestAddUserAccount(t *testing.T) {
400394
testUserID,
401395
schema.AddAccountRequest{
402396
DisplayName: displayName,
403-
PrPermitted: prPermitted,
404397
Type: schema.AccountType(domain.AccountLimit),
405398
Url: accountURL,
406399
},
@@ -411,7 +404,6 @@ func TestAddUserAccount(t *testing.T) {
411404
testUserID,
412405
schema.AddAccountRequest{
413406
DisplayName: displayName,
414-
PrPermitted: prPermitted,
415407
Type: conflictType,
416408
Url: random.AccountURLString(domain.AccountType(conflictType)),
417409
},
@@ -422,7 +414,6 @@ func TestAddUserAccount(t *testing.T) {
422414
testUserID,
423415
schema.AddAccountRequest{
424416
DisplayName: tooLongDisplayName,
425-
PrPermitted: prPermitted,
426417
Type: accountType,
427418
Url: accountURL,
428419
},
@@ -450,7 +441,6 @@ func TestAddUserAccount(t *testing.T) {
450441
func TestEditUserAccount(t *testing.T) {
451442
var (
452443
displayName = random.AlphaNumeric()
453-
prPermitted = schema.PrPermitted(random.Bool())
454444
testAccount = mockdata.UserID1()
455445
accountType = schema.AccountType(mockdata.AccountTypesMockUserHas(testAccount)[0])
456446
accountURL = random.AccountURLString(domain.AccountType(accountType))
@@ -474,7 +464,6 @@ func TestEditUserAccount(t *testing.T) {
474464
mockdata.AccountID1(),
475465
schema.EditUserAccountRequest{
476466
DisplayName: &displayName,
477-
PrPermitted: &prPermitted,
478467
Type: &accountType,
479468
Url: &accountURL,
480469
},
@@ -551,7 +540,6 @@ func TestEditUserAccount(t *testing.T) {
551540
mockdata.AccountID1(),
552541
schema.EditUserAccountRequest{
553542
DisplayName: &displayName,
554-
PrPermitted: &prPermitted,
555543
Type: &accountType,
556544
Url: &accountURL,
557545
},
@@ -570,13 +558,11 @@ func TestEditUserAccount(t *testing.T) {
570558
// Insert & Assert
571559
account = schema.Account{
572560
DisplayName: random.AlphaNumeric(),
573-
PrPermitted: schema.PrPermitted(random.Bool()),
574561
Type: schema.AccountType(initialAccountType),
575562
Url: random.AccountURLString(initialAccountType),
576563
}
577564
res := doRequest(t, e, http.MethodPost, e.URL(api.User.AddUserAccount, tt.userID), schema.AddAccountRequest{
578565
DisplayName: account.DisplayName,
579-
PrPermitted: account.PrPermitted,
580566
Type: account.Type,
581567
Url: account.Url,
582568
})
@@ -595,9 +581,6 @@ func TestEditUserAccount(t *testing.T) {
595581
if tt.reqBody.DisplayName != nil {
596582
account.DisplayName = *tt.reqBody.DisplayName
597583
}
598-
if tt.reqBody.PrPermitted != nil {
599-
account.PrPermitted = *tt.reqBody.PrPermitted
600-
}
601584
if tt.reqBody.Type != nil {
602585
account.Type = *tt.reqBody.Type
603586
}
@@ -660,14 +643,12 @@ func TestDeleteUserAccount(t *testing.T) {
660643
accountType := mockdata.AccountTypesMockUserDoesntHave(tt.userID)[0]
661644
reqBody := schema.AddAccountRequest{
662645
DisplayName: random.AlphaNumeric(),
663-
PrPermitted: schema.PrPermitted(random.Bool()),
664646
Type: accountType,
665647
Url: random.AccountURLString(domain.AccountType(accountType)),
666648
}
667649
res := doRequest(t, e, http.MethodPost, e.URL(api.User.AddUserAccount, tt.userID), &reqBody)
668650
assertResponse(t, http.StatusCreated, schema.Account{
669651
DisplayName: reqBody.DisplayName,
670-
PrPermitted: reqBody.PrPermitted,
671652
Type: reqBody.Type,
672653
Url: reqBody.Url,
673654
}, res, optSyncID, optRetrieveID(&tt.accountID))

internal/domain/user.go

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type Account struct {
4444
ID uuid.UUID
4545
DisplayName string
4646
Type AccountType
47-
PrPermitted bool
4847
URL string
4948
}
5049

internal/handler/schema/schema_gen.go

+1-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/handler/schema/validator.go

-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ func (p GetUsersParams) Validate() error {
3636
func (r AddAccountRequest) Validate() error {
3737
return vd.ValidateStruct(&r,
3838
vd.Field(&r.DisplayName, vd.Required, vdRuleDisplayNameLength),
39-
vd.Field(&r.PrPermitted),
4039
vd.Field(&r.Type, vdRuleAccountTypeMax),
4140
vd.Field(&r.Url, vd.Required, is.URL),
4241
)
@@ -78,7 +77,6 @@ func (r CreateProjectRequest) Validate() error {
7877
func (r EditUserAccountRequest) Validate() error {
7978
return vd.ValidateStruct(&r,
8079
vd.Field(&r.DisplayName, vd.NilOrNotEmpty, vdRuleDisplayNameLength),
81-
vd.Field(&r.PrPermitted),
8280
vd.Field(&r.Type, vdRuleAccountTypeMax),
8381
vd.Field(&r.Url, vd.NilOrNotEmpty, is.URL),
8482
)

internal/handler/user.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (h *UserHandler) GetUser(c echo.Context) error {
7373

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

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

124124
res := make([]schema.Account, len(accounts))
125125
for i, v := range accounts {
126-
res[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted)
126+
res[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL)
127127
}
128128

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

150-
return c.JSON(http.StatusOK, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL, account.PrPermitted))
150+
return c.JSON(http.StatusOK, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL))
151151
}
152152

153153
// AddUserAccount POST /users/:userID/accounts
@@ -166,15 +166,14 @@ func (h *UserHandler) AddUserAccount(c echo.Context) error {
166166
args := repository.CreateAccountArgs{
167167
DisplayName: req.DisplayName,
168168
Type: domain.AccountType(req.Type),
169-
PrPermitted: bool(req.PrPermitted),
170169
URL: req.Url,
171170
}
172171
account, err := h.user.CreateAccount(ctx, userID, &args)
173172
if err != nil {
174173
return err
175174
}
176175

177-
return c.JSON(http.StatusCreated, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL, account.PrPermitted))
176+
return c.JSON(http.StatusCreated, newAccount(account.ID, account.DisplayName, schema.AccountType(account.Type), account.URL))
178177
}
179178

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

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

357355
accounts := make([]schema.Account, len(user.Accounts))
358356
for i, v := range user.Accounts {
359-
accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL, v.PrPermitted)
357+
accounts[i] = newAccount(v.ID, v.DisplayName, schema.AccountType(v.Type), v.URL)
360358
}
361359

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

389-
func newAccount(id uuid.UUID, displayName string, atype schema.AccountType, url string, prPermitted bool) schema.Account {
387+
func newAccount(id uuid.UUID, displayName string, atype schema.AccountType, url string) schema.Account {
390388
return schema.Account{
391389
Id: id,
392390
DisplayName: displayName,
393391
Type: atype,
394392
Url: url,
395-
PrPermitted: schema.PrPermitted(prPermitted),
396393
}
397394
}
398395

0 commit comments

Comments
 (0)