-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemes.js
128 lines (115 loc) · 2.53 KB
/
schemes.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'use strict';
/**
* Created by jonas on 29/05/16.
*/
var Document = require('camo').Document;
var EmbeddedDocument = require('camo').EmbeddedDocument;
/**
* actual template used to construct the message, language parameter should be respected if available
*/
class Template extends EmbeddedDocument {
constructor() {
super();
this.template = {
type: String,
required: true,
validate: function (el) {
return !/(<%(?!(name|real_name|wazename|id|color|tz|profile.email)%>).*?%>)/igm.test(el);
}
};
this.lang = {
type: String,
choices: ["en", "nl", "fr", "de"]
};
}
static collectionName() {
return 'template';
}
}
/**
* container for templates, per destination
* allows a pm to triggering user + message in a public and/or private channel; or any combination thereof
*/
class TypeTemplate extends EmbeddedDocument {
constructor() {
super();
this.usedFor = {
type: String,
required: true,
choices: ["welcomepm", "welcomegeneral", "privategroup"]
}
this.templates = [Template]
}
static collectionName() {
return 'typeTemplate';
}
}
/**
* Base "settings" document, key is linked to (slack) events
*/
class Settings extends Document {
constructor() {
super();
this.name = {
type: String,
unique: true
};
this.key = {
type: [String],
required: true,
// choices: ["team_join","user_typing"],
default: ["team_join"]
}
this.types = [TypeTemplate];
this.createdAt = {
type: Date,
default: Date.now
};
}
static collectionName() {
return 'settings';
}
}
global.Settings = Settings;
/**
* possible User scheme, currently unused (camo had update issues)
*/
class User extends Document {
constructor() {
super();
this.uid = {
type: String,
unique: true
};
this.team_id = String;
this.name = String;
this.lang = {
type: String//,
// choices: ['nl','fr','en','de']
}
this.color = String;
this.real_name = String;
this.tz = String;
this.waze_name = String;
this.email = String;
this.skype = String;
this.image_72 = String;
this.pgw = {
channel: String,
ts: String
};
// this.profile = Profile;
this.is_admin = Boolean;
this.is_owner = Boolean;
this.is_primary_owner = Boolean;
this.is_bot = Boolean;
this.createdAt = {
type: Date,
default: Date.now
};
}
static collectionName() {
return 'user';
}
}
global.User = User;