Switch to prefixed IDs and tell agents which Mac a message came from
This commit is contained in:
@@ -25,6 +25,7 @@ type LeadInput struct {
|
||||
Text string
|
||||
Images []string
|
||||
SendID string
|
||||
Client string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
@@ -34,14 +35,14 @@ func (s *Store) AddLeadInput(ctx context.Context, in LeadInput) error {
|
||||
return err
|
||||
}
|
||||
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
|
||||
_, err := tx.ExecContext(ctx, `INSERT INTO lead_inputs (owner, kind, actor, text, images, send_id, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
in.Owner, string(in.Kind), in.Actor, in.Text, string(images), in.SendID, now())
|
||||
_, err := tx.ExecContext(ctx, `INSERT INTO lead_inputs (owner, kind, actor, text, images, send_id, client_id, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
in.Owner, string(in.Kind), in.Actor, in.Text, string(images), in.SendID, in.Client, now())
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Store) LeadInputs(ctx context.Context, owner string) ([]LeadInput, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT id, owner, kind, actor, text, images, send_id, created_at FROM lead_inputs WHERE owner = ? ORDER BY id`, owner)
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT id, owner, kind, actor, text, images, send_id, client_id, created_at FROM lead_inputs WHERE owner = ? ORDER BY id`, owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -53,7 +54,7 @@ func (s *Store) LeadInputs(ctx context.Context, owner string) ([]LeadInput, erro
|
||||
kind := ""
|
||||
images := ""
|
||||
createdAt := ""
|
||||
err = rows.Scan(&in.ID, &in.Owner, &kind, &in.Actor, &in.Text, &images, &in.SendID, &createdAt)
|
||||
err = rows.Scan(&in.ID, &in.Owner, &kind, &in.Actor, &in.Text, &images, &in.SendID, &in.Client, &createdAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -78,8 +79,8 @@ func (s *Store) RestoreLeadInputs(ctx context.Context, inputs []LeadInput) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO lead_inputs (id, owner, kind, actor, text, images, send_id, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
in.ID, in.Owner, string(in.Kind), in.Actor, in.Text, string(images), in.SendID, formatTime(in.CreatedAt))
|
||||
_, err = tx.ExecContext(ctx, `INSERT INTO lead_inputs (id, owner, kind, actor, text, images, send_id, client_id, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
in.ID, in.Owner, string(in.Kind), in.Actor, in.Text, string(images), in.SendID, in.Client, formatTime(in.CreatedAt))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user