Skip to content

Commit fd98424

Browse files
add opt_in model
1 parent 46ac8b6 commit fd98424

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/server/models/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import CampaignContact from "./campaign-contact";
1111
import InteractionStep from "./interaction-step";
1212
import QuestionResponse from "./question-response";
1313
import OptOut from "./opt-out";
14+
import OptIn from "./opt-in";
1415
import JobRequest from "./job-request";
1516
import Invite from "./invite";
1617
import CannedResponse from "./canned-response";
@@ -64,6 +65,7 @@ const tableList = [
6465
"log",
6566
"message",
6667
"opt_out", // good candidate
68+
"opt_in",
6769
"pending_message_part",
6870
"question_response",
6971
"tag",
@@ -131,6 +133,7 @@ const createLoaders = () => ({
131133
jobRequest: createLoader(JobRequest),
132134
message: createLoader(Message),
133135
optOut: createLoader(OptOut),
136+
optIn: createLoader(OptIn),
134137
pendingMessagePart: createLoader(PendingMessagePart),
135138
questionResponse: createLoader(QuestionResponse),
136139
userCell: createLoader(UserCell),
@@ -165,6 +168,7 @@ export {
165168
JobRequest,
166169
Message,
167170
OptOut,
171+
OptIn,
168172
Organization,
169173
PendingMessagePart,
170174
CannedResponse,

src/server/models/opt-in.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import thinky from "./thinky";
2+
const type = thinky.type;
3+
import { optionalString, requiredString, timestamp } from "./custom-types";
4+
5+
import Organization from "./organization";
6+
import Assignment from "./assignment";
7+
8+
const OptIn = thinky.createModel(
9+
"opt_in",
10+
type
11+
.object()
12+
.schema({
13+
id: type.string(),
14+
cell: requiredString(),
15+
assignment_id: optionalString(),
16+
organization_id: requiredString(),
17+
reason_code: optionalString(),
18+
created_at: timestamp()
19+
})
20+
.allowExtra(false),
21+
{ noAutoCreation: true, dependencies: [Organization, Assignment] }
22+
);
23+
24+
OptIn.ensureIndex("cell");
25+
OptIn.ensureIndex("assignment_id");
26+
OptIn.ensureIndex("organization_id");
27+
28+
export default OptIn;

0 commit comments

Comments
 (0)