🐛 Fix check punishment expires
This commit is contained in:
parent
b327e08062
commit
e716f5700c
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.solsynth.dev/hypernet/passport
|
||||
go 1.23.2
|
||||
|
||||
require (
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250329075932-d5422ab5b04c
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250330063116-4350d197f9c6
|
||||
git.solsynth.dev/hypernet/paperclip v0.0.0-20250310151112-1d866f317f47
|
||||
git.solsynth.dev/hypernet/pusher v0.0.0-20250216145944-5fb769823a88
|
||||
git.solsynth.dev/hypernet/wallet v0.0.0-20250323095812-468cd655f886
|
||||
|
2
go.sum
2
go.sum
@ -6,6 +6,8 @@ git.solsynth.dev/hypernet/nexus v0.0.0-20250329072729-4a08fd8f1c46 h1:oH2jq7ZG5c
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250329072729-4a08fd8f1c46/go.mod h1:5tk62VQ1DcbR0EAN2jAOqYxHiegUPEC805JlfQ/G19I=
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250329075932-d5422ab5b04c h1:XgdTgJxSAQuCbiG15hN5pY6chzcz8sX3Onm2itS+Ufs=
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250329075932-d5422ab5b04c/go.mod h1:5tk62VQ1DcbR0EAN2jAOqYxHiegUPEC805JlfQ/G19I=
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250330063116-4350d197f9c6 h1:K7dYn7/rAXry3dSghFVd4aHOt2+8nTbhdav6DTW8sP8=
|
||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250330063116-4350d197f9c6/go.mod h1:5tk62VQ1DcbR0EAN2jAOqYxHiegUPEC805JlfQ/G19I=
|
||||
git.solsynth.dev/hypernet/paperclip v0.0.0-20250310151112-1d866f317f47 h1:fvu+bNKPTNtQocssnKbEZ66MqR0iBfAxY3HwlqnmYyE=
|
||||
git.solsynth.dev/hypernet/paperclip v0.0.0-20250310151112-1d866f317f47/go.mod h1:jvxq2qftz2v72x+24+cTFJdQKr9eHQTdk3KVR7cx36s=
|
||||
git.solsynth.dev/hypernet/pusher v0.0.0-20250216145944-5fb769823a88 h1:2HEENe9KUrdaJeNBzx9lsuXQGyzWqCgnLTKQnr8xFr8=
|
||||
|
@ -32,7 +32,7 @@ func NewPunishment(in models.Punishment, moderator ...models.Account) (models.Pu
|
||||
if err := database.C.Create(&in).Error; err != nil {
|
||||
return in, err
|
||||
} else {
|
||||
var moderator = "System"
|
||||
moderator := "System"
|
||||
if in.Moderator != nil {
|
||||
moderator = fmt.Sprintf("@%s", in.Moderator.Name)
|
||||
}
|
||||
@ -57,7 +57,7 @@ func EditPunishment(in models.Punishment) (models.Punishment, error) {
|
||||
if err := database.C.Save(&in).Error; err != nil {
|
||||
return in, err
|
||||
} else {
|
||||
var moderator = "System"
|
||||
moderator := "System"
|
||||
if in.Moderator != nil {
|
||||
moderator = fmt.Sprintf("@%s", in.Moderator.Name)
|
||||
}
|
||||
@ -81,7 +81,7 @@ func DeletePunishment(in models.Punishment) error {
|
||||
if err := database.C.Delete(&in).Error; err != nil {
|
||||
return err
|
||||
} else {
|
||||
var moderator = "System"
|
||||
moderator := "System"
|
||||
if in.Moderator != nil {
|
||||
moderator = fmt.Sprintf("@%s", in.Moderator.Name)
|
||||
}
|
||||
@ -125,7 +125,7 @@ func GetMadePunishment(id uint, moderator models.Account) (models.Punishment, er
|
||||
func ListPunishments(user models.Account) ([]models.Punishment, error) {
|
||||
var punishments []models.Punishment
|
||||
if err := database.C.
|
||||
Where("account_id = ? AND (expired_at IS NULL OR expired_at <= ?)", user.ID, time.Now()).
|
||||
Where("account_id = ? AND (expired_at IS NULL OR expired_at > ?)", user.ID, time.Now()).
|
||||
Preload("Moderator").
|
||||
Order("created_at DESC").
|
||||
Find(&punishments).Error; err != nil {
|
||||
@ -183,7 +183,7 @@ func ListMadePunishments(moderator models.Account, take, offset int) ([]models.P
|
||||
|
||||
func CheckLoginAbility(user models.Account) error {
|
||||
var punishments []models.Punishment
|
||||
if err := database.C.Where("account_id = ? AND (expired_at IS NULL OR expired_at <= ?)", user.ID, time.Now()).
|
||||
if err := database.C.Where("account_id = ? AND (expired_at IS NULL OR expired_at > ?)", user.ID, time.Now()).
|
||||
Find(&punishments).Error; err != nil {
|
||||
return fmt.Errorf("failed to get punishments: %v", err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user