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.
65 lines
2.2 KiB
Go
65 lines
2.2 KiB
Go
package channel
|
|
|
|
import "github.com/gochat/gochat/internal/model"
|
|
|
|
// ChannelMicrosoft represents a Microsoft (Azure AD/Teams) channel.
|
|
// Reference: Chatwoot does not have a native Microsoft channel — this is a gochat addition.
|
|
//
|
|
// Enterprise Microsoft integration uses Azure AD OAuth for authentication
|
|
// and Microsoft Graph API for Teams messaging.
|
|
//
|
|
// Features:
|
|
// - Azure AD OAuth 2.0 authorization flow for enterprise SSO
|
|
// - Microsoft Teams channel messaging via Graph API
|
|
// - Outlook email integration potential
|
|
// - Azure webhook subscriptions for real-time events
|
|
type ChannelMicrosoft struct {
|
|
model.Base
|
|
|
|
// Account foreign key
|
|
AccountID uint `gorm:"index;not null" json:"account_id"`
|
|
|
|
// Inbox foreign key — links to the Inbox that wraps this channel
|
|
InboxID uint `gorm:"not null;uniqueIndex" json:"inbox_id"`
|
|
|
|
// Azure AD tenant ID — identifies the Azure organization
|
|
TenantID string `gorm:"size:255;not null" json:"tenant_id"`
|
|
|
|
// Azure AD client/object ID for the application
|
|
ClientID string `gorm:"size:255;not null" json:"client_id"`
|
|
|
|
// Microsoft Graph API access token
|
|
AccessToken string `gorm:"size:2048;not null" json:"-"`
|
|
|
|
// OAuth 2.0 refresh token for token renewal
|
|
RefreshToken string `gorm:"size:2048" json:"-"`
|
|
|
|
// Microsoft Teams team ID (optional — for Teams channel integration)
|
|
TeamID string `gorm:"size:255" json:"team_id,omitempty"`
|
|
|
|
// Microsoft Teams channel ID (optional — for specific Teams channel)
|
|
ChannelID string `gorm:"size:255" json:"channel_id,omitempty"`
|
|
|
|
// Display name of the connected Microsoft resource
|
|
DisplayName string `gorm:"size:255" json:"display_name,omitempty"`
|
|
|
|
// Webhook subscription ID for Graph API subscriptions
|
|
SubscriptionID string `gorm:"size:255" json:"subscription_id,omitempty"`
|
|
|
|
// Flag indicating reauthorization is required
|
|
ReauthorizationRequired bool `gorm:"default:false" json:"reauthorization_required,omitempty"`
|
|
}
|
|
|
|
func (ChannelMicrosoft) TableName() string { return "channel_microsoft" }
|
|
|
|
func (c ChannelMicrosoft) GetChannelBase() ChannelBase {
|
|
return ChannelBase{
|
|
ID: c.ID,
|
|
AccountID: c.AccountID,
|
|
InboxID: c.InboxID,
|
|
ChannelType: "microsoft",
|
|
}
|
|
}
|
|
|
|
func (c ChannelMicrosoft) GetChannelType() string { return "microsoft" }
|