@@ -52,21 +52,25 @@ type Contact struct {
52
52
CreatedOn_ time.Time `db:"created_on"`
53
53
ModifiedOn_ time.Time `db:"modified_on"`
54
54
55
+ CreatedBy_ int `db:"created_by_id"`
56
+ ModifiedBy_ int `db:"modified_by_id"`
57
+
55
58
IsNew_ bool
56
59
}
57
60
58
61
// UUID returns the UUID for this contact
59
62
func (c * Contact ) UUID () courier.ContactUUID { return c .UUID_ }
60
63
61
- const sqlInsertContact = `
64
+ const insertContactSQL = `
62
65
INSERT INTO
63
- contacts_contact( org_id, is_active, status, uuid, created_on, modified_on, name, ticket_count)
64
- VALUES(:org_id, TRUE, 'A', :uuid, :created_on, :modified_on, :name, 0)
65
- RETURNING id`
66
+ contacts_contact(org_id, is_active, status, uuid, created_on, modified_on, created_by_id, modified_by_id, name, ticket_count)
67
+ VALUES(:org_id, TRUE, 'A', :uuid, :created_on, :modified_on, :created_by_id, :modified_by_id, :name, 0)
68
+ RETURNING id
69
+ `
66
70
67
71
// insertContact inserts the passed in contact, the id field will be populated with the result on success
68
72
func insertContact (tx * sqlx.Tx , contact * Contact ) error {
69
- rows , err := tx .NamedQuery (sqlInsertContact , contact )
73
+ rows , err := tx .NamedQuery (insertContactSQL , contact )
70
74
if err != nil {
71
75
return err
72
76
}
@@ -162,6 +166,10 @@ func contactForURN(ctx context.Context, b *backend, org OrgID, channel *Channel,
162
166
}
163
167
}
164
168
169
+ // TODO: Set these to a system user
170
+ contact .CreatedBy_ = 1
171
+ contact .ModifiedBy_ = 1
172
+
165
173
// insert it
166
174
tx , err := b .db .BeginTxx (ctx , nil )
167
175
if err != nil {
0 commit comments