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.
58 lines
2.5 KiB
Go
58 lines
2.5 KiB
Go
package channel
|
|
|
|
// ChannelLINE represents a LINE Official Account channel configuration.
|
|
// Reference: LINE Messaging API — https://developers.line.biz/en/docs/messaging-api/
|
|
//
|
|
// GoChat addition — LINE Messaging API integration.
|
|
// The LINE channel connects LINE Official Accounts to gochat conversations.
|
|
//
|
|
// Key LINE API concepts:
|
|
// - Channel Access Token: long-lived token for API calls (renewable)
|
|
// - Channel Secret: used for webhook signature verification (HMAC-SHA256)
|
|
// - LINE Login: OAuth2 flow for user authentication (optional)
|
|
// - Webhook URL: where LINE sends event notifications
|
|
//
|
|
// Design notes:
|
|
// - Uses GORM soft-delete pattern consistent with other channel models
|
|
// - JSON field tags follow snake_case convention per P2D §7
|
|
// - Channel-specific fields (channel_access_token, channel_secret) are stored
|
|
// in Inbox.ChannelConfig rather than in this model, keeping the model lean
|
|
// per the Chatwoot pattern where channel_type specific config lives in the polymorphic association
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
// ChannelLINE is the GORM model for LINE Official Account channels.
|
|
// Reference: Chatwoot does not have LINE channel support — this is a GoChat addition.
|
|
// Design: Follows the same pattern as ChannelTelegram — minimal GORM model with
|
|
// config stored in Inbox.ChannelConfig (JSONB).
|
|
type ChannelLINE struct {
|
|
gorm.Model
|
|
|
|
// LINE Channel ID (from LINE Developers Console)
|
|
// Unique identifier for the LINE Official Account
|
|
ChannelID string `json:"channel_id" gorm:"type:varchar(255);uniqueIndex;not null"`
|
|
|
|
// LINE Official Account name (display name)
|
|
Name string `json:"name" gorm:"type:varchar(255)"`
|
|
|
|
// AccountID references the owning account (multi-tenant)
|
|
// Foreign key to accounts table for tenant isolation
|
|
AccountID uint `json:"account_id" gorm:"index;not null"`
|
|
|
|
// InboxID references the associated inbox (1:1 with channel)
|
|
InboxID uint `json:"inbox_id" gorm:"uniqueIndex;not null"`
|
|
}
|
|
|
|
// TableName overrides GORM table name convention.
|
|
func (ChannelLINE) TableName() string { return "channel_lines" }
|
|
|
|
// Channelable interface implementation for ChannelLINE.
|
|
// Returns LINE-specific identifiers and display name.
|
|
|
|
func (c *ChannelLINE) GetChannelType() string { return "line" }
|
|
func (c *ChannelLINE) GetChannelID() string { return c.ChannelID }
|
|
func (c *ChannelLINE) GetName() string { return c.Name }
|
|
func (c *ChannelLINE) GetAccountID() uint { return c.AccountID }
|
|
func (c *ChannelLINE) GetInboxID() uint { return c.InboxID }
|
|
func (c *ChannelLINE) SetInboxID(id uint) { c.InboxID = id }
|