🐛 Prevent user from creating boost on same destination
This commit is contained in:
parent
a58f44d50e
commit
78e554577e
@ -66,7 +66,12 @@ func GetBoostByID(id uint) (models.AttachmentBoost, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreateBoost(user *sec.UserInfo, source models.Attachment, destination int) (models.AttachmentBoost, error) {
|
func CreateBoost(user *sec.UserInfo, source models.Attachment, destination int) (models.AttachmentBoost, error) {
|
||||||
boost := models.AttachmentBoost{
|
var boost models.AttachmentBoost
|
||||||
|
if err := database.C.Where("attachment_id = ? AND destination = ?", source.ID, destination).First(&boost); err == nil {
|
||||||
|
return boost, fmt.Errorf("boost already exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
boost = models.AttachmentBoost{
|
||||||
Status: models.BoostStatusPending,
|
Status: models.BoostStatusPending,
|
||||||
Destination: destination,
|
Destination: destination,
|
||||||
AttachmentID: source.ID,
|
AttachmentID: source.ID,
|
||||||
|
Loading…
Reference in New Issue
Block a user