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

Fix/issue 400 #461

Merged
merged 4 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions router/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ func (h *Handlers) HandleGetMeGroupIDs(c echo.Context) error {
if err != nil {
return judgeErrorResponse(err)
}
case presentation.RelationBelongsOrAdmins:
belongingGroupIDs, err := h.Repo.GetUserBelongingGroupIDs(userID, getConinfo(c))
if err != nil {
return judgeErrorResponse(err)
}
adminGroupIDs, err := h.Repo.GetUserAdminGroupIDs(userID)
if err != nil {
return judgeErrorResponse(err)
}

groupIDs = append(belongingGroupIDs, adminGroupIDs...)
}

return c.JSON(http.StatusOK, groupIDs)
Expand Down
7 changes: 5 additions & 2 deletions router/presentation/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ func GetTiemRange(values url.Values) (start time.Time, end time.Time, err error)
type UserRelation int

const (
RelationBelongs = iota
RelationAdmins = iota
RelationBelongs = iota
RelationAdmins = iota
RelationBelongsOrAdmins = iota
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
RelationBelongs = iota
RelationAdmins = iota
RelationBelongsOrAdmins = iota
RelationBelongs UserRelation = iota
RelationAdmins
RelationBelongsOrAdmins

かも?今のままだとuntyped intとかになってそう

)

func GetUserRelationQuery(values url.Values) UserRelation {
Expand All @@ -38,6 +39,8 @@ func GetUserRelationQuery(values url.Values) UserRelation {
return RelationBelongs
case "admins":
return RelationAdmins
case "belongsoradmins":
Copy link
Member

Choose a reason for hiding this comment

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

URLに指定するのでbelongs-or-adminsの方がいいかな
openapiにも追記してもらえると助かります:pray:

return RelationBelongsOrAdmins
}

return RelationBelongs
Copy link
Member

Choose a reason for hiding this comment

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

デフォルトをどうするかも考慮したい
個人的にはRelationBelongsOrAdminsが自然な気がします

Expand Down