Initial work on getting communication context

Committing now to debug build process.
This commit is contained in:
Eli Ribble 2026-05-12 03:21:18 +00:00
parent fa012bebca
commit 8f0ee9015d
No known key found for this signature in database
31 changed files with 1352 additions and 4 deletions

View file

@ -0,0 +1,24 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package enum
import "github.com/Gleipnir-Technology/jet/postgres"
var Messagetypeemail = &struct {
InitialContact postgres.StringExpression
ReportSubscriptionConfirmation postgres.StringExpression
ReportStatusScheduled postgres.StringExpression
ReportStatusComplete postgres.StringExpression
ReportNotificationConfirmation postgres.StringExpression
}{
InitialContact: postgres.NewEnumValue("initial-contact"),
ReportSubscriptionConfirmation: postgres.NewEnumValue("report-subscription-confirmation"),
ReportStatusScheduled: postgres.NewEnumValue("report-status-scheduled"),
ReportStatusComplete: postgres.NewEnumValue("report-status-complete"),
ReportNotificationConfirmation: postgres.NewEnumValue("report-notification-confirmation"),
}

View file

@ -0,0 +1,20 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package enum
import "github.com/Gleipnir-Technology/jet/postgres"
var Phonestatustype = &struct {
Unconfirmed postgres.StringExpression
OkToSend postgres.StringExpression
Stopped postgres.StringExpression
}{
Unconfirmed: postgres.NewEnumValue("unconfirmed"),
OkToSend: postgres.NewEnumValue("ok-to-send"),
Stopped: postgres.NewEnumValue("stopped"),
}

View file

@ -0,0 +1,18 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package enum
import "github.com/Gleipnir-Technology/jet/postgres"
var Textjobsource = &struct {
Rmo postgres.StringExpression
Nidus postgres.StringExpression
}{
Rmo: postgres.NewEnumValue("rmo"),
Nidus: postgres.NewEnumValue("nidus"),
}

View file

@ -0,0 +1,18 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package enum
import "github.com/Gleipnir-Technology/jet/postgres"
var Textjobtype = &struct {
ReportConfirmation postgres.StringExpression
ReportMessage postgres.StringExpression
}{
ReportConfirmation: postgres.NewEnumValue("report-confirmation"),
ReportMessage: postgres.NewEnumValue("report-message"),
}

View file

@ -0,0 +1,26 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package enum
import "github.com/Gleipnir-Technology/jet/postgres"
var Textorigin = &struct {
District postgres.StringExpression
Llm postgres.StringExpression
WebsiteAction postgres.StringExpression
Customer postgres.StringExpression
Reiteration postgres.StringExpression
CommandResponse postgres.StringExpression
}{
District: postgres.NewEnumValue("district"),
Llm: postgres.NewEnumValue("llm"),
WebsiteAction: postgres.NewEnumValue("website-action"),
Customer: postgres.NewEnumValue("customer"),
Reiteration: postgres.NewEnumValue("reiteration"),
CommandResponse: postgres.NewEnumValue("command-response"),
}

View file

@ -0,0 +1,15 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
type EmailContact struct {
Address string `sql:"primary_key"`
Confirmed bool
IsSubscribed bool
PublicID string
}

View file

@ -0,0 +1,26 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type EmailLog struct {
ID int32 `sql:"primary_key"`
Created time.Time
DeliveryStatus string
Destination string
PublicID string
SentAt *time.Time
Source string
Subject string
TemplateID int32
TemplateData string
Type Messagetypeemail
}

View file

@ -0,0 +1,23 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type EmailTemplate struct {
ContentHTML string
ContentTxt string
ContentHashHTML string
ContentHashTxt string
Created time.Time
ID int32 `sql:"primary_key"`
Superceded *time.Time
MessageType Messagetypeemail
}

View file

@ -0,0 +1,22 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"github.com/google/uuid"
"time"
)
type Mailer struct {
AddressID int32
Created time.Time
ID int32 `sql:"primary_key"`
Recipient string
UUID uuid.UUID
ExternalID string
}

View file

@ -0,0 +1,61 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import "errors"
type Messagetypeemail string
const (
Messagetypeemail_InitialContact Messagetypeemail = "initial-contact"
Messagetypeemail_ReportSubscriptionConfirmation Messagetypeemail = "report-subscription-confirmation"
Messagetypeemail_ReportStatusScheduled Messagetypeemail = "report-status-scheduled"
Messagetypeemail_ReportStatusComplete Messagetypeemail = "report-status-complete"
Messagetypeemail_ReportNotificationConfirmation Messagetypeemail = "report-notification-confirmation"
)
var MessagetypeemailAllValues = []Messagetypeemail{
Messagetypeemail_InitialContact,
Messagetypeemail_ReportSubscriptionConfirmation,
Messagetypeemail_ReportStatusScheduled,
Messagetypeemail_ReportStatusComplete,
Messagetypeemail_ReportNotificationConfirmation,
}
func (e *Messagetypeemail) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "initial-contact":
*e = Messagetypeemail_InitialContact
case "report-subscription-confirmation":
*e = Messagetypeemail_ReportSubscriptionConfirmation
case "report-status-scheduled":
*e = Messagetypeemail_ReportStatusScheduled
case "report-status-complete":
*e = Messagetypeemail_ReportStatusComplete
case "report-notification-confirmation":
*e = Messagetypeemail_ReportNotificationConfirmation
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for Messagetypeemail enum")
}
return nil
}
func (e Messagetypeemail) String() string {
return string(e)
}

View file

@ -0,0 +1,15 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
type Phone struct {
E164 string `sql:"primary_key"`
IsSubscribed bool
Status Phonestatustype
CanSms bool
}

View file

@ -0,0 +1,53 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import "errors"
type Phonestatustype string
const (
Phonestatustype_Unconfirmed Phonestatustype = "unconfirmed"
Phonestatustype_OkToSend Phonestatustype = "ok-to-send"
Phonestatustype_Stopped Phonestatustype = "stopped"
)
var PhonestatustypeAllValues = []Phonestatustype{
Phonestatustype_Unconfirmed,
Phonestatustype_OkToSend,
Phonestatustype_Stopped,
}
func (e *Phonestatustype) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "unconfirmed":
*e = Phonestatustype_Unconfirmed
case "ok-to-send":
*e = Phonestatustype_OkToSend
case "stopped":
*e = Phonestatustype_Stopped
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for Phonestatustype enum")
}
return nil
}
func (e Phonestatustype) String() string {
return string(e)
}

View file

@ -0,0 +1,25 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
// Used to track text messages that should be sent later
type TextJob struct {
Content string
Created time.Time
Destination string
ID int32 `sql:"primary_key"`
Type Textjobtype
Source Textjobsource
Completed *time.Time
CreatorID *int32
ReportID *int32
}

View file

@ -0,0 +1,26 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
// Used to track text messages that were sent.
type TextLog struct {
Content string
Created time.Time
Destination string
ID int32 `sql:"primary_key"`
IsWelcome bool
Origin Textorigin
Source string
TwilioSid *string
TwilioStatus string
IsVisibleToLlm bool
}

View file

@ -0,0 +1,49 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import "errors"
type Textjobsource string
const (
Textjobsource_Rmo Textjobsource = "rmo"
Textjobsource_Nidus Textjobsource = "nidus"
)
var TextjobsourceAllValues = []Textjobsource{
Textjobsource_Rmo,
Textjobsource_Nidus,
}
func (e *Textjobsource) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "rmo":
*e = Textjobsource_Rmo
case "nidus":
*e = Textjobsource_Nidus
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for Textjobsource enum")
}
return nil
}
func (e Textjobsource) String() string {
return string(e)
}

View file

@ -0,0 +1,49 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import "errors"
type Textjobtype string
const (
Textjobtype_ReportConfirmation Textjobtype = "report-confirmation"
Textjobtype_ReportMessage Textjobtype = "report-message"
)
var TextjobtypeAllValues = []Textjobtype{
Textjobtype_ReportConfirmation,
Textjobtype_ReportMessage,
}
func (e *Textjobtype) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "report-confirmation":
*e = Textjobtype_ReportConfirmation
case "report-message":
*e = Textjobtype_ReportMessage
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for Textjobtype enum")
}
return nil
}
func (e Textjobtype) String() string {
return string(e)
}

View file

@ -0,0 +1,65 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import "errors"
type Textorigin string
const (
Textorigin_District Textorigin = "district"
Textorigin_Llm Textorigin = "llm"
Textorigin_WebsiteAction Textorigin = "website-action"
Textorigin_Customer Textorigin = "customer"
Textorigin_Reiteration Textorigin = "reiteration"
Textorigin_CommandResponse Textorigin = "command-response"
)
var TextoriginAllValues = []Textorigin{
Textorigin_District,
Textorigin_Llm,
Textorigin_WebsiteAction,
Textorigin_Customer,
Textorigin_Reiteration,
Textorigin_CommandResponse,
}
func (e *Textorigin) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "district":
*e = Textorigin_District
case "llm":
*e = Textorigin_Llm
case "website-action":
*e = Textorigin_WebsiteAction
case "customer":
*e = Textorigin_Customer
case "reiteration":
*e = Textorigin_Reiteration
case "command-response":
*e = Textorigin_CommandResponse
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for Textorigin enum")
}
return nil
}
func (e Textorigin) String() string {
return string(e)
}

View file

@ -0,0 +1,87 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var EmailContact = newEmailContactTable("comms", "email_contact", "")
type emailContactTable struct {
postgres.Table
// Columns
Address postgres.ColumnString
Confirmed postgres.ColumnBool
IsSubscribed postgres.ColumnBool
PublicID postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type EmailContactTable struct {
emailContactTable
EXCLUDED emailContactTable
}
// AS creates new EmailContactTable with assigned alias
func (a EmailContactTable) AS(alias string) *EmailContactTable {
return newEmailContactTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new EmailContactTable with assigned schema name
func (a EmailContactTable) FromSchema(schemaName string) *EmailContactTable {
return newEmailContactTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new EmailContactTable with assigned table prefix
func (a EmailContactTable) WithPrefix(prefix string) *EmailContactTable {
return newEmailContactTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new EmailContactTable with assigned table suffix
func (a EmailContactTable) WithSuffix(suffix string) *EmailContactTable {
return newEmailContactTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newEmailContactTable(schemaName, tableName, alias string) *EmailContactTable {
return &EmailContactTable{
emailContactTable: newEmailContactTableImpl(schemaName, tableName, alias),
EXCLUDED: newEmailContactTableImpl("", "excluded", ""),
}
}
func newEmailContactTableImpl(schemaName, tableName, alias string) emailContactTable {
var (
AddressColumn = postgres.StringColumn("address")
ConfirmedColumn = postgres.BoolColumn("confirmed")
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
PublicIDColumn = postgres.StringColumn("public_id")
allColumns = postgres.ColumnList{AddressColumn, ConfirmedColumn, IsSubscribedColumn, PublicIDColumn}
mutableColumns = postgres.ColumnList{ConfirmedColumn, IsSubscribedColumn, PublicIDColumn}
defaultColumns = postgres.ColumnList{}
)
return emailContactTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
Address: AddressColumn,
Confirmed: ConfirmedColumn,
IsSubscribed: IsSubscribedColumn,
PublicID: PublicIDColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -0,0 +1,108 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var EmailLog = newEmailLogTable("comms", "email_log", "")
type emailLogTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
Created postgres.ColumnTimestamp
DeliveryStatus postgres.ColumnString
Destination postgres.ColumnString
PublicID postgres.ColumnString
SentAt postgres.ColumnTimestamp
Source postgres.ColumnString
Subject postgres.ColumnString
TemplateID postgres.ColumnInteger
TemplateData postgres.ColumnString
Type postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type EmailLogTable struct {
emailLogTable
EXCLUDED emailLogTable
}
// AS creates new EmailLogTable with assigned alias
func (a EmailLogTable) AS(alias string) *EmailLogTable {
return newEmailLogTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new EmailLogTable with assigned schema name
func (a EmailLogTable) FromSchema(schemaName string) *EmailLogTable {
return newEmailLogTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new EmailLogTable with assigned table prefix
func (a EmailLogTable) WithPrefix(prefix string) *EmailLogTable {
return newEmailLogTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new EmailLogTable with assigned table suffix
func (a EmailLogTable) WithSuffix(suffix string) *EmailLogTable {
return newEmailLogTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newEmailLogTable(schemaName, tableName, alias string) *EmailLogTable {
return &EmailLogTable{
emailLogTable: newEmailLogTableImpl(schemaName, tableName, alias),
EXCLUDED: newEmailLogTableImpl("", "excluded", ""),
}
}
func newEmailLogTableImpl(schemaName, tableName, alias string) emailLogTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedColumn = postgres.TimestampColumn("created")
DeliveryStatusColumn = postgres.StringColumn("delivery_status")
DestinationColumn = postgres.StringColumn("destination")
PublicIDColumn = postgres.StringColumn("public_id")
SentAtColumn = postgres.TimestampColumn("sent_at")
SourceColumn = postgres.StringColumn("source")
SubjectColumn = postgres.StringColumn("subject")
TemplateIDColumn = postgres.IntegerColumn("template_id")
TemplateDataColumn = postgres.StringColumn("template_data")
TypeColumn = postgres.StringColumn("type")
allColumns = postgres.ColumnList{IDColumn, CreatedColumn, DeliveryStatusColumn, DestinationColumn, PublicIDColumn, SentAtColumn, SourceColumn, SubjectColumn, TemplateIDColumn, TemplateDataColumn, TypeColumn}
mutableColumns = postgres.ColumnList{CreatedColumn, DeliveryStatusColumn, DestinationColumn, PublicIDColumn, SentAtColumn, SourceColumn, SubjectColumn, TemplateIDColumn, TemplateDataColumn, TypeColumn}
defaultColumns = postgres.ColumnList{IDColumn}
)
return emailLogTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
Created: CreatedColumn,
DeliveryStatus: DeliveryStatusColumn,
Destination: DestinationColumn,
PublicID: PublicIDColumn,
SentAt: SentAtColumn,
Source: SourceColumn,
Subject: SubjectColumn,
TemplateID: TemplateIDColumn,
TemplateData: TemplateDataColumn,
Type: TypeColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -0,0 +1,99 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var EmailTemplate = newEmailTemplateTable("comms", "email_template", "")
type emailTemplateTable struct {
postgres.Table
// Columns
ContentHTML postgres.ColumnString
ContentTxt postgres.ColumnString
ContentHashHTML postgres.ColumnString
ContentHashTxt postgres.ColumnString
Created postgres.ColumnTimestamp
ID postgres.ColumnInteger
Superceded postgres.ColumnTimestamp
MessageType postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type EmailTemplateTable struct {
emailTemplateTable
EXCLUDED emailTemplateTable
}
// AS creates new EmailTemplateTable with assigned alias
func (a EmailTemplateTable) AS(alias string) *EmailTemplateTable {
return newEmailTemplateTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new EmailTemplateTable with assigned schema name
func (a EmailTemplateTable) FromSchema(schemaName string) *EmailTemplateTable {
return newEmailTemplateTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new EmailTemplateTable with assigned table prefix
func (a EmailTemplateTable) WithPrefix(prefix string) *EmailTemplateTable {
return newEmailTemplateTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new EmailTemplateTable with assigned table suffix
func (a EmailTemplateTable) WithSuffix(suffix string) *EmailTemplateTable {
return newEmailTemplateTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newEmailTemplateTable(schemaName, tableName, alias string) *EmailTemplateTable {
return &EmailTemplateTable{
emailTemplateTable: newEmailTemplateTableImpl(schemaName, tableName, alias),
EXCLUDED: newEmailTemplateTableImpl("", "excluded", ""),
}
}
func newEmailTemplateTableImpl(schemaName, tableName, alias string) emailTemplateTable {
var (
ContentHTMLColumn = postgres.StringColumn("content_html")
ContentTxtColumn = postgres.StringColumn("content_txt")
ContentHashHTMLColumn = postgres.StringColumn("content_hash_html")
ContentHashTxtColumn = postgres.StringColumn("content_hash_txt")
CreatedColumn = postgres.TimestampColumn("created")
IDColumn = postgres.IntegerColumn("id")
SupercededColumn = postgres.TimestampColumn("superceded")
MessageTypeColumn = postgres.StringColumn("message_type")
allColumns = postgres.ColumnList{ContentHTMLColumn, ContentTxtColumn, ContentHashHTMLColumn, ContentHashTxtColumn, CreatedColumn, IDColumn, SupercededColumn, MessageTypeColumn}
mutableColumns = postgres.ColumnList{ContentHTMLColumn, ContentTxtColumn, ContentHashHTMLColumn, ContentHashTxtColumn, CreatedColumn, SupercededColumn, MessageTypeColumn}
defaultColumns = postgres.ColumnList{IDColumn}
)
return emailTemplateTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ContentHTML: ContentHTMLColumn,
ContentTxt: ContentTxtColumn,
ContentHashHTML: ContentHashHTMLColumn,
ContentHashTxt: ContentHashTxtColumn,
Created: CreatedColumn,
ID: IDColumn,
Superceded: SupercededColumn,
MessageType: MessageTypeColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -0,0 +1,93 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var Mailer = newMailerTable("comms", "mailer", "")
type mailerTable struct {
postgres.Table
// Columns
AddressID postgres.ColumnInteger
Created postgres.ColumnTimestamp
ID postgres.ColumnInteger
Recipient postgres.ColumnString
UUID postgres.ColumnString
ExternalID postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type MailerTable struct {
mailerTable
EXCLUDED mailerTable
}
// AS creates new MailerTable with assigned alias
func (a MailerTable) AS(alias string) *MailerTable {
return newMailerTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new MailerTable with assigned schema name
func (a MailerTable) FromSchema(schemaName string) *MailerTable {
return newMailerTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new MailerTable with assigned table prefix
func (a MailerTable) WithPrefix(prefix string) *MailerTable {
return newMailerTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new MailerTable with assigned table suffix
func (a MailerTable) WithSuffix(suffix string) *MailerTable {
return newMailerTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newMailerTable(schemaName, tableName, alias string) *MailerTable {
return &MailerTable{
mailerTable: newMailerTableImpl(schemaName, tableName, alias),
EXCLUDED: newMailerTableImpl("", "excluded", ""),
}
}
func newMailerTableImpl(schemaName, tableName, alias string) mailerTable {
var (
AddressIDColumn = postgres.IntegerColumn("address_id")
CreatedColumn = postgres.TimestampColumn("created")
IDColumn = postgres.IntegerColumn("id")
RecipientColumn = postgres.StringColumn("recipient")
UUIDColumn = postgres.StringColumn("uuid")
ExternalIDColumn = postgres.StringColumn("external_id")
allColumns = postgres.ColumnList{AddressIDColumn, CreatedColumn, IDColumn, RecipientColumn, UUIDColumn, ExternalIDColumn}
mutableColumns = postgres.ColumnList{AddressIDColumn, CreatedColumn, RecipientColumn, UUIDColumn, ExternalIDColumn}
defaultColumns = postgres.ColumnList{IDColumn}
)
return mailerTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
AddressID: AddressIDColumn,
Created: CreatedColumn,
ID: IDColumn,
Recipient: RecipientColumn,
UUID: UUIDColumn,
ExternalID: ExternalIDColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -0,0 +1,87 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var Phone = newPhoneTable("comms", "phone", "")
type phoneTable struct {
postgres.Table
// Columns
E164 postgres.ColumnString
IsSubscribed postgres.ColumnBool
Status postgres.ColumnString
CanSms postgres.ColumnBool
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type PhoneTable struct {
phoneTable
EXCLUDED phoneTable
}
// AS creates new PhoneTable with assigned alias
func (a PhoneTable) AS(alias string) *PhoneTable {
return newPhoneTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new PhoneTable with assigned schema name
func (a PhoneTable) FromSchema(schemaName string) *PhoneTable {
return newPhoneTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new PhoneTable with assigned table prefix
func (a PhoneTable) WithPrefix(prefix string) *PhoneTable {
return newPhoneTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new PhoneTable with assigned table suffix
func (a PhoneTable) WithSuffix(suffix string) *PhoneTable {
return newPhoneTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newPhoneTable(schemaName, tableName, alias string) *PhoneTable {
return &PhoneTable{
phoneTable: newPhoneTableImpl(schemaName, tableName, alias),
EXCLUDED: newPhoneTableImpl("", "excluded", ""),
}
}
func newPhoneTableImpl(schemaName, tableName, alias string) phoneTable {
var (
E164Column = postgres.StringColumn("e164")
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
StatusColumn = postgres.StringColumn("status")
CanSmsColumn = postgres.BoolColumn("can_sms")
allColumns = postgres.ColumnList{E164Column, IsSubscribedColumn, StatusColumn, CanSmsColumn}
mutableColumns = postgres.ColumnList{IsSubscribedColumn, StatusColumn, CanSmsColumn}
defaultColumns = postgres.ColumnList{}
)
return phoneTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
E164: E164Column,
IsSubscribed: IsSubscribedColumn,
Status: StatusColumn,
CanSms: CanSmsColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -0,0 +1,20 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
// UseSchema sets a new schema name for all generated table SQL builder types. It is recommended to invoke
// this method only once at the beginning of the program.
func UseSchema(schema string) {
EmailContact = EmailContact.FromSchema(schema)
EmailLog = EmailLog.FromSchema(schema)
EmailTemplate = EmailTemplate.FromSchema(schema)
Mailer = Mailer.FromSchema(schema)
Phone = Phone.FromSchema(schema)
TextJob = TextJob.FromSchema(schema)
TextLog = TextLog.FromSchema(schema)
}

View file

@ -0,0 +1,103 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var TextJob = newTextJobTable("comms", "text_job", "")
// Used to track text messages that should be sent later
type textJobTable struct {
postgres.Table
// Columns
Content postgres.ColumnString
Created postgres.ColumnTimestamp
Destination postgres.ColumnString
ID postgres.ColumnInteger
Type postgres.ColumnString
Source postgres.ColumnString
Completed postgres.ColumnTimestamp
CreatorID postgres.ColumnInteger
ReportID postgres.ColumnInteger
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type TextJobTable struct {
textJobTable
EXCLUDED textJobTable
}
// AS creates new TextJobTable with assigned alias
func (a TextJobTable) AS(alias string) *TextJobTable {
return newTextJobTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new TextJobTable with assigned schema name
func (a TextJobTable) FromSchema(schemaName string) *TextJobTable {
return newTextJobTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new TextJobTable with assigned table prefix
func (a TextJobTable) WithPrefix(prefix string) *TextJobTable {
return newTextJobTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new TextJobTable with assigned table suffix
func (a TextJobTable) WithSuffix(suffix string) *TextJobTable {
return newTextJobTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newTextJobTable(schemaName, tableName, alias string) *TextJobTable {
return &TextJobTable{
textJobTable: newTextJobTableImpl(schemaName, tableName, alias),
EXCLUDED: newTextJobTableImpl("", "excluded", ""),
}
}
func newTextJobTableImpl(schemaName, tableName, alias string) textJobTable {
var (
ContentColumn = postgres.StringColumn("content")
CreatedColumn = postgres.TimestampColumn("created")
DestinationColumn = postgres.StringColumn("destination")
IDColumn = postgres.IntegerColumn("id")
TypeColumn = postgres.StringColumn("type_")
SourceColumn = postgres.StringColumn("source")
CompletedColumn = postgres.TimestampColumn("completed")
CreatorIDColumn = postgres.IntegerColumn("creator_id")
ReportIDColumn = postgres.IntegerColumn("report_id")
allColumns = postgres.ColumnList{ContentColumn, CreatedColumn, DestinationColumn, IDColumn, TypeColumn, SourceColumn, CompletedColumn, CreatorIDColumn, ReportIDColumn}
mutableColumns = postgres.ColumnList{ContentColumn, CreatedColumn, DestinationColumn, TypeColumn, SourceColumn, CompletedColumn, CreatorIDColumn, ReportIDColumn}
defaultColumns = postgres.ColumnList{IDColumn}
)
return textJobTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
Content: ContentColumn,
Created: CreatedColumn,
Destination: DestinationColumn,
ID: IDColumn,
Type: TypeColumn,
Source: SourceColumn,
Completed: CompletedColumn,
CreatorID: CreatorIDColumn,
ReportID: ReportIDColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -0,0 +1,106 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/Gleipnir-Technology/jet/postgres"
)
var TextLog = newTextLogTable("comms", "text_log", "")
// Used to track text messages that were sent.
type textLogTable struct {
postgres.Table
// Columns
Content postgres.ColumnString
Created postgres.ColumnTimestamp
Destination postgres.ColumnString
ID postgres.ColumnInteger
IsWelcome postgres.ColumnBool
Origin postgres.ColumnString
Source postgres.ColumnString
TwilioSid postgres.ColumnString
TwilioStatus postgres.ColumnString
IsVisibleToLlm postgres.ColumnBool
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
DefaultColumns postgres.ColumnList
}
type TextLogTable struct {
textLogTable
EXCLUDED textLogTable
}
// AS creates new TextLogTable with assigned alias
func (a TextLogTable) AS(alias string) *TextLogTable {
return newTextLogTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new TextLogTable with assigned schema name
func (a TextLogTable) FromSchema(schemaName string) *TextLogTable {
return newTextLogTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new TextLogTable with assigned table prefix
func (a TextLogTable) WithPrefix(prefix string) *TextLogTable {
return newTextLogTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new TextLogTable with assigned table suffix
func (a TextLogTable) WithSuffix(suffix string) *TextLogTable {
return newTextLogTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newTextLogTable(schemaName, tableName, alias string) *TextLogTable {
return &TextLogTable{
textLogTable: newTextLogTableImpl(schemaName, tableName, alias),
EXCLUDED: newTextLogTableImpl("", "excluded", ""),
}
}
func newTextLogTableImpl(schemaName, tableName, alias string) textLogTable {
var (
ContentColumn = postgres.StringColumn("content")
CreatedColumn = postgres.TimestampColumn("created")
DestinationColumn = postgres.StringColumn("destination")
IDColumn = postgres.IntegerColumn("id")
IsWelcomeColumn = postgres.BoolColumn("is_welcome")
OriginColumn = postgres.StringColumn("origin")
SourceColumn = postgres.StringColumn("source")
TwilioSidColumn = postgres.StringColumn("twilio_sid")
TwilioStatusColumn = postgres.StringColumn("twilio_status")
IsVisibleToLlmColumn = postgres.BoolColumn("is_visible_to_llm")
allColumns = postgres.ColumnList{ContentColumn, CreatedColumn, DestinationColumn, IDColumn, IsWelcomeColumn, OriginColumn, SourceColumn, TwilioSidColumn, TwilioStatusColumn, IsVisibleToLlmColumn}
mutableColumns = postgres.ColumnList{ContentColumn, CreatedColumn, DestinationColumn, IsWelcomeColumn, OriginColumn, SourceColumn, TwilioSidColumn, TwilioStatusColumn, IsVisibleToLlmColumn}
defaultColumns = postgres.ColumnList{IDColumn}
)
return textLogTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
Content: ContentColumn,
Created: CreatedColumn,
Destination: DestinationColumn,
ID: IDColumn,
IsWelcome: IsWelcomeColumn,
Origin: OriginColumn,
Source: SourceColumn,
TwilioSid: TwilioSidColumn,
TwilioStatus: TwilioStatusColumn,
IsVisibleToLlm: IsVisibleToLlmColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
DefaultColumns: defaultColumns,
}
}

View file

@ -15,6 +15,7 @@ import (
var schemas []string = []string{ var schemas []string = []string{
"arcgis", "arcgis",
"comms",
"public", "public",
"publicreport", "publicreport",
"stadia", "stadia",

View file

@ -0,0 +1,53 @@
package comms
import (
"context"
//"github.com/Gleipnir-Technology/bob"
"github.com/Gleipnir-Technology/nidus-sync/db"
//"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/enum"
"github.com/Gleipnir-Technology/jet/postgres"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/model"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/table"
)
/*
func CommunicationInsert(ctx context.Context, txn db.Tx, m model.Communication) (model.Communication, error) {
statement := table.Communication.INSERT(table.Communication.MutableColumns).
MODEL(m).
RETURNING(table.Communication.AllColumns)
return db.ExecuteOneTx[model.Communication](ctx, txn, statement)
}
func CommunicationFromID(ctx context.Context, comm_id int64) (model.Communication, error) {
statement := table.Communication.SELECT(
table.Communication.AllColumns,
).FROM(table.Communication).
WHERE(table.Communication.ID.EQ(postgres.Int(comm_id)))
return db.ExecuteOne[model.Communication](ctx, statement)
}
func CommunicationsFromOrganization(ctx context.Context, org_id int64) ([]model.Communication, error) {
statement := table.Communication.SELECT(
table.Communication.AllColumns,
).FROM(table.Communication).
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id))).
ORDER_BY(table.Communication.Created.DESC())
return db.ExecuteMany[model.Communication](ctx, statement)
}
func CommunicationSetStatus(ctx context.Context, txn db.Tx, org_id int64, comm_id int64, status model.Communicationstatus) error {
statement := table.Communication.UPDATE().
SET(
table.Communication.Status.SET(postgres.NewEnumValue(status.String())),
).
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)).AND(
table.Communication.ID.EQ(postgres.Int(comm_id))))
return db.ExecuteNoneTx(ctx, txn, statement)
}
*/
func EmailLogFromID(ctx context.Context, id int64) (model.EmailLog, error) {
statement := table.EmailLog.SELECT(
table.EmailLog.AllColumns,
).FROM(table.EmailLog).
WHERE(table.EmailLog.ID.EQ(postgres.Int(id)))
return db.ExecuteOne[model.EmailLog](ctx, statement)
}

View file

@ -0,0 +1,18 @@
package comms
import (
"context"
"github.com/Gleipnir-Technology/jet/postgres"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/model"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/table"
)
func TextLogFromID(ctx context.Context, id int64) (model.TextLog, error) {
statement := table.TextLog.SELECT(
table.TextLog.AllColumns,
).FROM(table.TextLog).
WHERE(table.TextLog.ID.EQ(postgres.Int(id)))
return db.ExecuteOne[model.TextLog](ctx, statement)
}

6
go.mod
View file

@ -6,6 +6,7 @@ require (
github.com/Gleipnir-Technology/arcgis-go v0.0.12 github.com/Gleipnir-Technology/arcgis-go v0.0.12
github.com/Gleipnir-Technology/bob v0.42.5 github.com/Gleipnir-Technology/bob v0.42.5
github.com/Gleipnir-Technology/go-geojson2h3/v2 v2.0.0 github.com/Gleipnir-Technology/go-geojson2h3/v2 v2.0.0
github.com/Gleipnir-Technology/jet v0.0.0-20260509014340-4474319e732c
github.com/aarondl/opt v0.0.0-20250607033636-982744e1bd65 github.com/aarondl/opt v0.0.0-20250607033636-982744e1bd65
github.com/alexedwards/scs/pgxstore v0.0.0-20251002162104-209de6e426de github.com/alexedwards/scs/pgxstore v0.0.0-20251002162104-209de6e426de
github.com/alexedwards/scs/v2 v2.9.0 github.com/alexedwards/scs/v2 v2.9.0
@ -16,7 +17,6 @@ require (
github.com/disintegration/imaging v1.6.2 github.com/disintegration/imaging v1.6.2
github.com/getsentry/sentry-go v0.42.0 github.com/getsentry/sentry-go v0.42.0
github.com/getsentry/sentry-go/zerolog v0.42.0 github.com/getsentry/sentry-go/zerolog v0.42.0
github.com/go-jet/jet/v2 v2.14.1
github.com/google/go-querystring v1.2.0 github.com/google/go-querystring v1.2.0
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1 github.com/gorilla/mux v1.8.1
@ -45,7 +45,6 @@ require (
) )
require ( require (
github.com/Gleipnir-Technology/jet v0.0.0-20260509014340-4474319e732c // indirect
github.com/andybalholm/brotli v1.2.0 // indirect github.com/andybalholm/brotli v1.2.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beevik/etree v1.1.0 // indirect github.com/beevik/etree v1.1.0 // indirect
@ -65,6 +64,7 @@ require (
github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgtype v1.14.4 // indirect github.com/jackc/pgtype v1.14.4 // indirect
github.com/jackc/pgx/v4 v4.18.3 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/klauspost/compress v1.18.2 // indirect github.com/klauspost/compress v1.18.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect github.com/klauspost/cpuid/v2 v2.2.11 // indirect
@ -107,4 +107,4 @@ require (
// replace github.com/stephenafamo/bob v0.42.0 => ../bob // replace github.com/stephenafamo/bob v0.42.0 => ../bob
// replace github.com/Gleipnir-Technology/arcgis-go v0.0.12 => ./arcgis-go // replace github.com/Gleipnir-Technology/arcgis-go v0.0.12 => ./arcgis-go
replace github.com/go-jet/jet/v2 v2.14.1 => ../jet // replace github.com/go-jet/jet/v2 v2.14.1 => ../jet

3
go.sum
View file

@ -181,8 +181,9 @@ github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU=
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA=
github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk= github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk=
github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M=

View file

@ -8,12 +8,49 @@ import (
"github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model" "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model"
querycomms "github.com/Gleipnir-Technology/nidus-sync/db/query/comms"
querypublic "github.com/Gleipnir-Technology/nidus-sync/db/query/public" querypublic "github.com/Gleipnir-Technology/nidus-sync/db/query/public"
querypublicreport "github.com/Gleipnir-Technology/nidus-sync/db/query/publicreport"
"github.com/Gleipnir-Technology/nidus-sync/lint" "github.com/Gleipnir-Technology/nidus-sync/lint"
"github.com/Gleipnir-Technology/nidus-sync/platform/event" "github.com/Gleipnir-Technology/nidus-sync/platform/event"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
type RelatedRecord struct {
ID int32
Type string
}
func CommunicationRelatedRecords(ctx context.Context, user User, comm *model.Communication) ([]RelatedRecord, error) {
// Gather associated records
// * address
// * phone number
// * email
// * name
result := make([]RelatedRecord, 0)
if comm.SourceEmailLogID != nil {
email_log, err := querycomms.EmailLogFromID(ctx, int64(*comm.SourceEmailLogID))
if err != nil {
return result, fmt.Errorf("email log from ID: %w", err)
}
log.Debug().Int32("id", email_log.ID).Send()
}
if comm.SourceTextLogID != nil {
text_log, err := querycomms.TextLogFromID(ctx, int64(*comm.SourceTextLogID))
if err != nil {
return result, fmt.Errorf("text log from ID: %w", err)
}
log.Debug().Int32("id", text_log.ID).Send()
}
if comm.SourceReportID != nil {
report, err := querypublicreport.ReportFromID(ctx, int64(*comm.SourceReportID))
if err != nil {
return result, fmt.Errorf("report from ID: %w", err)
}
log.Debug().Int32("id", report.ID).Send()
}
return result, nil
}
func CommunicationsForOrganization(ctx context.Context, org_id int64) ([]model.Communication, error) { func CommunicationsForOrganization(ctx context.Context, org_id int64) ([]model.Communication, error) {
return querypublic.CommunicationsFromOrganization(ctx, org_id) return querypublic.CommunicationsFromOrganization(ctx, org_id)
} }