forked from ushahidi/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSMSSync.php
More file actions
117 lines (100 loc) · 3.33 KB
/
Copy pathSMSSync.php
File metadata and controls
117 lines (100 loc) · 3.33 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
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
<?php
namespace Ushahidi\App\DataSource\SMSSync;
/**
* SMSSync Data Providers
*
* @author Ushahidi Team <team@ushahidi.com>
* @package DataSource\SMSSync
* @copyright 2013 Ushahidi
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/
use Ushahidi\App\DataSource\CallbackDataSource;
use Ushahidi\App\DataSource\Message\Type as MessageType;
use Ushahidi\App\DataSource\Message\Status as MessageStatus;
use Ushahidi\App\DataSource\Concerns\MapsInboundFields;
use Ushahidi\Core\Entity\Contact;
class SMSSync implements CallbackDataSource
{
use MapsInboundFields;
protected $config;
/**
* Constructor function for DataSource
*/
public function __construct(array $config)
{
$this->config = $config;
}
public function getName()
{
return 'SMSSync';
}
public function getId()
{
return strtolower($this->getName());
}
public function getServices()
{
return [MessageType::SMS];
}
public function getOptions()
{
return [
'intro_step1' => [
'label' => 'Step 1: Download the "SMSSync" app from the Android Market.',
'input' => 'read-only-text',
'description' => function () {
return 'Scan this QR Code with your phone to download the app from the Android Market
<img src="'. url('/images/smssync.png') .'" width="150"/>';
}
],
// @todo figure out how to inject link and fix base url
'intro_step2' => [
'label' => 'Step 2: Android App Settings',
'input' => 'read-only-text',
'description' => function () {
return 'Turn on SMSSync and use the following link as the Sync URL: ' . url('sms/smssync');
}
],
'secret' => [
'label' => 'Secret',
'input' => 'text',
'description' => 'Set a secret so that only authorized SMSSync devices can send/recieve message.
You need to configure the same secret in the SMSSync App.',
'rules' => ['required']
]
];
}
public function getInboundFields()
{
return [
'Message' => 'text',
'Date' => 'datetime',
];
}
public function isUserConfigurable()
{
return true;
}
/**
* Contact type user for this provider
*/
public $contact_type = Contact::PHONE;
public static function registerRoutes(\Laravel\Lumen\Routing\Router $router)
{
$router->post('sms/smssync', 'Ushahidi\App\DataSource\SMSSync\SMSSyncController@handleRequest');
$router->post('smssync', 'Ushahidi\App\DataSource\SMSSync\SMSSyncController@handleRequest');
$router->get('sms/smssync', 'Ushahidi\App\DataSource\SMSSync\SMSSyncController@handleRequest');
$router->get('smssync', 'Ushahidi\App\DataSource\SMSSync\SMSSyncController@handleRequest');
}
public function verifySecret($secret)
{
if (isset($this->config['secret']) and $secret === $this->config['secret']) {
return true;
}
return false;
}
public function getSecret()
{
return isset($this->config['secret']) ? $this->config['secret'] : false;
}
}