package models

import "time"

// UserSocialAccount links one Firebase provider identity to a local user row.
// A user may have several (Google today, Apple tomorrow), so the identity lives
// here rather than as a column on users.
type UserSocialAccount struct {
	ID uint `gorm:"primaryKey;column:id" json:"id"`

	UserID uint `gorm:"column:userId" json:"userId"`

	// Provider is Firebase's sign_in_provider (google.com, apple.com, ...).
	Provider string `gorm:"column:provider" json:"provider"`

	// ProviderUID is the Firebase uid (the ID token `sub`).
	ProviderUID string `gorm:"column:providerUid" json:"providerUid"`

	Email string `gorm:"column:email" json:"email"`

	Name string `gorm:"column:name" json:"name"`

	PhotoURL string `gorm:"column:photoUrl" json:"photoUrl"`

	// Platform records which app the identity was last seen from: mobile | web.
	Platform string `gorm:"column:platform" json:"platform"`

	IsActive bool `gorm:"column:isActive" json:"isActive"`

	IsDelete bool `gorm:"column:isDelete" json:"isDelete"`

	LastLoginAt *time.Time `gorm:"column:last_login_at" json:"last_login_at"`

	CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`

	UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
}

func (UserSocialAccount) TableName() string {
	return "user_social_accounts"
}
