Skip to content
Open
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
4 changes: 2 additions & 2 deletions domain/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (r *Room) AdminsValidation() bool {
type WriteRoomParams struct {
Place string

// Verifeid indicates if the room has been verified by privileged users.
// Verified indicates if the room has been verified by privileged users.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
TimeStart time.Time
TimeEnd time.Time

Expand All @@ -157,7 +157,7 @@ func (r *WriteRoomParams) TimeConsistency() bool {
}

type RoomService interface {
CreateUnVerifiedRoom(ctx context.Context, reqID uuid.UUID, params WriteRoomParams) (*Room, error)
CreateUnVerifiedRoom(ctx context.Context, reqID uuid.UUID, params WriteRoomParams, update bool, oldRoom uuid.UUID) (*Room, error)
CreateVerifiedRoom(ctx context.Context, reqID uuid.UUID, params WriteRoomParams) (*Room, error)

UpdateRoom(ctx context.Context, reqID uuid.UUID, roomID uuid.UUID, params WriteRoomParams) (*Room, error)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/ory/dockertest/v3 v3.12.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/robfig/cron/v3 v3.0.1
github.com/samber/lo v1.52.0
github.com/samber/lo v1.53.0
github.com/stretchr/testify v1.11.1
github.com/traPtitech/go-traq v0.0.0-20251201015624-285ca186fc5e
go.uber.org/zap v1.27.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0t
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/samber/lo v1.52.0 h1:Rvi+3BFHES3A8meP33VPAxiBZX/Aws5RxrschYGjomw=
github.com/samber/lo v1.52.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
github.com/samber/lo v1.53.0 h1:t975lj2py4kJPQ6haz1QMgtId2gtmfktACxIXArw3HM=
github.com/samber/lo v1.53.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
2 changes: 1 addition & 1 deletion router/presentation/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type StartEndTime struct {

type RoomRes struct {
ID uuid.UUID `json:"roomId"`
// Verifeid indicates if the room has been verified by privileged users.
// Verified indicates if the room has been verified by privileged users.
Verified bool `json:"verified"`
RoomReq
FreeTimes []StartEndTime `json:"freeTimes" cvt:"-"`
Expand Down
2 changes: 1 addition & 1 deletion router/rooms.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (h *Handlers) HandlePostRoom(c echo.Context) error {
roomParams := presentation.ConvRoomReqTodomainWriteRoomParams(req)
ctx := c.Request().Context()
reqID := c.Get(userIDKey).(uuid.UUID)
room, err := h.Service.CreateUnVerifiedRoom(ctx, reqID, roomParams)
room, err := h.Service.CreateUnVerifiedRoom(ctx, reqID, roomParams, false, uuid.Nil)
if err != nil {
return judgeErrorResponse(err)
}
Expand Down
4 changes: 2 additions & 2 deletions service/event_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *service) CreateEvent(ctx context.Context, reqID uuid.UUID, params domai
}
// UnVerifiedを仮定
var r *domain.Room
r, err = s.CreateUnVerifiedRoom(ctx, reqID, roomParams)
r, err = s.CreateUnVerifiedRoom(ctx, reqID, roomParams, false, uuid.Nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func (s *service) UpdateEvent(ctx context.Context, reqID uuid.UUID, eventID uuid
}
// UnVerifiedを仮定
var r *domain.Room
r, err = s.CreateUnVerifiedRoom(ctx, reqID, roomParams)
r, err = s.CreateUnVerifiedRoom(ctx, reqID, roomParams, true, currentEvent.Room.ID)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
if err != nil {
return err
}
Expand Down
10 changes: 8 additions & 2 deletions service/room_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/traPtitech/knoQ/domain"
)

func (s *service) CreateUnVerifiedRoom(ctx context.Context, reqID uuid.UUID, params domain.WriteRoomParams) (*domain.Room, error) {
func (s *service) CreateUnVerifiedRoom(ctx context.Context, reqID uuid.UUID, params domain.WriteRoomParams, update bool, oldRoom uuid.UUID) (*domain.Room, error) {
if !params.TimeConsistency() {
return nil, ErrTimeConsistency
}
Expand All @@ -19,7 +19,13 @@ func (s *service) CreateUnVerifiedRoom(ctx context.Context, reqID uuid.UUID, par
}
var roomResp *domain.Room
err := s.TxManager.Do(ctx, func(ctx context.Context) error {
var err error
var err, err2 error
if update {
err2 = s.GormRepo.DeleteRoom(ctx, oldRoom)
if err2 != nil {
return err2
}
}
roomResp, err = s.GormRepo.CreateRoom(ctx, p)
return err
})
Expand Down