backend-ci.yml's `test -z "$(gofmt -l .)"` strict gate (added in
13c21ac11) failed on a backlog of unformatted files. None of the
85 files in this commit had been edited since the gate was added
because no push touched veza-backend-api/** in between, so the
gate never fired until today's CI fixes triggered it.
The diff is exclusively whitespace alignment in struct literals
and trailing-space comments. `go build ./...` and the full test
suite (with VEZA_SKIP_INTEGRATION=1 -short) pass identically.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// RoomInvitation represents an invitation to join a room (v0.9.7)
|
|
type RoomInvitation struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
|
|
RoomID uuid.UUID `gorm:"type:uuid;not null" json:"room_id"`
|
|
InviterID uuid.UUID `gorm:"type:uuid;not null" json:"inviter_id"`
|
|
InviteeID *uuid.UUID `gorm:"type:uuid" json:"invitee_id,omitempty"`
|
|
Token uuid.UUID `gorm:"type:uuid;not null;uniqueIndex" json:"token"`
|
|
Status string `gorm:"type:varchar(20);not null;default:'pending'" json:"status"` // pending, accepted, expired
|
|
ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
|
|
Room Room `gorm:"foreignKey:RoomID" json:"-"`
|
|
Inviter User `gorm:"foreignKey:InviterID" json:"-"`
|
|
}
|
|
|
|
func (r *RoomInvitation) BeforeCreate(tx *gorm.DB) error {
|
|
if r.ID == uuid.Nil {
|
|
r.ID = uuid.New()
|
|
}
|
|
if r.Token == uuid.Nil {
|
|
r.Token = uuid.New()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (RoomInvitation) TableName() string {
|
|
return "room_invitations"
|
|
}
|