Restructure the monorepo into clear top-level directories: - backend/: Go module root (cmd, internal, pkg, configs, migrations, docs/swagger, scripts, tests, go.mod, Makefile, .air.toml) - deploy/: Docker (Dockerfile, docker-compose*), quickstart, fluentd - docs/: project documentation + reports/ (moved from repo root) - AGENTS.md: new AI coding-agent guide at repo root Update all references to the new layout: - Dockerfile: COPY backend/go.mod, COPY backend/ (context = repo root) - docker-compose files: context ../.., dockerfile deploy/docker/Dockerfile, env_file ../../.env, volume mounts ../../backend:/app - deploy/quickstart/compose.yaml: dockerfile deploy/docker/Dockerfile - CI: working-directory: backend for go commands, file deploy/docker/Dockerfile, coverage path backend/coverage.out, health_check backend/scripts/ - backend/Makefile: docker target uses -f ../deploy/docker/Dockerfile ../ - README: architecture tree, quickstart, config paths updated Move root stray scripts (rename_models.*, run_m11_tests.sh, verify_build.sh, gorm_bool_main.go) to backend/scripts/legacy/. All moves via git mv to preserve history. Build, vet, SQLite tests, and docker compose config verified.
45 lines
2.4 KiB
Go
45 lines
2.4 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// Portal represents a help center / knowledge base portal.
|
|
// Reference: Chatwoot Portal model + P2B M9 spec
|
|
type Portal struct {
|
|
Base
|
|
AccountID uint `gorm:"index;not null" json:"account_id"`
|
|
Name string `gorm:"size:255;not null" json:"name"`
|
|
Slug string `gorm:"size:255;not null;uniqueIndex" json:"slug"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
LogoURL string `gorm:"size:512" json:"logo_url"`
|
|
HeaderText string `gorm:"type:text" json:"header_text"`
|
|
HomepageLink string `gorm:"size:255" json:"homepage_link"`
|
|
PageTitle string `gorm:"size:255" json:"page_title"`
|
|
Color string `gorm:"size:20;default:'#1f93ff'" json:"color"`
|
|
Archived bool `gorm:"default:false" json:"archived"`
|
|
CustomDomain string `gorm:"size:255" json:"custom_domain"`
|
|
Locale string `gorm:"size:10;default:'en'" json:"locale"`
|
|
PortalConfiguration json.RawMessage `gorm:"type:jsonb;serializer:json" json:"portal_configuration"` // allowed_locales, default_locale, layout, social_profiles
|
|
SSLSettings json.RawMessage `gorm:"type:jsonb;default:'{}';serializer:json" json:"ssl_settings"`
|
|
ChannelWebWidgetID *uint `gorm:"index" json:"channel_web_widget_id,omitempty"`
|
|
HomepageContent string `gorm:"type:text" json:"homepage_content"`
|
|
|
|
Account Account `gorm:"foreignKey:AccountID" json:"account,omitempty"`
|
|
Categories []Category `gorm:"foreignKey:PortalID" json:"categories,omitempty"`
|
|
Members []PortalMember `gorm:"foreignKey:PortalID" json:"members,omitempty"`
|
|
Folders []Folder `gorm:"foreignKey:PortalID" json:"folders,omitempty"`
|
|
Articles []Article `gorm:"foreignKey:PortalID" json:"articles,omitempty"`
|
|
}
|
|
|
|
// PortalSSLStatus is a read-only DTO for the SSL status of a portal.
|
|
// Reference: Chatwoot portals_controller#ssl_status
|
|
type PortalSSLStatus struct {
|
|
PortalID uint `json:"portal_id"`
|
|
CustomDomain string `json:"custom_domain"`
|
|
SSLState string `json:"ssl_state"` // no_custom_domain, pending, success, error
|
|
CertificateExpiry string `json:"certificate_expiry,omitempty"`
|
|
CNAMEValid bool `json:"cname_valid"`
|
|
}
|
|
|
|
func (Portal) TableName() string { return "portals" } |