forked from hasadna/meirim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_emails.js
More file actions
74 lines (63 loc) · 2.19 KB
/
Copy pathtest_emails.js
File metadata and controls
74 lines (63 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
const yargs = require('yargs/yargs');
const Alert = require('../api/model/alert');
const Person = require('../api/model/person');
const Plan = require('../api/model/plan');
const TreePermit = require('../api/model/tree_permit');
const emailService = require('../api/service/email');
const { fetchStaticMap } = require('../api/service/staticmap');
const argv = yargs(process.argv.slice(2))
.usage('Usage: $0 <email>')
.version(false)
.demandCommand(1)
.argv;
const email = argv._[0];
emailService.init().then(() => {
const person = new Person({ id: 1, email });
// user signed up
emailService.newSignUp(person);
// user saved a new plan alert
emailService.newAlert(person.toJSON(), new Alert({ type: 'plan', address: 'כתובת פיקטיבית', radius: '5' }));
// user saved a new tree alert
emailService.newAlert(person.toJSON(), new Alert({ type: 'tree', place: 'מקום פיקטיבי' }));
fetchStaticMap(32.817153, 35.0005748).then((staticMap) => {
// a new plan was crawled and it matches a user's plan alert
emailService.newPlanAlert(
{ email, alert_id: 1, person_id: 1 },
new Plan({
id: 1,
jurisdiction: 'מקומית',
goals_from_mavat: 'שינוי קו בניין פיקטיבי',
main_details_from_mavat: 'שינוי קו בניין בהתאם לפיקציה',
data: {
DEPOSITING_DATE: '2021-04-21T12:00:00',
PLAN_COUNTY_NAME: 'חיפה',
PL_NUMBER: '000-0000000',
PL_NAME: 'שם פיקטיבי',
STATION_DESC: 'בהליך אישור',
ENTITY_SUBTYPE_DESC: 'תכנית מפורטת',
PL_LANDUSE_STRING: 'מגורים מסחר ותיירות,שטח ציבורי פתוח'
}
}),
staticMap
);
// a new tree permit was crawled and it matches a user's tree alert
emailService.treeAlert(
{ email, alert_id: 1, person_id: 1 },
new TreePermit({
id: 1,
action: 'כריתה',
place: 'חיפה',
street: 'דרך העצמאות',
street_number: 1,
total_trees: 5,
reason_short: 'בניה',
reason_detailed: 'בניה פיקטיבית',
start_date: new Date(2021, 4, 21)
}),
staticMap
);
});
// user forgot password
emailService.resetPasswordToken(person);
});