Skip to content

Commit cdc6c76

Browse files
yyyyyyjwppolariss
authored andcommitted
feat: update hole timestamps on first floor moderation to prevent burial
1 parent 197c85d commit cdc6c76

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

apis/floor/apis.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,29 @@ func ModifyFloorSensitive(c *fiber.Ctx) (err error) {
10261026

10271027
if !body.IsActualSensitive {
10281028
// save actual_sensitive only
1029-
return tx.Model(&floor).Select("IsActualSensitive").UpdateColumns(&floor).Error
1029+
err := tx.Model(&floor).Select("IsActualSensitive").UpdateColumns(&floor).Error
1030+
if err != nil {
1031+
return err
1032+
}
1033+
1034+
// update CreatedAt and UpdatedAt to prevent new posts from being buried due to review delays
1035+
if floor.Ranking == 0 {
1036+
var hole Hole
1037+
err = tx.First(&hole, floor.HoleID).Error
1038+
if err != nil {
1039+
return err
1040+
}
1041+
1042+
now := time.Now()
1043+
hole.CreatedAt = now
1044+
hole.UpdatedAt = now
1045+
err = tx.Model(&hole).Select("CreatedAt", "UpdatedAt").UpdateColumns(&hole).Error
1046+
if err != nil {
1047+
return err
1048+
}
1049+
}
1050+
1051+
return nil
10301052
}
10311053

10321054
reason := "违反社区规范"

models/hole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func (hole *Hole) SetHoleFloor() {
369369
hole.HoleFloor.Floors = hole.Floors[0 : holeFloorSize-1]
370370
}
371371
} else if len(hole.HoleFloor.Floors) != 0 {
372-
holeFloorSize := len(hole.Floors)
372+
holeFloorSize := len(hole.HoleFloor.Floors)
373373

374374
hole.HoleFloor.FirstFloor = hole.HoleFloor.Floors[0]
375375
hole.HoleFloor.LastFloor = hole.HoleFloor.Floors[holeFloorSize-1]

0 commit comments

Comments
 (0)