Browse code

added Conversations page and improved mobile compatibility

DoubleBastionAdmin authored on 02/04/2024 00:47:37
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,572 @@
1
+<?php
2
+/**
3
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
4
+ *
5
+ * @author Double Bastion LLC
6
+ *
7
+ * @license GNU AGPL version 3 or any later version
8
+ *
9
+ * This program is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
11
+ * License as published by the Free Software Foundation; either
12
+ * version 3 of the License, or any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
18
+ *
19
+ * You should have received a copy of the GNU Affero General Public
20
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
+ *
22
+ */
23
+
24
+declare(strict_types=1);
25
+
26
+namespace OCA\SMSRelentless\Migration;
27
+
28
+use Closure;
29
+use OCP\DB\Types;
30
+use OCP\DB\ISchemaWrapper;
31
+use OCP\IDBConnection;
32
+use OCP\Migration\IOutput;
33
+use OCP\Migration\SimpleMigrationStep;
34
+
35
+
36
+class Version134Date20240402032516 extends SimpleMigrationStep {
37
+
38
+        /** @var IDBConnection */
39
+        private $connection;
40
+
41
+        /**
42
+         * @param IDBConnection $connection
43
+         */
44
+        public function __construct(IDBConnection $connection) {
45
+                $this->connection = $connection;
46
+        }
47
+
48
+	/**
49
+	 * @param IOutput $output
50
+	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
51
+	 * @param array $options
52
+	 * @return null|ISchemaWrapper
53
+	 */
54
+	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
55
+		/** @var ISchemaWrapper $schema */
56
+		$schema = $schemaClosure();
57
+
58
+		if (!$schema->hasTable('sms_relent_settings')) {
59
+			$table = $schema->createTable('sms_relent_settings');
60
+			$table->addColumn('id', Types::BIGINT, [
61
+				'autoincrement' => true,
62
+				'notnull' => true,
63
+                                'length' => 11,
64
+                                'unsigned' => true,
65
+			]);
66
+			$table->addColumn('user_id', Types::STRING, [
67
+				'notnull' => true,
68
+				'length' => 128,
69
+			]);
70
+			$table->addColumn('telapi_key', Types::STRING, [
71
+				'notnull' => true,
72
+				'length' => 512,
73
+			]);
74
+			$table->addColumn('tel_pub_key', Types::STRING, [
75
+				'notnull' => true,
76
+				'length' => 512,
77
+			]);
78
+			$table->addColumn('telapi_url_rec', Types::STRING, [
79
+				'notnull' => true,
80
+				'length' => 512,
81
+			]);
82
+			$table->addColumn('telapi_url', Types::STRING, [
83
+				'notnull' => true,
84
+				'length' => 512,
85
+			]);
86
+			$table->addColumn('messaging_profile_id', Types::STRING, [
87
+				'notnull' => true,
88
+				'length' => 512,
89
+			]);
90
+			$table->addColumn('nexapi_key', Types::STRING, [
91
+				'notnull' => true,
92
+				'length' => 512,
93
+			]);
94
+			$table->addColumn('nexapi_secret', Types::STRING, [
95
+				'notnull' => true,
96
+				'length' => 512,
97
+			]);
98
+			$table->addColumn('nexapi_url_rec', Types::STRING, [
99
+				'notnull' => true,
100
+				'length' => 512,
101
+			]);
102
+			$table->addColumn('nexapi_url', Types::STRING, [
103
+				'notnull' => true,
104
+				'length' => 512,
105
+			]);
106
+			$table->addColumn('twilapi_key', Types::STRING, [
107
+				'notnull' => true,
108
+				'length' => 512,
109
+			]);
110
+			$table->addColumn('twilapi_secret', Types::STRING, [
111
+				'notnull' => true,
112
+				'length' => 512,
113
+			]);
114
+			$table->addColumn('twilapi_url_rec', Types::STRING, [
115
+				'notnull' => true,
116
+				'length' => 512,
117
+			]);
118
+			$table->addColumn('twilapi_url', Types::STRING, [
119
+				'notnull' => true,
120
+				'length' => 512,
121
+			]);
122
+			$table->addColumn('flowapi_key', Types::STRING, [
123
+				'notnull' => true,
124
+				'length' => 512,
125
+			]);
126
+			$table->addColumn('flowapi_secret', Types::STRING, [
127
+				'notnull' => true,
128
+				'length' => 512,
129
+			]);
130
+			$table->addColumn('flowapi_url_rec', Types::STRING, [
131
+				'notnull' => true,
132
+				'length' => 512,
133
+			]);
134
+			$table->addColumn('flowapi_url', Types::STRING, [
135
+				'notnull' => true,
136
+				'length' => 512,
137
+			]);
138
+			$table->addColumn('tel_sender_name', Types::STRING, [
139
+				'notnull' => false,
140
+				'length' => 48,
141
+				'default' => '',
142
+			]);
143
+			$table->addColumn('nex_sender_name', Types::STRING, [
144
+				'notnull' => false,
145
+				'length' => 48,
146
+				'default' => '',
147
+			]);
148
+			$table->addColumn('twil_sender_name', Types::STRING, [
149
+				'notnull' => false,
150
+				'length' => 48,
151
+				'default' => '',
152
+			]);
153
+			$table->addColumn('flow_sender_name', Types::STRING, [
154
+				'notnull' => false,
155
+				'length' => 48,
156
+				'default' => '',
157
+			]);
158
+			$table->addColumn('messagesperpage', Types::INTEGER, [
159
+				'notnull' => false,
160
+				'length' => 10,
161
+                                'unsigned' => true,
162
+			]);
163
+			$table->addColumn('get_notify', Types::SMALLINT, [
164
+				'notnull' => false,
165
+				'length' => 1,
166
+			]);
167
+			$table->addColumn('notification_email', Types::STRING, [
168
+				'notnull' => false,
169
+				'length' => 512,
170
+				'default' => '',
171
+			]);
172
+			$table->addColumn('getsmsinemail', Types::SMALLINT, [
173
+				'notnull' => false,
174
+				'length' => 1,
175
+			]);
176
+			$table->addColumn('show_all_messages', Types::SMALLINT, [
177
+				'notnull' => false,
178
+				'length' => 1,
179
+			]);
180
+			$table->addColumn('show_display_names', Types::SMALLINT, [
181
+				'notnull' => false,
182
+				'length' => 1,
183
+			]);
184
+			$table->addColumn('add_display_names', Types::SMALLINT, [
185
+				'notnull' => false,
186
+				'length' => 1,
187
+			]);
188
+			$table->addColumn('available_numbers', Types::TEXT, [
189
+				'notnull' => false,
190
+                                'default' => '',
191
+			]);
192
+			$table->addColumn('msg_check_interval', Types::INTEGER, [
193
+				'notnull' => false,
194
+				'length' => 10,
195
+                                'unsigned' => true,
196
+			]);
197
+			$table->addColumn('new_message_rcd', Types::SMALLINT, [
198
+				'notnull' => false,
199
+				'length' => 1,
200
+			]);
201
+			$table->addColumn('archived_conv_nmbr', Types::INTEGER, [
202
+				'notnull' => false,
203
+				'length' => 10,
204
+                                'unsigned' => true,
205
+			]);
206
+                        $table->setPrimaryKey(['id']);
207
+                        $table->addUniqueIndex(['id']);
208
+
209
+		} else {
210
+
211
+                        $table = $schema->getTable('sms_relent_settings');
212
+
213
+			$table->addColumn('archived_conv_nmbr', Types::INTEGER, [
214
+				'notnull' => false,
215
+				'length' => 10,
216
+                                'unsigned' => true,
217
+			]);
218
+                }
219
+
220
+
221
+		if (!$schema->hasTable('sms_relent_received')) {
222
+			$table = $schema->createTable('sms_relent_received');
223
+			$table->addColumn('id', Types::BIGINT, [
224
+				'autoincrement' => true,
225
+				'notnull' => true,
226
+                                'length' => 11,
227
+                                'unsigned' => true,
228
+			]);
229
+			$table->addColumn('user_id', Types::STRING, [
230
+				'notnull' => true,
231
+				'length' => 64,
232
+			]);
233
+			$table->addColumn('message_id', Types::STRING, [
234
+				'notnull' => true,
235
+				'length' => 512,
236
+			]);
237
+			$table->addColumn('date', Types::DATETIME, [
238
+				'notnull' => true,
239
+			]);
240
+			$table->addColumn('from', Types::STRING, [
241
+				'notnull' => true,
242
+				'length' => 128,
243
+			]);
244
+			$table->addColumn('to', Types::STRING, [
245
+				'notnull' => true,
246
+				'length' => 128,
247
+			]);
248
+			$table->addColumn('message', Types::TEXT, [
249
+				'notnull' => false,
250
+				'default' => '',
251
+			]);
252
+			$table->addColumn('author_displayname', Types::STRING, [
253
+				'notnull' => true,
254
+				'length' => 255,
255
+			]);
256
+			$table->addColumn('internal_sender', Types::SMALLINT, [
257
+				'notnull' => false,
258
+				'length' => 1,
259
+			]);
260
+			$table->addColumn('conversation_id', Types::STRING, [
261
+				'notnull' => false,
262
+				'length' => 255,
263
+			]);
264
+                        $table->setPrimaryKey(['id']);
265
+                        $table->addUniqueIndex(['id']);
266
+
267
+		} else {
268
+
269
+                        $table = $schema->getTable('sms_relent_received');
270
+
271
+			$table->addColumn('conversation_id', Types::STRING, [
272
+				'notnull' => false,
273
+				'length' => 255,
274
+			]);
275
+                }
276
+
277
+
278
+		if (!$schema->hasTable('sms_relent_sent')) {
279
+			$table = $schema->createTable('sms_relent_sent');
280
+			$table->addColumn('id', Types::BIGINT, [
281
+				'autoincrement' => true,
282
+				'notnull' => true,
283
+                                'length' => 11,
284
+                                'unsigned' => true,
285
+			]);
286
+			$table->addColumn('user_id', Types::STRING, [
287
+				'notnull' => true,
288
+				'length' => 64,
289
+			]);
290
+			$table->addColumn('message_id', Types::STRING, [
291
+				'notnull' => true,
292
+				'length' => 512,
293
+			]);
294
+			$table->addColumn('date', Types::DATETIME, [
295
+				'notnull' => true,
296
+			]);
297
+			$table->addColumn('from', Types::STRING, [
298
+				'notnull' => true,
299
+				'length' => 128,
300
+			]);
301
+			$table->addColumn('to', Types::STRING, [
302
+				'notnull' => true,
303
+				'length' => 128,
304
+			]);
305
+			$table->addColumn('network ', Types::STRING, [
306
+				'notnull' => false,
307
+				'length' => 64,
308
+				'default' => '',
309
+			]);
310
+			$table->addColumn('price', Types::STRING, [
311
+				'notnull' => false,
312
+				'length' => 64,
313
+				'default' => '',
314
+			]);
315
+			$table->addColumn('status', Types::STRING, [
316
+				'notnull' => false,
317
+				'length' => 512,
318
+				'default' => '',
319
+			]);
320
+			$table->addColumn('deliveryreceipt', Types::STRING, [
321
+				'notnull' => false,
322
+				'length' => 64,
323
+				'default' => '',
324
+			]);
325
+			$table->addColumn('message', Types::TEXT, [
326
+				'notnull' => false,
327
+                                'default' => '',
328
+			]);
329
+			$table->addColumn('author_displayname', Types::STRING, [
330
+				'notnull' => true,
331
+				'length' => 255,
332
+			]);
333
+			$table->addColumn('conversation_id', Types::STRING, [
334
+				'notnull' => false,
335
+				'length' => 255,
336
+			]);
337
+                        $table->setPrimaryKey(['id']);
338
+                        $table->addUniqueIndex(['id']);
339
+
340
+		} else {
341
+
342
+                        $table = $schema->getTable('sms_relent_sent');
343
+
344
+			$table->addColumn('conversation_id', Types::STRING, [
345
+				'notnull' => false,
346
+				'length' => 255,
347
+			]);
348
+                }
349
+
350
+
351
+		if (!$schema->hasTable('sms_relent_autorply')) {
352
+			$table = $schema->createTable('sms_relent_autorply');
353
+			$table->addColumn('id', Types::BIGINT, [
354
+				'autoincrement' => true,
355
+				'notnull' => true,
356
+                                'length' => 11,
357
+                                'unsigned' => true,
358
+			]);
359
+			$table->addColumn('user_id', Types::STRING, [
360
+				'notnull' => true,
361
+				'length' => 128,
362
+			]);
363
+			$table->addColumn('saved_by_dsplname', Types::STRING, [
364
+				'notnull' => true,
365
+				'length' => 255,
366
+			]);
367
+			$table->addColumn('phone_number', Types::STRING, [
368
+				'notnull' => true,
369
+				'length' => 128,
370
+			]);
371
+			$table->addColumn('days_of_week', Types::STRING, [
372
+				'notnull' => false,
373
+				'length' => 64,
374
+                                'default' => '',
375
+			]);
376
+			$table->addColumn('daily_start', Types::STRING, [
377
+				'notnull' => false,
378
+				'length' => 8,
379
+                                'default' => '',
380
+			]);
381
+			$table->addColumn('daily_end', Types::STRING, [
382
+				'notnull' => false,
383
+				'length' => 8,
384
+                                'default' => '',
385
+			]);
386
+			$table->addColumn('vacation_start', Types::DATETIME, [
387
+				'notnull' => false,
388
+			]);
389
+			$table->addColumn('vacation_end', Types::DATETIME, [
390
+				'notnull' => false,
391
+			]);
392
+			$table->addColumn('message_text', Types::TEXT, [
393
+				'notnull' => false,
394
+                                'default' => '',
395
+			]);
396
+                        $table->setPrimaryKey(['id']);
397
+                        $table->addUniqueIndex(['id']);
398
+		}
399
+
400
+
401
+		if (!$schema->hasTable('sms_relent_restrict')) {
402
+			$table = $schema->createTable('sms_relent_restrict');
403
+			$table->addColumn('id', Types::BIGINT, [
404
+				'autoincrement' => true,
405
+				'notnull' => true,
406
+                                'length' => 11,
407
+                                'unsigned' => true,
408
+			]);
409
+			$table->addColumn('user_id', Types::STRING, [
410
+				'notnull' => true,
411
+				'length' => 128,
412
+			]);
413
+			$table->addColumn('saved_by_dsplname', Types::STRING, [
414
+				'notnull' => true,
415
+				'length' => 255,
416
+			]);
417
+			$table->addColumn('phone_number', Types::STRING, [
418
+				'notnull' => true,
419
+				'length' => 128,
420
+			]);
421
+			$table->addColumn('groups', Types::STRING, [
422
+				'notnull' => true,
423
+				'length' => 2048,
424
+			]);
425
+			$table->addColumn('users', Types::STRING, [
426
+				'notnull' => true,
427
+				'length' => 2048,
428
+			]);
429
+                        $table->setPrimaryKey(['id']);
430
+                        $table->addUniqueIndex(['id']);
431
+		}
432
+
433
+
434
+		if (!$schema->hasTable('sms_relent_subac')) {
435
+			$table = $schema->createTable('sms_relent_subac');
436
+			$table->addColumn('id', Types::BIGINT, [
437
+				'autoincrement' => true,
438
+				'notnull' => true,
439
+                                'length' => 11,
440
+                                'unsigned' => true,
441
+			]);
442
+			$table->addColumn('user_id', Types::STRING, [
443
+				'notnull' => true,
444
+				'length' => 128,
445
+			]);
446
+			$table->addColumn('tnx_groups_allowed', Types::TEXT, [
447
+				'notnull' => false,
448
+                                'default' => '',
449
+			]);
450
+			$table->addColumn('tnx_users_allowed', Types::TEXT, [
451
+				'notnull' => false,
452
+                                'default' => '',
453
+			]);
454
+			$table->addColumn('plv_groups_allowed', Types::TEXT, [
455
+				'notnull' => false,
456
+                                'default' => '',
457
+			]);
458
+			$table->addColumn('plv_users_allowed', Types::TEXT, [
459
+				'notnull' => false,
460
+                                'default' => '',
461
+			]);
462
+			$table->addColumn('twl_groups_allowed', Types::TEXT, [
463
+				'notnull' => false,
464
+                                'default' => '',
465
+			]);
466
+			$table->addColumn('twl_users_allowed', Types::TEXT, [
467
+				'notnull' => false,
468
+                                'default' => '',
469
+			]);
470
+			$table->addColumn('flr_groups_allowed', Types::TEXT, [
471
+				'notnull' => false,
472
+                                'default' => '',
473
+			]);
474
+			$table->addColumn('flr_users_allowed', Types::TEXT, [
475
+				'notnull' => false,
476
+                                'default' => '',
477
+			]);
478
+                        $table->setPrimaryKey(['id']);
479
+                        $table->addUniqueIndex(['id']);
480
+		}
481
+
482
+
483
+		if (!$schema->hasTable('sms_relent_conv')) {
484
+			$table = $schema->createTable('sms_relent_conv');
485
+			$table->addColumn('id', Types::BIGINT, [
486
+				'autoincrement' => true,
487
+				'notnull' => true,
488
+                                'length' => 11,
489
+                                'unsigned' => true,
490
+			]);
491
+			$table->addColumn('conversation_id', Types::STRING, [
492
+				'notnull' => false,
493
+				'length' => 255,
494
+			]);
495
+			$table->addColumn('archived', Types::SMALLINT, [
496
+				'notnull' => false,
497
+				'length' => 1,
498
+			]);
499
+			$table->addColumn('last_archived', Types::DATETIME, [
500
+				'notnull' => false,
501
+			]);
502
+			$table->addColumn('last_unarchived', Types::DATETIME, [
503
+				'notnull' => false,
504
+			]);
505
+			$table->addColumn('archived_by', Types::STRING, [
506
+				'notnull' => false,
507
+				'length' => 128,
508
+			]);
509
+			$table->addColumn('unarchived_by', Types::STRING, [
510
+				'notnull' => false,
511
+				'length' => 128,
512
+			]);
513
+			$table->addColumn('last_msg_date', Types::DATETIME, [
514
+				'notnull' => true,
515
+			]);
516
+			$table->addColumn('last_msg_from', Types::STRING, [
517
+				'notnull' => true,
518
+				'length' => 128,
519
+			]);
520
+			$table->addColumn('last_msg_to', Types::STRING, [
521
+				'notnull' => true,
522
+				'length' => 128,
523
+			]);
524
+			$table->addColumn('last_message', Types::TEXT, [
525
+				'notnull' => false,
526
+				'default' => '',
527
+			]);
528
+			$table->addColumn('lastmsgdisplayname', Types::STRING, [
529
+				'notnull' => true,
530
+				'length' => 255,
531
+			]);
532
+			$table->addColumn('flagged', Types::SMALLINT, [
533
+				'notnull' => false,
534
+				'length' => 1,
535
+			]);
536
+			$table->addColumn('flagunflagby', Types::STRING, [
537
+				'notnull' => false,
538
+				'length' => 128,
539
+			]);
540
+			$table->addColumn('flagunflagdate', Types::DATETIME, [
541
+				'notnull' => false,
542
+			]);
543
+			$table->addColumn('tag', Types::STRING, [
544
+				'notnull' => false,
545
+				'length' => 100,
546
+			]);
547
+			$table->addColumn('taguntagby', Types::STRING, [
548
+				'notnull' => false,
549
+				'length' => 128,
550
+			]);
551
+			$table->addColumn('taguntagdate', Types::DATETIME, [
552
+				'notnull' => false,
553
+			]);
554
+			$table->addColumn('description', Types::TEXT, [
555
+				'notnull' => false,
556
+                                'default' => '',
557
+			]);
558
+			$table->addColumn('descriptionby', Types::STRING, [
559
+				'notnull' => false,
560
+				'length' => 128,
561
+			]);
562
+			$table->addColumn('descriptiondate', Types::DATETIME, [
563
+				'notnull' => false,
564
+			]);
565
+                        $table->setPrimaryKey(['id']);
566
+                        $table->addUniqueIndex(['id']);
567
+		}
568
+
569
+		return $schema;
570
+	}
571
+
572
+}