@@ -715,6 +715,7 @@ func (s *server) ReportMap(ctx context.Context, request ReportMapRequestObject)
715715 return nil , fmt .Errorf ("failed to fetch map: %w" , err )
716716 }
717717
718+ var shouldDislike = false
718719 reportParams := db.InsertMapReportParams {
719720 MapID : request .MapId ,
720721 PlayerID : request .Body .Reporter ,
@@ -723,6 +724,10 @@ func (s *server) ReportMap(ctx context.Context, request ReportMapRequestObject)
723724 }
724725 for i , category := range request .Body .Categories {
725726 reportParams .Categories [i ] = mapReportCategoryFromAPI (category )
727+
728+ if model.ReportCategoriesToDislike [reportParams.Categories [i ]] == true {
729+ shouldDislike = true
730+ }
726731 }
727732
728733 // Save the report to the database immediately for future lookup
@@ -732,12 +737,25 @@ func (s *server) ReportMap(ctx context.Context, request ReportMapRequestObject)
732737 }
733738 s .log .Infow ("created map report #" + strconv .Itoa (report .ID ), "report" , report )
734739
735- // Submitting a report always results in disliking the map
736- err = s .store .UpsertMapRating (ctx , report .MapID , report .PlayerID , int (model .RatingStateDisliked ))
737- if err != nil {
738- // This is non fatal, just log it
739- s .log .Errorw ("failed to dislike map during report" , "error" , err )
740+ if shouldDislike {
741+ // Submitting a report that is dislikable should always results in disliking the map
742+ err = s .store .UpsertMapRating (ctx , report .MapID , report .PlayerID , int (model .RatingStateDisliked ))
743+ if err != nil {
744+ // This is non fatal, just log it
745+ s .log .Errorw ("failed to dislike map during report" , "error" , err )
746+ }
747+ }
748+
749+ reportEvent := model.MapReportedEvent {
750+ PlayerId : request .Body .Reporter ,
751+ MapId : request .MapId ,
752+ Categories : make ([]string , len (request .Body .Categories )),
753+ Comment : request .Body .Comment ,
754+ }
755+ for i , category := range request .Body .Categories {
756+ reportEvent .Categories [i ] = string (category )
740757 }
758+ go s .metrics .Write (reportEvent )
741759
742760 return ReportMap200Response {}, nil
743761}
0 commit comments