Enforce nickname is not null after join event
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
@@ -126,6 +126,49 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userData, err := new(data.User).GetByUserId(payload.Context, &userId)
|
||||||
|
if err != nil {
|
||||||
|
exception := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusServer).
|
||||||
|
SetService(exception.ServiceEvent).
|
||||||
|
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonErrorDatabase).
|
||||||
|
SetError(err).
|
||||||
|
Throw(payload.Context)
|
||||||
|
|
||||||
|
result = &EventJoinResult{
|
||||||
|
Common: shared.CommonResult{
|
||||||
|
HttpCode: 500,
|
||||||
|
Exception: exception,
|
||||||
|
},
|
||||||
|
Data: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if userData.Nickname == "" {
|
||||||
|
exception := new(exception.Builder).
|
||||||
|
SetStatus(exception.StatusUser).
|
||||||
|
SetService(exception.ServiceEvent).
|
||||||
|
SetEndpoint(exception.EndpointEventServiceJoin).
|
||||||
|
SetType(exception.TypeCommon).
|
||||||
|
SetOriginal(exception.CommonErrorInvalidInput).
|
||||||
|
SetError(errors.New("user nickname is empty")).
|
||||||
|
Throw(payload.Context)
|
||||||
|
|
||||||
|
result = &EventJoinResult{
|
||||||
|
Common: shared.CommonResult{
|
||||||
|
HttpCode: 500,
|
||||||
|
Exception: exception,
|
||||||
|
},
|
||||||
|
Data: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
attendenceSearch, err := new(data.Attendance).GetAttendance(payload.Context, eventId, userId)
|
attendenceSearch, err := new(data.Attendance).GetAttendance(payload.Context, eventId, userId)
|
||||||
|
|
||||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
|||||||
Reference in New Issue
Block a user