feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
52
app/models/invite.go
Обычный файл
52
app/models/invite.go
Обычный файл
@@ -0,0 +1,52 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models/concerns"
|
||||
)
|
||||
|
||||
// Invite provides functionality.
|
||||
type Invite struct {
|
||||
concerns.Model
|
||||
|
||||
AccountID int64 `gorm:"type:bigint REFERENCES accounts(id)" json:"account_id"`
|
||||
Account *Account `json:"-"`
|
||||
InviterID *int64 `gorm:"type:bigint REFERENCES users(id)" json:"inviter_id"`
|
||||
Inviter *User `json:"inviter"`
|
||||
InviteeID *int64 `gorm:"type:bigint REFERENCES users(id)" json:"invitee_id"`
|
||||
Invitee *User `json:"invitee"`
|
||||
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
|
||||
// invite state, FAIL - failed to send, SENT - not regestired, OK - registered
|
||||
State string `gorm:"not null;default:'UNK'" json:"state"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
RegisteredAt time.Time `json:"registered_at"`
|
||||
SentAt time.Time `json:"sent_at"`
|
||||
|
||||
Accesses []Access `json:"accesses" gorm:"foreignkey:invite_id"`
|
||||
|
||||
concerns.HasToken
|
||||
Audited
|
||||
}
|
||||
|
||||
// BeforeCreate runs before creating an Invite record.
|
||||
func (i *Invite) BeforeCreate(_ *gorm.DB) error {
|
||||
i.SetToken()
|
||||
return nil
|
||||
}
|
||||
|
||||
// FillAccesses provides functionality.
|
||||
func (i *Invite) FillAccesses() {
|
||||
for k, a := range i.Accesses { //nolint:gocritic // range copy is acceptable here
|
||||
if a.ID <= 0 {
|
||||
i.Accesses[k].ID = 0
|
||||
}
|
||||
i.Accesses[k].AccountID = i.AccountID
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user