diff --git a/internal/chat/usecase/chat_usecase.go b/internal/chat/usecase/chat_usecase.go index ee7be61..01cd878 100644 --- a/internal/chat/usecase/chat_usecase.go +++ b/internal/chat/usecase/chat_usecase.go @@ -3,6 +3,7 @@ package usecase import ( "2024_2_FIGHT-CLUB/domain" "context" + "github.com/microcosm-cc/bluemonday" "time" ) @@ -42,6 +43,10 @@ func (cs *chatUseCase) GetChat(ctx context.Context, userID1 string, userID2 stri } func (cs *chatUseCase) SendNewMessage(ctx context.Context, receiver string, sender string, message string) error { + sanitizer := bluemonday.UGCPolicy() + message = sanitizer.Sanitize(message) + receiver = sanitizer.Sanitize(receiver) + sender = sanitizer.Sanitize(sender) err := cs.repo.SendNewMessage(ctx, receiver, sender, message) if err != nil { return err diff --git a/internal/regions/controller/regions_controller.go b/internal/regions/controller/regions_controller.go index 2049c51..4dd40bf 100644 --- a/internal/regions/controller/regions_controller.go +++ b/internal/regions/controller/regions_controller.go @@ -129,9 +129,7 @@ func (rh *RegionHandler) handleError(w http.ResponseWriter, err error, requestID "error generating random bytes for session ID", "failed to fetch reviews for host", "failed to update host score", - "error creating review", - "error updating review", - "error finding review", + "error fetching regions", "error finding host", "error updating host score", "error fetching reviews", diff --git a/internal/regions/repository/regions_repository.go b/internal/regions/repository/regions_repository.go index c0cbeb3..86112a6 100644 --- a/internal/regions/repository/regions_repository.go +++ b/internal/regions/repository/regions_repository.go @@ -51,10 +51,6 @@ func (r *RegionRepository) GetVisitedRegions(ctx context.Context, userId string) Where("\"userId\"", userId). Order("\"startVisitDate\" ASC"). Find(®ions).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - logger.DBLogger.Warn("No regions found", zap.String("request_id", requestID), zap.String("userID", userId)) - return nil, errors.New("no regions found") - } logger.DBLogger.Error("Error fetching regions", zap.String("request_id", requestID), zap.String("userID", userId), zap.Error(err)) return nil, errors.New("error fetching regions") }