Proyectos de Subversion LeadersLinked - Services

Rev

Rev 300 | Rev 334 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 300 Rev 307
Línea 17... Línea 17...
17
 
17
 
Línea 18... Línea 18...
18
use LeadersLinked\Mapper\UserBlockedMapper;
18
use LeadersLinked\Mapper\UserBlockedMapper;
19
 
19
 
-
 
20
use LeadersLinked\Mapper\CompanyMapper;
-
 
21
use LeadersLinked\Mapper\CompanyUserMapper;
-
 
22
use LeadersLinked\Mapper\ConversationMapper;
20
use LeadersLinked\Mapper\CompanyMapper;
23
use LeadersLinked\Mapper\MessageMapper;
21
use LeadersLinked\Mapper\CompanyUserMapper;
24
use LeadersLinked\Model\Conversation;
-
 
25
use LeadersLinked\Library\Image;
-
 
26
use Laminas\View\Model\JsonModel;
-
 
27
use LeadersLinked\Form\InMail\SendForm;
-
 
28
use LeadersLinked\Model\Message;
22
use LeadersLinked\Library\Image;
29
use LeadersLinked\Model\VideoConvert;
23
use Laminas\View\Model\JsonModel;
30
use LeadersLinked\Mapper\VideoConvertMapper;
24
use Laminas\Mvc\I18n\Translator;
31
use Laminas\Mvc\I18n\Translator;
25
use LeadersLinked\Mapper\AbuseReportMapper;
-
 
26
use LeadersLinked\Model\AbuseReport;
-
 
27
use LeadersLinked\Library\ExternalCredentials;
-
 
28
use LeadersLinked\Library\Storage;
-
 
29
use LeadersLinked\Form\InMail\SendForm;
-
 
30
use PHPMailer\PHPMailer\PHPMailer;
-
 
Línea 31... Línea 32...
31
use LeadersLinked\Library\S3Files;
32
use LeadersLinked\Mapper\AbuseReportMapper;
32
 
33
use LeadersLinked\Model\AbuseReport;
33
 
-
 
34
class InMailController extends AbstractActionController
-
 
35
{
-
 
36
    const _SIZE_PAGE = 10;
34
 
37
 
35
class InMailController extends AbstractActionController
38
    
36
{
39
    /**
37
    /**
40
     *
38
     *
Línea 91... Línea 89...
91
     * Generación del listado de conversationes
89
     * Generación del listado de conversationes
92
     * 
90
     * 
93
     * [
91
     * [
94
     *  success: true,
92
     *  success: true,
95
     *  data:[
93
     *  data:[
96
     *    messages : 
-
 
97
     *    [
94
     *    [
98
     *       uuid: uuid con quien se tiene la conversación,
95
     *       uuid: uuid con quien se tiene la conversación,
99
     *       name: nombre de con quien se tiene la conversacion,
96
     *       name: nombre de con quien se tiene la conversacion,
100
     *       image: imagen de con quien se tiene la conversación,
97
     *       image: imagen de con quien se tiene la conversación,
101
     *       subject: asunto del mensaje
98
     *       profile: url del profile con quien se tiene la conversación,
102
     *       date: fecha del ultimo mensaje,
99
     *       last_message: fecha del ultimo mensaje,
-
 
100
     *       count_unread: cantidad de mensajes sin leer,
103
     *       seen: true|false,
101
     *       messages_link: url para recuperar los mensajes,
104
     *       send_link: url para enviar el mensaje,
102
     *       send_link: url para enviar el mensaje,
105
     *       open_link : url para leer el mensaje,
-
 
106
     *       delete_link : url para leer el mensaje,
103
     *       selected: 0 = no seleccionado, 1 = seleccionado
107
     *     ],
104
     *     ]
108
     *     'total_messages' : total de mensajes,
-
 
109
     *     'total_pages' : total de páginas 10 en 10,
-
 
110
     *     'current_page' : página actual 
-
 
111
     *  ]
105
     *  ]
112
     * 
106
     * 
113
     * 
107
     * 
114
     * @return \Laminas\View\Model\JsonModel
108
     * @return \Laminas\View\Model\JsonModel
115
     */
109
     */
Línea 117... Línea 111...
117
    {
111
    {
118
        $request = $this->getRequest();
112
        $request = $this->getRequest();
119
        if ($request->isGet()) {
113
        if ($request->isGet()) {
120
            $currentUserPlugin = $this->plugin('currentUserPlugin');
114
            $currentUserPlugin = $this->plugin('currentUserPlugin');
121
            $currentUser = $currentUserPlugin->getUser();
115
            $currentUser = $currentUserPlugin->getUser();
122
            
-
 
123
            $page = intval($this->params()->fromQuery('page', 0), 10);
-
 
124
            
-
 
125
            $storage = Storage::getInstance($this->config);
-
 
126
            
-
 
127
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
-
 
128
            $externalCredentials->getUserBy($currentUser->id);
-
 
129
            
-
 
130
            $host       = trim($this->config['leaderslinked.inmail.host']);
-
 
131
            $port       = intval($this->config['leaderslinked.inmail.port_imap'], 10);
-
 
132
            $mailbox    = trim($this->config['leaderslinked.inmail.mailbox']);
-
 
133
            
-
 
Línea -... Línea 116...
-
 
116
 
-
 
117
            $id = $this->params()->fromRoute('id');
134
 
118
 
135
            $username   = $externalCredentials->getUsernameInmail();
119
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
120
            $currentUser = $currentUserPlugin->getUser();
-
 
121
            
-
 
122
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
Línea 136... Línea 123...
136
            $password   =  $externalCredentials->getPasswordInmail();
123
                $user_blocked_ids = $userBlockedMapper ->fetchAllBlockedReturnIds($currentUser->id);
Línea 137... Línea -...
137
            
-
 
138
            $userMapper = \LeadersLinked\Mapper\UserMapper::getInstance($this->adapter);
-
 
139
 
-
 
140
            try { 
-
 
141
                \Eden\Core\Control::i();
-
 
142
                $client = eden('mail')->imap(
-
 
143
                    $host,
-
 
144
                    $username,
-
 
145
                    $password,
-
 
146
                    $port,
-
 
147
                    false);
-
 
148
                
-
 
149
                $client->setActiveMailbox($mailbox);
-
 
Línea -... Línea 124...
-
 
124
            
150
                 
125
                $user_blocked_me_ids = $userBlockedMapper->fetchAllUserBlockMeReturnIds($currentUser->id);                
151
                //$emails = $imap->getEmails(0, 3);
-
 
Línea 152... Línea 126...
152
                $maxMessages = $client->getEmailTotal(); 
126
 
153
 
127
 
154
                if($maxMessages > self::_SIZE_PAGE) {
-
 
155
                    
-
 
156
                
-
 
157
                    $maxPages = (int)  $maxMessages / self::_SIZE_PAGE;
128
                $userMapper = UserMapper::getInstance($this->adapter);
158
                    if(($maxPages * self::_SIZE_PAGE) <  $maxMessages) {
-
 
159
                        $maxPages++;
-
 
160
                    }
129
                $now = $userMapper->getDatebaseNow();
161
                } else {
130
                
162
                    $maxPages = 1; 
-
 
163
                    $page = 1;
131
                $conversationMapper = ConversationMapper::getInstance($this->adapter);
164
                }
-
 
165
                 
-
 
166
                $page = $page > 0 ? $page : 1;
132
                $messageMapper = MessageMapper::getInstance($this->adapter);
167
                $page = $page > $maxPages ? $maxPages : $page;
133
                $conversations = [];
168
                 
-
 
169
                if($page == 1) {
-
 
170
                    $low = 0;
-
 
171
                    $high = self::_SIZE_PAGE - 1;
134
 
172
                } else {
-
 
173
                    $low = ($page - 1) * self::_SIZE_PAGE;
-
 
174
                    $high = $low + ( self::_SIZE_PAGE - 1); 
-
 
175
                }
135
                $selected_user_id = 0;
176
      
136
 
177
                $users = [];
137
                $id = $this->params()->fromRoute('id');
178
                $messages = [];
138
                if ($id) {
-
 
139
 
-
 
140
                    $companyMapper = CompanyMapper::getInstance($this->adapter);
179
                if( $maxMessages ) {
141
                    $company = $companyMapper->fetchOneByUuid($id);
-
 
142
                    if ($company) {
-
 
143
 
180
                    $emails = $client->getEmails($low, $high);
144
                        $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
181
                    foreach($emails as $email)
-
 
182
                    {
145
                        $companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
183
                        
-
 
184
                      
146
                        
185
                     
-
 
186
                        $from = $email['from']['email'];
147
                        if(!in_array($companyUser->user_id, $user_blocked_ids) && !in_array($companyUser->id, $user_blocked_me_ids)) {
187
             
-
 
188
                        if(isset($users[ $from ])) {
-
 
189
                            $user = $users[ $from ];
148
                            $user  = $userMapper->fetchOne($companyUser->user_id);
190
                        } else {
149
                            
191
                            $user = $userMapper->fetchOneByUsernameInmailAndNetworkId($from, $currentUser->network_id);
150
                            
192
                            $users[ $from ] = $user;
151
                            $selected_user_id = $user->id;
193
                        }
152
                            $conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
194
                        
-
 
195
             
153
                            
-
 
154
                            
196
                        $seen = false;
155
                            $timeElapsedString = '';
197
                        if(is_array($email['flags'])) {
156
                            if ($conversation) {
198
                            foreach($email['flags'] as $flag)
157
                                $unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
-
 
158
                                $lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
-
 
159
                                
199
                            {
160
                                if ($lastMessage) {
-
 
161
                                    $timeElapsedString =  $this->timeAgo($lastMessage, $now);
-
 
162
                                }
-
 
163
                            } else {
-
 
164
                                $unread = 0;
-
 
165
                            }
-
 
166
                            
-
 
167
                            
-
 
168
                            array_push($conversations, [
-
 
169
                                'uuid' => $company->uuid,
-
 
170
                                'name' => $company->name,
-
 
171
                                'image' => $this->url()->fromRoute('storage', ['type' => 'company', 'code' => $company->uuid, 'filename' => $company->image],['force_canonical' => true]),
-
 
172
                                'profile' => $this->url()->fromRoute('company/view', ['id' => $company->uuid]),
-
 
173
                                'last_message' => $timeElapsedString,
-
 
174
                                'count_unread' => $unread,
-
 
175
                                'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
200
                                if($flag == 'seen') {
176
                                'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
Línea 201... Línea -...
201
                                    $seen = 1;
-
 
202
                                    break;
177
                                'selected' => 1,
203
                                }
-
 
204
                            }
-
 
205
                        }
-
 
206
                        
-
 
207
                 
-
 
208
                        
-
 
209
                        $message =  [
-
 
210
                            'uuid' => $user->uuid,
-
 
211
                            'name' => $user->first_name . ' ' . $user->last_name,
-
 
212
                            'image' => $storage->getUserImage($user), 
-
 
213
                            'subject' => $email['subject'],
-
 
214
                            'date' => date('Y-m-d h:i a', $email['date']),
-
 
215
                            'seen' => $seen,
-
 
Línea -... Línea 178...
-
 
178
                                'delete_link' => $this->url()->fromRoute('inmail/delete',  ['id' => $user->uuid]),
-
 
179
                            ]);
-
 
180
                            
216
                            'email_id' => $email['uid'],
181
                        }
-
 
182
                        
-
 
183
 
-
 
184
                        
-
 
185
                    } else {
-
 
186
                        $user = $userMapper->fetchOneByUuid($id);
-
 
187
                        if ($user) {
-
 
188
                            
-
 
189
                            if(!in_array($user->id, $user_blocked_ids) && !in_array($user->id, $user_blocked_me_ids)) {
-
 
190
 
-
 
191
                                $timeElapsedString = '';
-
 
192
    
-
 
193
                                $selected_user_id = $user->id;
-
 
194
                                $conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
-
 
195
                                if ($conversation) {
-
 
196
                                    $unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
-
 
197
                                    $lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
-
 
198
                                    if ($lastMessage) {
217
                            'block_link' => $this->url()->fromRoute('inmail/user/block',[ 'id' => $user->uuid ], ['force_canonical' => true]),
199
                                        $timeElapsedString =  $this->timeAgo($lastMessage, $now);
-
 
200
                                    }
-
 
201
                                } else {
-
 
202
                                    $unread = 0;
-
 
203
                                }
-
 
204
    
-
 
205
    
-
 
206
                                array_push($conversations, [
-
 
207
                                    'uuid' => $user->uuid,
-
 
208
                                    'name' => trim($user->first_name . ' ' . $user->last_name),
-
 
209
                                    'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image],['force_canonical' => true]),
-
 
210
                                    'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
-
 
211
                                    'last_message' => $timeElapsedString,
-
 
212
                                    'count_unread' => $unread,
-
 
213
                                    'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
-
 
214
                                    'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
-
 
215
                                    'selected' => 1,
-
 
216
                                    'delete_link' => $this->url()->fromRoute('inmail/delete',  ['id' => $user->uuid]),
-
 
217
                                ]);
-
 
218
                            }
-
 
219
                        }
-
 
220
                    }
-
 
221
                }
-
 
222
 
-
 
223
 
-
 
224
                $records = $conversationMapper->fetchAllByUserId($currentUser->id);
-
 
225
                foreach ($records as $record) {
-
 
226
                    if ($selected_user_id) {
-
 
227
                        if ($record->sender_id == $currentUser->id && $record->receiver_id == $selected_user_id) {
-
 
228
                            continue;
-
 
229
                        }
-
 
230
                        if ($record->receiver_id == $currentUser->id && $record->sender_id == $selected_user_id) {
-
 
231
                            continue;
-
 
232
                        }
Línea -... Línea 233...
-
 
233
                    }
-
 
234
 
-
 
235
                    if ($record->sender_id == $currentUser->id) {
218
                            'send_link' => $this->url()->fromRoute('inmail/message/send',[ 'id' => $user->uuid ], ['force_canonical' => true]),
236
                        $user = $userMapper->fetchOne($record->receiver_id);
219
                            'get_link' =>  $this->url()->fromRoute('inmail/message/get',[ 'id' => $email['uid'] ], ['force_canonical' => true]),
237
                    }
-
 
238
                    if ($record->receiver_id == $currentUser->id) {
-
 
239
                        $user = $userMapper->fetchOne($record->sender_id);
-
 
240
                        
-
 
241
                        if(in_array($user->id, $user_blocked_ids) || in_array($user->id, $user_blocked_me_ids)) {
-
 
242
                            continue;
-
 
243
                        }
-
 
244
                    }
-
 
245
 
-
 
246
                    $timeElapsedString = '';
-
 
247
                    $unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($record->id, $currentUser->id);
-
 
248
                    $lastMessage = $messageMapper->fetchLastMessagesByConversationIdAndReceiverId($record->id, $currentUser->id);
-
 
249
 
-
 
250
 
-
 
251
                    if ($lastMessage) {
-
 
252
                        $timeElapsedString =  $this->timeAgo($lastMessage, $now);
-
 
253
                    }
-
 
254
 
-
 
255
                    array_push($conversations, [
-
 
256
                        'uuid' => $user->uuid,
-
 
257
                        'name' => trim($user->first_name . ' ' . $user->last_name),
-
 
258
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image],['force_canonical' => true]),
220
                            'delete_link'=>    $this->url()->fromRoute('inmail/message/delete',[ 'id' => $email['uid'] ], ['force_canonical' => true]),
259
                        'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
221
                       ];
260
                        'last_message' => $timeElapsedString,
222
                        
-
 
223
         
261
                        'count_unread' => $unread,
224
                        array_push($messages, $message);
262
                        'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
-
 
263
                        'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
-
 
264
                        'selected' => 0,
225
                        
265
                        'delete_link' => $this->url()->fromRoute('inmail/delete',  ['id' => $user->uuid]),
226
                    }
266
                    ]);
227
                     
267
                }
228
                }
268
 
229
                 
269
 
230
                $client->disconnect(); 
270
                usort($conversations, function ($a, $b) {
231
                 
271
                    if ($a['selected'] == $b['selected']) {
232
                $data = [
272
                        if ($a['last_message'] == $b['last_message']) {
233
                    'success' => true, 
-
 
234
                    'data' => [
-
 
235
                        'messages'          => $messages,  
-
 
236
                        'total_messages'    => $maxMessages,
273
                            return 0;
237
                        'total_pages'       => $maxPages,
-
 
238
                        'current_page'      => $page,
274
                        } else {
239
                    ]
275
                            return $a['last_message'] < $b['last_message'] ? -1 : 1;
240
                ];
276
                        }
241
                     
277
                    } else {
242
                     
278
                        return $a['selected'] < $b['selected'] ? -1 : 1;
243
                return new JsonModel($data);   
-
 
244
                     
-
 
245
            } catch (\Exception $e) {
-
 
246
                
-
 
247
                return new JsonModel([
-
 
248
                    'success' => false, 
-
 
249
                    'data' => 'ERROR_INMAIL_MESSAGE_LIST_UNAVAILABLE' 
-
 
250
                ]);
-
 
251
            }
-
 
252
             
-
 
253
           /*
-
 
254
            * 
-
 
255
            * (
-
 
256
    [0] => Array
-
 
257
        (
-
 
258
            [id] => <6f27ed6a-d554-4f0b-b9ee-7c708cca8b33@inmail.leaderslinked.com>
-
 
259
            [parent] => 
-
 
260
            [topic] => Test 1
-
 
261
            [mailbox] => INBOX
-
 
262
            [uid] => 8
-
 
263
            [date] => 1721906994
-
 
264
            [subject] => Test 1
-
 
265
            [from] => Array
-
 
266
                (
-
 
267
                    [name] => Efrain Yanez
-
 
268
                    [email] => efrain.yanez@inmail.leaderslinked.com
-
 
269
                )
-
 
270
 
-
 
271
            [flags] => Array
-
 
272
                (
-
 
273
                    [0] => seen
-
 
274
                )
-
 
275
 
-
 
276
            [to] => Array
-
 
277
                (
-
 
278
                    [0] => Array
-
 
279
                        (
-
 
280
                            [name] => 
-
 
281
                            [email] => santiago.olivera@inmail.leaderslinked.com
-
 
282
                        )
-
 
283
 
-
 
284
                )
-
 
285
 
-
 
286
            [cc] => Array
-
 
287
                (
-
 
288
                )
-
 
289
 
-
 
290
            [bcc] => Array
-
 
291
                (
-
 
292
                )
-
 
293
 
-
 
294
            [attachment] => 1
-
 
295
            
-
 
296
        )
-
 
297
        (
-
 
298
    [id] => <6f27ed6a-d554-4f0b-b9ee-7c708cca8b33@inmail.leaderslinked.com>
-
 
299
    [parent] =>
-
 
300
    [topic] => Test 1
-
 
301
    [mailbox] => INBOX
-
 
302
    [uid] => 8
-
 
303
    [date] => 1721906994
-
 
304
    [subject] => Test 1
-
 
305
    [from] => Array
-
 
306
        (
-
 
307
            [name] => Efrain Yanez
-
 
308
            [email] => efrain.yanez@inmail.leaderslinked.com
-
 
309
        )
-
 
310
 
-
 
311
    [flags] => Array
-
 
312
        (
-
 
313
            [0] => seen
-
 
314
        )
-
 
315
 
-
 
316
    [to] => Array
-
 
317
        (
-
 
318
            [0] => Array
-
 
319
                (
-
 
320
                    [name] =>
-
 
321
                    [email] => santiago.olivera@inmail.leaderslinked.com
-
 
322
                )
-
 
323
 
-
 
324
        )
-
 
325
 
-
 
326
    [cc] => Array
-
 
327
        (
-
 
328
        )
-
 
329
 
-
 
330
    [bcc] => Array
-
 
331
        (
-
 
332
        )
-
 
333
[body] => 'esto es una pryeba',
-
 
334
    [attachment] => Array
-
 
335
        (
-
 
336
            [POST 1080X1080-03-37.png] => Array
-
 
337
                (
-
 
338
                    [image/png] => �PNG
-
 
339
 
-
 
340
 
-
 
341
 
-
 
342
 
-
 
343
 
-
 
344
 
-
 
345
        [futbol-720p-230714 - Copy (1).mp4] => Array
-
 
346
                (
-
 
347
                    [video/mp4]
-
 
348
        
-
 
349
            * 
-
 
350
            * 
-
 
351
            Array
-
 
352
(
-
 
353
    [0] => __construct
-
 
354
    [1] => connect
-
 
355
    [2] => disconnect
-
 
356
    [3] => getActiveMailbox
-
 
357
    [4] => getEmails
-
 
358
    [5] => getEmailTotal
-
 
359
    [6] => getNextUid
-
 
360
    [7] => getMailboxes
-
 
361
    [8] => getUniqueEmails
-
 
362
    [9] => move
-
 
363
    [10] => copy
-
 
364
    [11] => remove
-
 
365
    [12] => expunge
-
 
366
    [13] => search
-
 
367
    [14] => searchTotal
-
 
368
    [15] => setActiveMailbox
-
 
369
    [16] => i
-
 
370
    [17] => __call
-
 
371
    [18] => __invoke
-
 
372
    [19] => __toString
-
 
373
    [20] => addMethod
-
 
374
    [21] => callArray
-
 
375
    [22] => inspect
-
 
376
    [23] => loadState
-
 
377
    [24] => loop
279
                    }
378
    [25] => off
280
                });
379
    [26] => on
281
 
380
    [27] => saveState
282
 
381
    [28] => trigger
283
                return new JsonModel([
382
    [29] => when
284
                    'success' => true,
383
)
285
                    'data' => $conversations
384
            */
286
                ]);
-
 
287
 
385
     
288
        } else {
-
 
289
            return new JsonModel([
-
 
290
                'success' => false,
-
 
291
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
292
            ]);
-
 
293
        }
-
 
294
    }
-
 
295
 
-
 
296
 
-
 
297
    /**
-
 
298
     * Esta función remueve el usuario del grupo
-
 
299
     * Es una petición GET el url recuperado en /inmail
-
 
300
     * [ruta del servidor]/inmail/[uuid]/message
-
 
301
     * retorna un json en caso de ser  positivo
-
 
302
     * [
-
 
303
     *   success: true,
-
 
304
     *      data: [
-
 
305
     *          [ 
-
 
306
     *              sender_name: nombre de quien que envia el mensaje,
-
 
307
     *              sender_image: imagen de quien que recibe el mensaje,
-
 
308
     *              sender_profile: url de profile de quien que envia el mensaje,
-
 
309
     *              receiver_name: nombre de quien que recibe el mensaje,
-
 
310
     *              receiver_image: url de la imagen de quien  que recibe el mensaje,
-
 
311
     *              receiver_profile: url del profile de quien recibe el mensaje,
-
 
312
     *              side: left/righ de que lado de la pantalla se mostrara,
-
 
313
     *              message: texto del mensaje,
-
 
314
     *              type: text|image|video|document,
-
 
315
     *              filename: url del archivo enviado,
-
 
316
     *              date: cadena que describe hace cuanto se recibio el mensaje
-
 
317
     *          ]
-
 
318
     *      ]
386
        } else {
319
     *   ]
387
            return new JsonModel([
320
     * En caso de ser negativo puede haber 2 formatos
388
                'success' => false,
321
     * [
389
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
322
     *  'success' : false,
-
 
323
     *  'data' : mensaje de error
-
 
324
     * ]
390
            ]);
325
     * @return \Laminas\View\Model\JsonModel
391
        }
326
     */
-
 
327
    public function messageAction()
-
 
328
    {
-
 
329
        $request = $this->getRequest();
Línea 392... Línea -...
392
    }
-
 
393
    
330
        if ($request->isGet()) {
394
    public function getAttachmentAction()
331
            $page = intval($this->params()->fromQuery('page', 0), 10);
395
    {
332
 
396
        $request = $this->getRequest();
-
 
397
        if ($request->isGet()) {
333
            $currentUserPlugin = $this->plugin('currentUserPlugin');
398
            $currentUserPlugin = $this->plugin('currentUserPlugin');
334
            $currentUser = $currentUserPlugin->getUser();
-
 
335
 
-
 
336
            $userMapper = UserMapper::getInstance($this->adapter);
399
            $currentUser = $currentUserPlugin->getUser();
337
            $now = $userMapper->getDatebaseNow();
400
            
338
            
-
 
339
            $conversationMapper = ConversationMapper::getInstance($this->adapter);
401
            $id = intval($this->params()->fromRoute('id'), 10);
340
 
402
            $attachment = intval($this->params()->fromRoute('attachment'), 10);
341
            $messageMapper = MessageMapper::getInstance($this->adapter);
403
            
342
 
-
 
343
            $id = $this->params()->fromRoute('id');
-
 
344
            if (!$id) {
-
 
345
                return new JsonModel([
404
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
346
                    'success' => false,
-
 
347
                    'data' => 'ERROR_PARAMETERS_ARE_INVALID'
-
 
348
                ]);
Línea 405... Línea -...
405
            $externalCredentials->getUserBy($currentUser->id);
-
 
-
 
349
            }
-
 
350
 
Línea 406... Línea 351...
406
            
351
            $user = $userMapper->fetchOneByUuid($id);
-
 
352
            if (!$user) {
-
 
353
                return new JsonModel([
-
 
354
                    'success' => false,
407
            $host       = trim($this->config['leaderslinked.inmail.host']);
355
                    'data' => 'ERROR_REQUEST_IS_INVALID'
408
            $port       = intval($this->config['leaderslinked.inmail.port_imap'], 10);
356
                ]);
409
            $mailbox    = trim($this->config['leaderslinked.inmail.mailbox']);
357
            }
-
 
358
            
-
 
359
            $abuseReportMapper = AbuseReportMapper::getInstance($this->adapter);
410
            
360
            $abuse_report_message_ids = $abuseReportMapper->fetchAllDataByUserReportingIdAndTypeReturnIds($currentUser->id, AbuseReport::TYPE_INMAIL_MESSAGE);
411
            
361
            
412
            $username   = $externalCredentials->getUsernameInmail();
362
 
413
            $password   =  $externalCredentials->getPasswordInmail();
363
            $conversationMapper = ConversationMapper::getInstance($this->adapter);
414
            
364
            $conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
415
           
365
 
416
            
366
            $messages = [];
-
 
367
            if ($conversation) {
417
 
368
                $records = $messageMapper->getAllMessagesPaginatorByConversationId($conversation->id, $page);
418
            try {
369
 
419
                \Eden\Core\Control::i();
370
 
420
                $client = eden('mail')->imap(
-
 
421
                    $host,
371
                foreach ($records as $record) {
422
                    $username,
-
 
423
                    $password,
-
 
-
 
372
                    /*
-
 
373
                    echo '<pre>'; 
-
 
374
                    print_r($record); 
-
 
375
                    echo '</pre>'; */
-
 
376
 
-
 
377
                    $timeElapsedString = $this->timeAgo($record->added_on, $now);
424
                    $port,
378
 
-
 
379
 
-
 
380
                    if ($record->sender_id == $currentUser->id) {
-
 
381
                        array_push($messages, [
-
 
382
                            'uuid' => $record->uuid,
425
                    false);
383
                            'sender_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
426
                
384
                            'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $currentUser->uuid],['force_canonical' => true]),
427
                $client->setActiveMailbox($mailbox);
-
 
428
      
385
                            'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
Línea -... Línea 386...
-
 
386
                            'receiver_name' => trim($user->first_name . ' ' . $user->last_name),
429
                $email = $client->getUniqueEmails($id, true);
387
                            'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
-
 
388
                            'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
-
 
389
                            'side' => 'left',
-
 
390
                            'message' => $record->message,
-
 
391
                            'type' => $record->type,
-
 
392
                            'filename' => $record->filename ? $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $record->filename, 'code' => $record->uuid],['force_canonical' => true]) : '',
-
 
393
                            'date' => $timeElapsedString,
-
 
394
                            'url_abuse_report' => '',
-
 
395
                        ]);
-
 
396
                    } else {
-
 
397
                        
-
 
398
                        if(in_array($record->id, $abuse_report_message_ids)) {
-
 
399
                            
-
 
400
                            array_push($messages, [
-
 
401
                                'uuid' => $record->uuid,
-
 
402
                                'sender_name' => trim($user->first_name . ' ' . $user->last_name),
-
 
403
                                'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
-
 
404
                                'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
-
 
405
                                'receiver_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
Línea 430... Línea 406...
430
                $client->disconnect();
406
                                'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $user->uuid],['force_canonical' => true]),
431
                
407
                                'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
432
                if($email['uid']) {
-
 
433
                    
408
                                'side' => 'right',
-
 
409
                                'message' => 'LABEL_ABUSE_CONTENT_REPORTED',
434
                    
410
                                'type' => Message::TYPE_TEXT,
435
                    $base64         = '';
411
                                'filename' => '',
-
 
412
                                'date' => $timeElapsedString,
-
 
413
                                'url_abuse_report' => '',
436
                    $contentType    = '';
414
                            ]);
437
                    $filename       = '';
415
                            
438
                  
416
                        } else {
-
 
417
                            $url_abuse_report = $this->url()->fromRoute('helpers/abuse-report', ['type' => 'message', 'id' => $record->uuid], ['force_canonical' => true]);
439
                    if(!empty($email['attachment']) &&  is_array($email['attachment'])) {
418
                        
440
                        
419
                            array_push($messages, [
441
                       
420
                                'uuid' => $record->uuid,
442
                        
421
                                'sender_name' => trim($user->first_name . ' ' . $user->last_name),
443
                        foreach($email['attachment'] as $filename => $data)
-
 
444
                        {
-
 
445
                         
-
 
446
                            $i = 0;
-
 
447
                            foreach($data as $contentType => $value)
-
 
448
                            {
-
 
449
                                if($i == $attachment) {
-
 
450
                                    $base64 = base64_encode($value);
-
 
451
                                    break;
-
 
452
                                }
-
 
453
                                $i++;
-
 
454
                            }
-
 
455
                        }
-
 
456
                    }
-
 
457
                    
-
 
458
                    if($base64) {
-
 
459
                        return new JsonModel([
-
 
460
                            'success' => true,
-
 
461
                            'data' => [
-
 
462
                                'filename' => $filename, 
-
 
463
                                'mime-type' => $contentType,
-
 
464
                                'base64' =>  $base64,
-
 
Línea 465... Línea -...
465
                            ]
-
 
466
                        ]);
-
 
467
                    } else {
-
 
468
                        return new JsonModel([
-
 
469
                            'success' => false,
422
                                'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
470
                            'data' =>  'ERROR_INMAIL_MESSAGE_ATTACHMENT_NOT_FOUND'
423
                                'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
471
                        ]);
424
                                'receiver_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
472
                    }
-
 
473
                    
425
                                'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $user->uuid],['force_canonical' => true]),
474
                    
-
 
475
                   
-
 
476
                   
426
                                'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
477
                   
427
                                'side' => 'right',
478
 
428
                                'message' => $record->message,
-
 
429
                                'type' => $record->type,
479
                    
430
                                'filename' => $record->filename ? $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $record->filename, 'code' => $record->uuid],['force_canonical' => true]) : '',
480
                } else {
431
                                'date' => $timeElapsedString,
481
                    return new JsonModel([
432
                                'url_abuse_report' => $url_abuse_report,
482
                        'success' => false,
433
                            ]);
-
 
434
                        }
-
 
435
 
-
 
436
                        $messageMapper->markAsRead($record->id);
-
 
437
                    }
483
                        'data' => 'ERROR_INMAIL_MESSAGE_NOT_FOUND'
438
                }
484
                    ]);
439
 
485
                }
440
                return new JsonModel([
486
          
441
                    'success' => true,
487
                
442
                    'data' => $messages,
488
            } catch (\Exception $e) {
443
                    'pagination' => $records->getPages()
489
                
444
                ]);
490
                return new JsonModel([
445
            }
491
                    'success' => false,
446
 
-
 
447
 
-
 
448
            return new JsonModel([
-
 
449
                'success' => true,
-
 
450
                'data' => $messages,
-
 
451
                'pagination' => 1
-
 
452
            ]);
-
 
453
        } else {
-
 
454
            return new JsonModel([
-
 
455
                'success' => false,
-
 
456
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
457
            ]);
-
 
458
        }
-
 
459
    }
-
 
460
 
-
 
461
    /**
-
 
462
     * Esta función envia un mensaje
-
 
463
     * Es una petición POST el url recuperado en /inmail
-
 
464
     * [ruta del servidor]/inmail/[uidd del usuario]/message/send 
-
 
465
     * Lo párametros son
-
 
466
     * message: text plain requerido
-
 
467
     * file: no requerido puede jpg, png, jpeg, mp3, mp4, webm o pdf
-
 
468
     * o
-
 
469
     * [ruta del servidor]/inmail/[uidd del usuario]/message/send/encoding/base64 para el caso de react-native
-
 
470
     * Los párametros son
-
 
471
     * message: text plain requerido
-
 
472
     * fileBase64Name: nombre del archivo  que se envia en base64 solo requerido si se envia un archivo
-
 
473
     * fileBase64Content: contenido en base 64 del archivo
-
 
474
     * 
-
 
475
     * retorna un json en caso de ser  positivo
-
 
476
     * [
-
 
477
     *   success: true,
-
 
478
     *      data:{
-
 
479
     *          sender_name: nombre de quien que envia el mensaje,
-
 
480
     *          sender_image: imagen de quien que recibe el mensaje,
-
 
481
     *          sender_profile: url de profile de quien que envia el mensaje,
-
 
482
     *          receiver_name: nombre de quien que recibe el mensaje,
-
 
483
     *          receiver_image: url de la imagen de quien  que recibe el mensaje,
-
 
484
     *          receiver_profile: url del profile de quien recibe el mensaje,
492
                    'data' => 'ERROR_INMAIL_MESSAGE_LIST_UNAVAILABLE'
485
     *          side: left/righ de que lado de la pantalla se mostrara,
493
                ]);
486
     *          message: texto del mensaje,
494
            }
487
     *          type: text|image|video|document,
495
            
488
     *          filename: url del archivo enviado,
496
          
489
     *          date: cadena que describe hace cuanto se recibio el mensaje
497
            
490
     *      ]
-
 
491
     *   ]   
-
 
492
     * En caso de ser negativo puede haber 2 formatos
-
 
493
     * [
Línea 498... Línea -...
498
        } else {
-
 
499
            return new JsonModel([
494
     *  'success' : false,
500
                'success' => false,
495
     *  'data' : mensaje de error
501
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
502
            ]);
496
     * ]
503
        }
497
     * @return \Laminas\View\Model\JsonModel
504
    }
-
 
505
    
498
     */
506
    public function getMessageAction()
499
    public function sendMessageAction()
507
    {
500
    {
-
 
501
        $request = $this->getRequest();
508
        $request = $this->getRequest();
502
        if ($request->isPost()) {
509
        if ($request->isGet()) {
503
            $currentUserPlugin = $this->plugin('currentUserPlugin');
510
            $currentUserPlugin = $this->plugin('currentUserPlugin');
504
            $currentUser = $currentUserPlugin->getUser();
-
 
505
 
-
 
506
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
507
            $now = $userMapper->getDatebaseNow();
511
            $currentUser = $currentUserPlugin->getUser();
508
            
-
 
509
 
-
 
510
            $id = $this->params()->fromRoute('id');
512
            
511
            if (!$id) {
513
            $id = intval($this->params()->fromRoute('id'), 10);
512
                return new JsonModel([
-
 
513
                    'success' => false,
514
            
514
                    'data' => 'ERROR_PARAMETERS_ARE_INVALID'
-
 
515
                ]);
-
 
516
            }
-
 
517
 
Línea -... Línea 518...
-
 
518
 
-
 
519
            $user = $userMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
-
 
520
            if (!$user) {
515
            $storage = Storage::getInstance($this->config);
521
                return new JsonModel([
-
 
522
                    'success' => false,
-
 
523
                    'data' => 'ERROR_REQUEST_IS_INVALID'
-
 
524
                ]);
-
 
525
            }
-
 
526
 
-
 
527
 
-
 
528
            $data = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
516
            
529
           
-
 
530
            if(!empty($data['file']) && empty($data['file']['error'])) {
-
 
531
                $data['message'] = $data['file']['name'];
-
 
532
            }
-
 
533
            
-
 
534
            $form = new SendForm();
517
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
535
            $form->setData($data);
-
 
536
 
518
            $externalCredentials->getUserBy($currentUser->id);
537
            if ($form->isValid()) {
519
            
538
 
520
            $host       = trim($this->config['leaderslinked.inmail.host']);
539
                $dataPost = (array) $form->getData();
-
 
540
       
-
 
541
 
-
 
542
                $conversationMapper = ConversationMapper::getInstance($this->adapter);
-
 
543
                $conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
-
 
544
 
-
 
545
                if ($conversation) {
-
 
546
                    $conversation->receiver_status = Conversation::STATUS_NORMAL;
-
 
547
                    $conversation->sender_status = Conversation::STATUS_NORMAL;
-
 
548
 
-
 
549
                    if (!$conversationMapper->update($conversation)) {
521
            $port       = intval($this->config['leaderslinked.inmail.port_imap'], 10);
550
                        return new JsonModel([
522
            $mailbox    = trim($this->config['leaderslinked.inmail.mailbox']);
551
                            'success'  => false,
-
 
552
                            'data' => $conversationMapper->getError()
-
 
553
                        ]);
-
 
554
                    }
-
 
555
                } else {
-
 
556
                    $conversation = new Conversation();
-
 
557
                    $conversation->sender_id = $currentUser->id;
-
 
558
                    $conversation->sender_status = Conversation::STATUS_NORMAL;
-
 
559
                    $conversation->receiver_id = $user->id;
-
 
560
                    $conversation->receiver_status = Conversation::STATUS_NORMAL;
-
 
561
 
523
            
562
                    if (!$conversationMapper->insert($conversation)) {
524
            
563
                        return new JsonModel([
-
 
564
                            'success'  => false,
525
            $username   = $externalCredentials->getUsernameInmail();
565
                            'data' => $conversationMapper->getError()
-
 
566
                        ]);
526
            $password   =  $externalCredentials->getPasswordInmail();
567
                    }
-
 
568
                }
527
            
569
                $files                  = $this->getRequest()->getFiles()->toArray();
-
 
570
                $type                   = Message::TYPE_TEXT;
-
 
571
                $message_tmp_filename   = '';
-
 
572
                $message_filename       = '';
-
 
573
 
-
 
574
 
-
 
575
                if (isset($files['file']) && empty($files['file']['error'])) {
-
 
576
                    $message_tmp_filename  = $files['file']['tmp_name'];
528
            
577
                    $message_filename      = $this->normalizeString($files['file']['name']);
529
            
578
 
530
            
579
                    $mime_type = mime_content_type($message_tmp_filename);
531
            try {
580
 
532
                \Eden\Core\Control::i();
581
 
-
 
582
                    if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
-
 
583
                        $type = Message::TYPE_IMAGE;
-
 
584
                    } else if ($mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
-
 
585
                        $type = Message::TYPE_VIDEO;
-
 
586
                    } else if ($mime_type == 'application/pdf') {
-
 
587
                        $type = Message::TYPE_DOCUMENT;
-
 
588
                    }
-
 
589
                }
533
                $client = eden('mail')->imap(
590
 
534
                    $host,
591
 
535
                    $username,
592
 
-
 
593
 
-
 
594
                $message = new Message();
536
                    $password,
595
                $message->conversation_id = $conversation->id;
537
                    $port,
596
                $message->read = Message::NO;
538
                    false);
597
                $message->message = $type == Message::TYPE_TEXT ? $dataPost['message'] : '';
-
 
598
                $message->receiver_id = $user->id;
539
                
599
                $message->receiver_status = Message::STATUS_NORMAL;
-
 
600
                $message->sender_id = $currentUser->id;
540
                $client->setActiveMailbox($mailbox);
601
                $message->sender_status = Message::STATUS_NORMAL;
541
                
602
                $message->type = $type;
542
                $email = $client->getUniqueEmails($id, true);
603
 
-
 
604
 
-
 
605
 
-
 
606
 
543
                $client->disconnect();
607
 
-
 
608
                $messageMapper = MessageMapper::getInstance($this->adapter);
544
                
609
                if ($messageMapper->insert($message)) {
-
 
610
 
-
 
611
                    $message = $messageMapper->fetchOne($message->id);
-
 
612
 
-
 
613
 
-
 
614
                    if ($type == Message::TYPE_DOCUMENT) {
-
 
615
                        try {
-
 
616
                            $target_path = $this->config['leaderslinked.fullpath.message'] . $message->uuid;
-
 
617
                            if (!file_exists($target_path)) {
-
 
618
                                mkdir($target_path, 0755);
-
 
619
                            }
545
                if($email['uid']) {
620
 
-
 
621
                            $full_filename = $target_path  . DIRECTORY_SEPARATOR . $message_filename;
546
                    $from = $email['from']['email'];
622
                            /*
-
 
623
                            if($encoding == 'base64') {
-
 
624
                                $resultMoveOrRename = rename($message_tmp_filename , $full_filename);
547
                    $subject = $email['subject'];
625
                            } else {
548
                    $body   = empty($email['body']['text/html']) ?  $email['body']['text/plain'] : $email['body']['text/html'];
626
                                $resultMoveOrRename = move_uploaded_file($message_tmp_filename , $full_filename);
549
                    
-
 
550
                    
-
 
551
                    $userMapper = \LeadersLinked\Mapper\UserMapper::getInstance($this->adapter);
-
 
552
                    $user = $userMapper->fetchOneByUsernameInmailAndNetworkId($from, $currentUser->network_id);
-
 
553
                    
-
 
554
                    
627
                            }
555
                    $seen = false;
-
 
556
                    if(is_array($email['flags'])) {
-
 
557
                        foreach($email['flags'] as $flag)
-
 
558
                        {
-
 
559
                            if($flag == 'seen') {
-
 
560
                                $seen = 1;
-
 
561
                                break;
-
 
562
                            }
-
 
563
                        }
628
                            */
564
                    }
-
 
565
                    
-
 
566
                    $extensions = ['mov', 'webm','mp4','mpeg','jpg','jpeg','png', 'pdf'];
-
 
567
                    $contentTypes =  ['video/quicktime', 'video/webm', 'video/mp4', 'video/mpeg', 'image/jpg', 'image/jpeg', 'image/png', 'application/pdf'];
-
 
568
                    
-
 
569
                    $storage = Storage::getInstance($this->config);
-
 
570
                    $path = $storage->getPathMessage();
-
 
571
                    $code = $currentUser->uuid;
-
 
572
                    
-
 
573
                    $attachments = [];
-
 
574
                    if(!empty($email['attachment']) &&  is_array($email['attachment'])) {
-
 
575
                        foreach($email['attachment'] as $filename => $attachment)
-
 
576
                        {
-
 
577
                            $i = 0;
629
 
578
                            foreach($attachment as $contentType => $value)
-
 
579
                            {
-
 
580
                                $pos = strrpos($filename, '.');
-
 
581
                                $extension = trim(substr($filename, $pos + 1));
-
 
582
                                
-
 
583
                               for($j = 0; $max = count($extensions), $j < $max; $j++)
-
 
584
                               {
-
 
585
                                   if($extension == $extensions[$j]) {
-
 
586
                                       $contentType = $contentTypes[$j];
-
 
587
                                   }
-
 
588
                               }
-
 
589
                               
-
 
590
                               $remoteFilename = trim($email['uid'] . '-' . $filename);
-
 
591
                              
-
 
592
                               
-
 
593
                               $url = $storage->getGenericFile($path, $code,  $remoteFilename) ;
-
 
594
                               if(!$url) {
-
 
595
                                   
-
 
596
                                   $tmp_file = sys_get_temp_dir() . '/' .  $remoteFilename;
630
                            $resultMoveOrRename = move_uploaded_file($message_tmp_filename, $full_filename);
597
                                   file_put_contents($tmp_file, $value);
-
 
598
                                   
-
 
599
                                   if($storage->putFile($path, $code, $tmp_file)) {
631
                            if ($resultMoveOrRename) {
600
                                       
-
 
601
                                       $url = $storage->getGenericFile($path, $code,  $remoteFilename) ;
-
 
602
                                   } else {
632
 
-
 
633
                                $message->type = $type;
-
 
634
                                $message->filename = basename($message_filename);
-
 
635
                                $messageMapper->update($message);
-
 
636
                            } else {
-
 
637
                                error_log('no se pudo mover o renombrar el documento : ' . $message_tmp_filename . ' al directorio : ' . $full_filename);
-
 
638
                            }
-
 
639
                        } catch (\Throwable $e) {
-
 
640
                            error_log($e->getTraceAsString());
-
 
641
                        }
-
 
642
                    }
-
 
643
                    if ($type == Message::TYPE_IMAGE) {
-
 
644
                        try {
-
 
645
                            $target_path = $this->config['leaderslinked.fullpath.message'] . $message->uuid;
-
 
646
                            if (!file_exists($target_path)) {
-
 
647
                                mkdir($target_path, 0755);
603
                                       $url = '';
648
                            }
604
                                   }
649
 
-
 
650
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.message_image_size']);
-
 
651
 
-
 
652
                            $message_filename = substr($message_filename, 0, strrpos($message_filename, '.'))  . '.png';
-
 
653
 
-
 
654
                            //echo "target_path = $target_path message_tmp_filename = $message_tmp_filename message_filename = $message_filename"; exit;
-
 
655
 
-
 
656
                            $crop_to_dimensions = false;
-
 
657
                            if (Image::uploadImage($message_tmp_filename, $target_path, $message_filename, $target_width, $target_height, $crop_to_dimensions)) {
-
 
658
                                $message->type = $type;
-
 
659
                                $message->filename = basename($message_filename);
-
 
660
                                $messageMapper->update($message);
-
 
661
                            }
-
 
662
                        } catch (\Throwable $e) {
-
 
663
                            error_log($e->getTraceAsString());
-
 
664
                        }
-
 
665
                    }
-
 
666
                    if ($type == Message::TYPE_VIDEO) {
-
 
667
                        try {
-
 
668
                            $target_path = $this->config['leaderslinked.fullpath.message'] . $message->uuid;
-
 
669
                            if (!file_exists($target_path)) {
-
 
670
                                mkdir($target_path, 0755);
-
 
671
                            }
-
 
672
 
-
 
673
                            $full_filename = $target_path  . DIRECTORY_SEPARATOR . $message_filename;
-
 
674
 
-
 
675
                            /*
-
 
676
                            if($encoding == 'base64') {
-
 
677
                                $resultMoveOrRename = rename($message_tmp_filename , $full_filename);
-
 
678
                            } else {
-
 
679
                                $resultMoveOrRename = move_uploaded_file($message_tmp_filename , $full_filename);
-
 
680
                            }*/
-
 
681
 
-
 
682
                            $resultMoveOrRename = move_uploaded_file($message_tmp_filename, $full_filename);
-
 
683
                            if ($resultMoveOrRename) {
-
 
684
 
-
 
685
                                $size = $this->config['leaderslinked.image_sizes.message_image_size'];
-
 
686
                                $getFromSecound = 2;
-
 
687
 
-
 
688
                                //extracción del cover
-
 
689
                                $generateFileName = substr($message_filename, 0, strrpos($message_filename, '.'));
-
 
690
                                $generateFile =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.png';
-
 
691
                                $cmd            = "/usr/bin/ffmpeg -i $full_filename -an -ss $getFromSecound -s $size $generateFile";
-
 
692
                                exec($cmd);
-
 
693
 
-
 
694
 
-
 
695
                                $message->type = $type;
-
 
696
                                $message->filename = basename($message_filename);
-
 
697
                                $message->image_preview = basename($generateFile);
-
 
698
                                $messageMapper->update($message);
-
 
699
 
-
 
700
                                $videoConvert = new VideoConvert();
-
 
701
                                $videoConvert->filename = $full_filename;
-
 
702
                                $videoConvert->type = VideoConvert::TYPE_FEED;
-
 
703
 
-
 
704
                                $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
-
 
705
                                $videoConvertMapper->insert($videoConvert);
-
 
706
                            } else {
-
 
707
                                error_log('no se pudo mover o renombrar el documento : ' . $message_tmp_filename . ' al directorio : ' . $full_filename);
-
 
708
                            }
-
 
709
                        } catch (\Throwable $e) {
-
 
710
                            error_log($e->getTraceAsString());
605
                                   
711
                        }
606
                               } 
712
                    }
607
                               
713
 
608
                                
714
                    $message = $messageMapper->fetchOne($message->id);
609
                                
715
 
-
 
716
                    if ($message->filename) {
-
 
717
                        $filename = $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $message->filename, 'code' => $message->uuid],['force_canonical' => true]);
610
                               // $this->url()->fromRoute('inmail/message/attachment',[ 'id' => $email['uid'], 'attachment' => $i ], ['force_canonical' => true]),
718
                    } else {
-
 
719
                        $filename = '';
611
                                
720
                    }
612
                                array_push($attachments, [
721
 
613
                                    'filename' =>  $remoteFilename,
722
                    $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $message->added_on);
614
                                    'content-type' => $contentType,
723
 
615
                                    'attachment_link' => $url,
724
                    $userMapper->updateLastActivity($currentUser->id);
616
                                ]);
-
 
617
                                $i++;
-
 
618
                            }
-
 
619
                        }
725
 
620
                    }
726
 
621
                    
727
 
622
                    return new JsonModel([
-
 
623
                        'success' => true,
-
 
624
                        'data' => [
728
                    return new JsonModel([
625
                            'uuid' => $user->uuid,
729
                        'success'   => true,
626
                            'name' => $user->first_name . ' ' . $user->last_name,
730
                        'data'   => [
627
                            'image' => $storage->getUserImage($user),
731
                            'sender_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
628
                            'subject' => $subject,
732
                            'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $currentUser->uuid],['force_canonical' => true]),
629
                            'body' => $body,
733
                            'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
-
 
734
                            'receiver_name' => trim($user->first_name . ' ' . $user->last_name),
630
                            'date' => date('Y-m-d h:i a', $email['date']),
735
                            'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
631
                            'seen' => $seen,
736
                            'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
632
                            'block_link' => $this->url()->fromRoute('inmail/user/block',[ 'id' => $user->uuid ], ['force_canonical' => true]),
737
                            'side' => 'left',
-
 
738
                            'message' => $message->message,
-
 
739
                            'type' => $message->type,
-
 
740
                            'filename' => $filename,
-
 
741
                            'date' => $this->timeAgo($now, $now),
633
                            'send_link' => $this->url()->fromRoute('inmail/message/send',[ 'id' => $user->uuid ], ['force_canonical' => true]),
742
                        ]
634
                            'delete_link'=>    $this->url()->fromRoute('inmail/message/delete',[ 'id' => $email['uid'] ], ['force_canonical' => true]),
743
                    ]);
635
                            'attachments' => $attachments,
744
                } else {
636
                        ]
745
                    return new JsonModel([
637
                    ]);
746
                        'success'   => false,
638
                    
747
                        'data'   => $messageMapper->getError()
639
                    
-
 
640
                } else {
-
 
641
                    return new JsonModel([
-
 
642
                        'success' => false,
748
                    ]);
643
                        'data' => 'ERROR_INMAIL_MESSAGE_NOT_FOUND'
749
                }
644
                    ]);
750
            } else {
645
                }
751
 
646
                
752
 
647
                
753
                $messages = [];
648
            } catch (\Exception $e) {
754
                $form_messages = (array) $form->getMessages();
-
 
755
                foreach ($form_messages  as $fieldname => $field_messages) {
649
                
756
                    $messages[$fieldname] = array_values($field_messages);
650
                return new JsonModel([
757
                }
651
                    'success' => false,
758
 
652
                    'data' => 'ERROR_INMAIL_MESSAGE_LIST_UNAVAILABLE'
759
                return new JsonModel([
653
                ]);
760
                    'success'   => false,
654
            }
-
 
655
            
-
 
656
            
761
                    'data'   => $messages
657
            
-
 
658
        } else {
-
 
Línea 659... Línea -...
659
            return new JsonModel([
-
 
660
                'success' => false,
-
 
661
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
762
                ]);
662
            ]);
-
 
663
        }
-
 
664
    }
-
 
665
    
-
 
666
    
763
            }
667
    public function deleteMessageAction()
-
 
668
    {
764
        } else {
669
        $request = $this->getRequest();
-
 
670
        if ($request->isPost()) {
-
 
671
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
672
            $currentUser = $currentUserPlugin->getUser();
-
 
673
            
765
            return new JsonModel([
674
            $id = intval($this->params()->fromRoute('id'), 10);
766
                'success' => false,
675
 
767
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
676
            
768
            ]);
677
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
-
 
678
            $externalCredentials->getUserBy($currentUser->id);
769
        }
679
            
770
    }
680
            $host       = trim($this->config['leaderslinked.inmail.host']);
-
 
681
            $port       = intval($this->config['leaderslinked.inmail.port_imap'], 10);
-
 
682
            $mailbox    = trim($this->config['leaderslinked.inmail.mailbox']);
-
 
683
            
771
 
684
            
-
 
685
            $username   = $externalCredentials->getUsernameInmail();
-
 
686
            $password   =  $externalCredentials->getPasswordInmail();
772
 
687
            
773
 
688
            
774
    private function normalizeString($str = '')
689
            
775
    {
690
            
-
 
691
            try {
-
 
692
                \Eden\Core\Control::i();
-
 
693
                $client = eden('mail')->imap(
-
 
694
                    $host,
776
        $basename  = substr($str, 0, strrpos($str, '.'));
695
                    $username,
-
 
696
                    $password,
-
 
697
                    $port,
-
 
698
                    false);
777
        $basename  = str_replace('.', '-', $basename);
699
                
-
 
700
                $client->setActiveMailbox($mailbox);
-
 
701
                
-
 
702
                
-
 
703
                $storage = Storage::getInstance($this->config);
-
 
704
                $path = $storage->getPathMessage();
778
 
705
                $code = $currentUser->uuid;
-
 
706
                $storage->deleteDirectory($path, $code);
779
        $extension  = substr($str, strrpos($str, '.'));
707
                
780
 
708
                $email = $client->getUniqueEmails($id, true);
-
 
709
         
-
 
710
                
-
 
711
                if($email['uid']) {
-
 
712
                    
-
 
713
         
781
        $str = $basename . $extension;
714
                    if(!empty($email['attachment']) &&  is_array($email['attachment'])) {
-
 
715
                        
782
 
716
                        $filenames = array_keys($email['attachment']);
-
 
717
                        foreach($filenames as $filename)
-
 
718
                        {
-
 
719
                            $remoteFilename = trim($email['uid'] . '-' . $filename);
783
        $str = strip_tags($str);
720
                            $storage->deleteFile($path, $code, $remoteFilename);
784
        $str = preg_replace('/[\r\n\t ]+/', ' ', $str);
721
                           
-
 
722
                        }
785
        $str = preg_replace('/[\"\*\/\:\<\>\?\'\|\,]+/', ' ', $str);
723
                    }
-
 
724
                }
-
 
725
                    
786
        $str = strtolower($str);
726
                
-
 
727
                
787
        $str = html_entity_decode($str, ENT_QUOTES, "utf-8");
728
                
788
        $str = htmlentities($str, ENT_QUOTES, "utf-8");
729
                $response = $client->remove($id, true); 
-
 
730
                $client->disconnect();
-
 
731
              
-
 
732
                if($response) {
789
        $str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
733
                    return new JsonModel([
-
 
734
                        'success' => true,
-
 
735
                        'data' => 'LABEL_INMAIL_MESSAGE_DELETED'
-
 
736
                    ]);
-
 
737
                } else {
-
 
738
                    return new JsonModel([
790
        $str = str_replace(' ', '-', $str);
739
                        'success' => false,
-
 
740
                        'data' =>  'ERROR_INMAIL_MESSAGE_NOT_DELETE'
791
        $str = rawurlencode($str);
741
                    ]);
792
        $str = str_replace('%', '-', $str);
742
                }
-
 
743
                
793
        return trim(strtolower($str));
-
 
794
    }
-
 
795
 
-
 
796
    /**
-
 
797
     *
-
 
798
     * @param string $timestamp
-
 
799
     * @param string $now
-
 
800
     * @return string
-
 
801
     */
-
 
802
    private function timeAgo($timestamp, $now = '')
-
 
803
    {
-
 
804
        
-
 
805
        if ($now) {
-
 
806
            $datetime1 = \DateTime::createFromFormat('Y-m-d H:i:s', $now);
-
 
807
        } else {
-
 
808
            $now = date('Y-m-d H:i:s');
-
 
809
            $datetime1 = date_create($now);
-
 
810
        }
-
 
811
        $datetime2 = date_create($timestamp);
-
 
812
        
-
 
813
        $diff = date_diff($datetime1, $datetime2);
-
 
814
        $timemsg = '';
-
 
815
        if ($diff->y > 0) {
-
 
816
            $timemsg = $diff->y . ' ' .($diff->y > 1 ? $this->translator->translate('LABEL_YEARS_SMALL')  : $this->translator->translate('LABEL_YEAR_SMALL') );
-
 
817
        } else if ($diff->m > 0) {
744
                
818
            $timemsg = $diff->m  . ' ' .($diff->m > 1 ? $this->translator->translate('LABEL_MONTHS_SMALL')  : $this->translator->translate('LABEL_MONTH_SMALL') );
745
            } catch (\Exception $e) {
819
        } else if ($diff->d > 0) {
746
                
820
            $timemsg = $diff->d . ' ' .($diff->d > 1 ? $this->translator->translate('LABEL_DAYS_SMALL')  : $this->translator->translate('LABEL_DAY_SMALL') );
747
                return new JsonModel([
821
        } else if ($diff->h > 0) {
748
                    'success' => false,
822
            $timemsg = $diff->h  . ' ' .($diff->h > 1 ? $this->translator->translate('LABEL_HOURS_SMALL')  : $this->translator->translate('LABEL_HOUR_SMALL') );
749
                    'data' => 'ERROR_INMAIL_MESSAGE_LIST_UNAVAILABLE'
823
        } else if ($diff->i > 0) {
750
                ]);
824
            $timemsg = $diff->i  . ' ' .($diff->i > 1 ? $this->translator->translate('LABEL_MINUTES_SMALL')  : $this->translator->translate('LABEL_MINUTE_SMALL') );
751
            }
825
        } else if ($diff->s > 0) {
752
            
826
            $timemsg = $diff->s  . ' ' . ($diff->s > 1 ? $this->translator->translate('LABEL_SECONDS_SMALL')  : $this->translator->translate('LABEL_SECOND_SMALL') );
Línea 753... Línea -...
753
            
-
 
754
            
-
 
755
        } else {
827
        }
756
            return new JsonModel([
828
        if (!$timemsg) {
757
                'success' => false,
829
            $timemsg = $this->translator->translate('LABEL_NOW') ;
758
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
830
        } else {
759
            ]);
831
            $timemsg = $this->translator->translate('LABEL_AGO_SMALL') . ' '. $timemsg . '';
760
        }
832
        }
761
    }
833
        return $timemsg;
Línea 762... Línea -...
762
    
-
 
-
 
834
        
763
    
835
    }
764
    public function sendMessageAction()
836
 
765
    {
837
 
766
        $request = $this->getRequest();
838
    public function deleteAction()
767
        if ($request->isPost()) {
839
    {
768
            $currentUserPlugin = $this->plugin('currentUserPlugin');
840
        $request = $this->getRequest();
769
            $currentUser = $currentUserPlugin->getUser();
841
        if ($request->isPost()) {
Línea 770... Línea 842...
770
            
842
            $currentUserPlugin = $this->plugin('currentUserPlugin');
771
            $userMapper = UserMapper::getInstance($this->adapter);
843
            $currentUser = $currentUserPlugin->getUser();
772
            
-
 
773
            $id = $this->params()->fromRoute('id');
-
 
774
            if (!$id) {
-
 
775
                return new JsonModel([
-
 
776
                    'success' => false,
-
 
777
                    'data' => 'ERROR_PARAMETERS_ARE_INVALID'
-
 
778
                ]);
-
 
Línea 779... Línea -...
779
            }
-
 
780
            
-
 
781
            
-
 
782
            $user = $userMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
-
 
783
            if (!$user) {
-
 
784
                return new JsonModel([
-
 
785
                    'success' => false,
-
 
786
                    'data' => 'ERROR_REQUEST_IS_INVALID'
844
            
787
                ]);
-
 
788
            }
-
 
Línea 789... Línea -...
789
            
-
 
790
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
-
 
791
            $externalCredentials->getUserBy($currentUser->id);
-
 
792
            
-
 
793
            $host       = trim($this->config['leaderslinked.inmail.host']);
-
 
794
            $port       = intval($this->config['leaderslinked.inmail.port_smtp'], 10);
-
 
795
 
-
 
796
            
-
 
797
            $username   = $externalCredentials->getUsernameInmail();
-
 
798
            $password   =  $externalCredentials->getPasswordInmail();
-
 
799
            
-
 
800
            
-
 
801
            
-
 
802
            $data = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
-
 
803
     
-
 
804
            
-
 
805
            $form = new SendForm();
-
 
806
            $form->setData($data);
-
 
807
            
-
 
808
            if ($form->isValid()) {
-
 
809
                
-
 
810
                $dataPost = (array) $form->getData();
-
 
811
                
-
 
812
                try { 
845
            $id = $this->params()->fromRoute('id');
813
                    
-
 
814
                    $subject = $dataPost['subject'];
-
 
815
                    $message = $dataPost['body'];
846
            if (!$id) {
816
                    
847
                return new JsonModel([
817
                    $encoding = mb_detect_encoding($subject);
848
                    'success' => false,
818
                    if($encoding != 'UTF-8') {
-
 
819
                        $subject = mb_convert_encoding($subject, 'UTF-8', $encoding);
-
 
820
                    }
849
                    'data' => 'ERROR_PARAMETERS_ARE_INVALID'
821
                    
850
                ]);
822
                    $encoding = mb_detect_encoding($message);
851
            }
823
                    if($encoding != 'UTF-8') {
852
            
824
                        $message = mb_convert_encoding($message, 'UTF-8', $encoding);
-
 
825
                    }
-
 
826
                    
-
 
827
                    
-
 
828
                   
-
 
829
                    
-
 
830
                    
-
 
831
                    
-
 
832
                    $phpMailer = new PHPMailer();
-
 
833
                    $phpMailer->isSMTP();
-
 
834
                    
-
 
835
                    $phpMailer->addAddress($user->username_inmail, ($user->first_name . ' ' . $user->last_name));
-
 
836
                   /*
-
 
837
                    if($cc) {
-
 
838
                        foreach($cc as $address => $name) {
-
 
839
                            $phpMailer->addCC($address, $name);
-
 
840
                        }
-
 
841
                    }
-
 
842
                    if($bcc) {
-
 
843
                        foreach($bcc as $address => $name) {
-
 
Línea 844... Línea -...
844
                            $phpMailer->addBCC($address, $name);
-
 
845
                        }
-
 
846
                    }*/
-
 
Línea 847... Línea -...
847
                    
-
 
848
                    $phpMailer->setFrom($currentUser->username_inmail, ($currentUser->first_name . ' ' . $currentUser->last_name));
-
 
849
                    $phpMailer->SMTPDebug    = false;
-
 
850
                    $phpMailer->Host         = $host;
-
 
851
                    $phpMailer->Port         = $port;
853
            $userMapper = UserMapper::getInstance($this->adapter);
852
                    $phpMailer->IsHTML(true);
-
 
853
                    $phpMailer->SMTPAuth    = true;
854
            $user = $userMapper->fetchOneByUuid($id);
854
                    //$phpMailer->SMTPSecure   = 'tls';
855
            if (!$user) {
855
                    $phpMailer->SMTPAutoTLS = false;
856
                return new JsonModel([
856
                    $phpMailer->SMTPSecure = ''; // PHPMailer::ENCRYPTION_SMTPS; 
857
                    'success' => false,
857
                    $phpMailer->Username     = $username;
-
 
858
                    $phpMailer->Password     = $password;
-
 
859
                    $phpMailer->Subject      = $subject;
858
                    'data' => 'ERROR_REQUEST_IS_INVALID'
860
                    $phpMailer->Body         = $message;
859
                ]);
861
                    $phpMailer->AltBody      = $message;
860
            }
862
                    $phpMailer->CharSet      = 'UTF-8';
861
            
863
                    
862
            $conversationMapper = ConversationMapper::getInstance($this->adapter);
864
                    $files  = $this->getRequest()->getFiles()->toArray();
863
            $conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
865
                    if (isset($files['filename']) && empty($files['filename']['error'])) {
864
            
866
                        $phpMailer->addAttachment($files['filename']['tmp_name'], $files['filename']['name'] );
865
            
867
                        
866
            if ($conversation) {
868
                    }
867
                
869
  
-
 
870
                    if($phpMailer->send()) {
-
 
871
                        
-
 
872
                        return new JsonModel([
-
 
873
                            'success'   => true,
-
 
874
                            'data'   => 'LABEL_INMAIL_MESSAGE_SENT'
868
                if ($conversation->sender_id == $currentUser->id && $conversation->receiver_id == $user->id) {
875
                        ]);
-
 
876
                    } else {
-
 
877
                        return new JsonModel([
-
 
Línea -... Línea 869...
-
 
869
                    $conversation->sender_status = Conversation::STATUS_DELETED;
-
 
870
                    if ($conversationMapper->update($conversation)) {
-
 
871
                        $response = [
-
 
872
                            'success' => true,
878
                            'success'   => false,
873
                            'data' => 'LABEL_CONVERSATION_WAS_DELETED'
879
                            'data'   => 'ERROR_INMAIL_MESSAGE_NOT_SENT'
-
 
880
                        ]);
-
 
881
                    }
-
 
882
                    
-
 
883
                    
-
 
884
                    /*
-
 
885
                    
-
 
886
                    \Eden\Core\Control::i();
-
 
887
                    $smtp = eden('mail')->smtp(
-
 
888
                        $host,
-
 
889
                        $username,
-
 
890
                        $password,
-
 
891
                        $port,
-
 
892
                        false
-
 
893
                    );
-
 
894
                   
-
 
895
                    $smtp->setSubject( $dataPost['subject']);
-
 
896
                    $smtp->setBody( $dataPost['body'], true);
874
                        ];
Línea -... Línea 875...
-
 
875
                    } else {
Línea 897... Línea 876...
897
                    $smtp->setBody($dataPost['body']);
876
                        
898
                    $smtp->addTo($user->username_inmail);
-
 
899
    
-
 
900
                    $files  = $this->getRequest()->getFiles()->toArray();
877
                        
901
                    if (isset($files['filename']) && empty($files['filename']['error'])) {
-
 
902
                        $smtp->addAttachment($files['filename']['name'], $files['filename']['tmp_name']);
-
 
903
                        
-
 
904
                    }
-
 
905
                    
-
 
906
                    
-
 
907
                    
878
                        $response = [
908
                    $smtp->send();
879
                            'success' => false,
909
                    
880
                            'data' => $conversationMapper->getError()
910
                    $smtp->disconnect(); */
881
                        ];
-
 
882
                    }
-
 
883
                }
911
                    
884
                
912
                    return new JsonModel([
885
                if ($conversation->receiver_id == $currentUser->id && $conversation->sender_id == $user->id) {
913
                        'success'   => true,
886
                    $conversation->receiver_status = Conversation::STATUS_DELETED;
914
                        'data'   => 'LABEL_INMAIL_MESSAGE_SENT'
887
                    if ($conversationMapper->update($conversation)) {
915
                    ]);
888
                        $response = [
916
                    
889
                            'success' => true,
-
 
890
                            'data' => 'LABEL_CONVERSATION_WAS_DELETED'
-
 
891
                        ];
917
                } catch (\Exception $e) {
892
                    } else {
918
                    return new JsonModel([
-
 
919
                        'success'   => false,
-
 
920
                        'data'   => 'ERROR_INMAIL_MESSAGE_NOT_SENT'
893
                        
921
                    ]);
-