-
Notifications
You must be signed in to change notification settings - Fork 26
/
telegram.install
245 lines (240 loc) · 7.4 KB
/
telegram.install
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
/**
* @file
* Install, update and uninstall functions for the telegram module.
*
*/
/**
* Implements hook_schema().
*/
function telegram_schema() {
$schema['telegram_contact'] = array(
'description' => "Stores information on specific Telegram contact.",
'fields' => array(
'oid' => array(
'description' => 'The primary internal identifier for a contact.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'idcontact' => array(
'description' => "The unique Telegram identifier of the {telegram_contact}.",
'type' => 'varchar',
'length' => 255,
'default' => '',
'not null' => FALSE,
),
'phone' => array(
'description' => "The unique phone number of the {telegram_contact} user.",
'type' => 'varchar',
'length' => 255,
),
'peer' => array(
'description' => "The unique peer name of the {telegram_contact} user.",
'type' => 'varchar',
'default' => '',
'length' => 255,
),
'name' => array(
'description' => "The full name of the {telegram_contact} user.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'source' => array(
'description' => "The source of the telegram contact (telegram, created, message).",
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => 'telegram',
),
'uid' => array(
'description' => "The Drupal uid of the user who owns this Telegram account.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'verification' => array(
'description' => "The verification code sent to the contact.",
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => 'telegram',
),
'verified' => array(
'description' => "Indicates if a user is verified.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => "A duplicate of {telegram_contact}.created_at in UNIX timestamp format.",
'type' => 'int',
'not null' => TRUE,
),
'updated' => array(
'description' => "A UNIX timestamp marking the date Telegram contacts were last fetched on.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'online' => array(
'description' => "A UNIX timestamp marking the last time the contact was seen online.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array('peer' => array('peer'), 'phone' => array('phone'), 'idcontact' => array('idcontact')),
'primary key' => array('oid'),
);
$schema['telegram_message'] = array(
'description' => "Stores individual Telegram messages.",
'fields' => array(
'oid' => array(
'description' => 'The primary internal identifier for a dialog.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'idmsg' => array(
'description' => "Telegram unique identifier for each {telegram_message}.",
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'idcontact' => array(
'description' => "Telegram unique identifier for each {telegram_contact}.",
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'peer' => array(
'description' => "Name of the {telegram_contact} peer.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'phone' => array(
'description' => "Phone number of the {telegram_contact} peer.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'direction' => array(
'description' => "Message type. Possible values are 'incoming', 'outgoing'",
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'text' => array(
'description' => "The text of the {telegram_message}.",
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
),
'source' => array(
'description' => "The application that created the {telegram_message}.",
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'status' => array(
'description' => "The internal status. Possible values are 0 = done, 1 = queued, 2 = error",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => "A UNIX timestamp indicated when the message was created.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'sent' => array(
'description' => "A UNIX timestamp indicated when the message was sent.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'received' => array(
'description' => "A UNIX timestamp indicated when the message was received.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'updated' => array(
'description' => "A UNIX timestamp marking when this row was updated.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'readtime' => array(
'description' => "A UNIX timestamp marking when the message was read.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array('peer' => array('peer'), 'idmsg' => array('idmsg')),
'primary key' => array('oid'),
);
$schema['telegram_dialog'] = array(
'description' => "Stores individual Telegram messages.",
'fields' => array(
'oid' => array(
'description' => 'The primary internal identifier for a message.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'idcontact' => array(
'description' => "Telegram unique identifier for each {telegram_contact}.",
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'peer' => array(
'description' => "Name of the {telegram_contact} peer.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => "Name of the {telegram_contact}.",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'unread' => array(
'description' => "The number of unread messages",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => "A UNIX timestamp indicated when the message was created.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'updated' => array(
'description' => "A UNIX timestamp marking when this row was updated.",
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('oid'),
);
return $schema;
}