🐛 Device no longer can register
This commit is contained in:
parent
c3636c23ff
commit
e8b5b05755
@ -32,6 +32,6 @@ type NotificationSubscriber struct {
|
|||||||
|
|
||||||
UserAgent string `json:"user_agent"`
|
UserAgent string `json:"user_agent"`
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
DeviceID string `json:"device_id"`
|
DeviceID string `json:"device_id" gorm:"uniqueIndex"`
|
||||||
AccountID uint `json:"account_id"`
|
AccountID uint `json:"account_id"`
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
|
import "C"
|
||||||
import (
|
import (
|
||||||
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
"code.smartsheep.studio/hydrogen/passport/pkg/models"
|
||||||
@ -71,6 +72,14 @@ func addNotifySubscriber(c *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
if err := database.C.Where(&models.NotificationSubscriber{
|
||||||
|
DeviceID: data.DeviceID,
|
||||||
|
AccountID: user.ID,
|
||||||
|
}).Model(&models.NotificationSubscriber{}).Count(&count).Error; err != nil || count > 0 {
|
||||||
|
return c.SendStatus(fiber.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
subscriber, err := services.AddNotifySubscriber(
|
subscriber, err := services.AddNotifySubscriber(
|
||||||
user,
|
user,
|
||||||
data.Provider,
|
data.Provider,
|
||||||
|
Loading…
Reference in New Issue
Block a user