From 1a5deabadb76f8411ce2dd75fa739c691cbdb54c Mon Sep 17 00:00:00 2001 From: Asai Neko Date: Wed, 11 Feb 2026 21:51:34 +0800 Subject: [PATCH] Enforce nickname is not null after join event Signed-off-by: Asai Neko --- service/service_event/join_event.go | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/service/service_event/join_event.go b/service/service_event/join_event.go index e71eef9..9d986ee 100644 --- a/service/service_event/join_event.go +++ b/service/service_event/join_event.go @@ -126,6 +126,49 @@ func (self *EventServiceImpl) JoinEvent(payload *EventJoinPayload) (result *Even 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) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {