| Línea 38... |
Línea 38... |
| 38 |
/**
|
38 |
/**
|
| 39 |
*
|
39 |
*
|
| 40 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
40 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
| 41 |
*/
|
41 |
*/
|
| 42 |
private $adapter;
|
42 |
private $adapter;
|
| 43 |
|
43 |
|
| 44 |
/**
|
44 |
/**
|
| 45 |
*
|
45 |
*
|
| 46 |
* @var \LeadersLinked\Cache\CacheInterface
|
46 |
* @var \LeadersLinked\Cache\CacheInterface
|
| 47 |
*/
|
47 |
*/
|
| 48 |
private $cache;
|
48 |
private $cache;
|
| 49 |
|
49 |
|
| 50 |
|
50 |
|
| 51 |
/**
|
51 |
/**
|
| 52 |
*
|
52 |
*
|
| 53 |
* @var \Laminas\Log\LoggerInterface
|
53 |
* @var \Laminas\Log\LoggerInterface
|
| 54 |
*/
|
54 |
*/
|
| 55 |
private $logger;
|
55 |
private $logger;
|
| 56 |
|
56 |
|
| 57 |
/**
|
57 |
/**
|
| 58 |
*
|
58 |
*
|
| 59 |
* @var array
|
59 |
* @var array
|
| 60 |
*/
|
60 |
*/
|
| 61 |
private $config;
|
61 |
private $config;
|
| 62 |
|
62 |
|
| 63 |
|
63 |
|
| 64 |
/**
|
64 |
/**
|
| 65 |
*
|
65 |
*
|
| 66 |
* @var \Laminas\Mvc\I18n\Translator
|
66 |
* @var \Laminas\Mvc\I18n\Translator
|
| 67 |
*/
|
67 |
*/
|
| 68 |
private $translator;
|
68 |
private $translator;
|
| 69 |
|
69 |
|
| 70 |
|
70 |
|
| 71 |
/**
|
71 |
/**
|
| 72 |
*
|
72 |
*
|
| 73 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
73 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
| 74 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
74 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
| 75 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
75 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
| Línea 117... |
Línea 117... |
| 117 |
|
117 |
|
| Línea 118... |
Línea 118... |
| 118 |
$id = $this->params()->fromRoute('id');
|
118 |
$id = $this->params()->fromRoute('id');
|
| 119 |
|
119 |
|
| 120 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
- |
|
| 121 |
$currentUser = $currentUserPlugin->getUser();
|
- |
|
| 122 |
|
- |
|
| 123 |
$userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
|
- |
|
| 124 |
$user_blocked_ids = $userBlockedMapper ->fetchAllBlockedReturnIds($currentUser->id);
|
- |
|
| Línea -... |
Línea 120... |
| - |
|
120 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| - |
|
121 |
$currentUser = $currentUserPlugin->getUser();
|
| Línea -... |
Línea 122... |
| - |
|
122 |
|
| - |
|
123 |
$userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
|
| - |
|
124 |
$user_blocked_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
|
| 125 |
|
125 |
|
| 126 |
$user_blocked_me_ids = $userBlockedMapper->fetchAllUserBlockMeReturnIds($currentUser->id);
|
126 |
$user_blocked_me_ids = $userBlockedMapper->fetchAllUserBlockMeReturnIds($currentUser->id);
|
| 127 |
|
127 |
|
| 128 |
|
128 |
|
| 129 |
$userMapper = UserMapper::getInstance($this->adapter);
|
129 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| 130 |
$now = $userMapper->getDatebaseNow();
|
130 |
$now = $userMapper->getDatebaseNow();
|
| - |
|
131 |
|
| - |
|
132 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
| - |
|
133 |
$messageMapper = MessageMapper::getInstance($this->adapter);
|
| - |
|
134 |
$conversations = [];
|
| - |
|
135 |
|
| - |
|
136 |
$selected_user_id = 0;
|
| - |
|
137 |
|
| - |
|
138 |
$id = $this->params()->fromRoute('id');
|
| - |
|
139 |
if ($id) {
|
| - |
|
140 |
|
| - |
|
141 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
| - |
|
142 |
$company = $companyMapper->fetchOneByUuid($id);
|
| - |
|
143 |
if ($company) {
|
| - |
|
144 |
|
| - |
|
145 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
| - |
|
146 |
$companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
|
| - |
|
147 |
|
| - |
|
148 |
if (!in_array($companyUser->user_id, $user_blocked_ids) && !in_array($companyUser->id, $user_blocked_me_ids)) {
|
| - |
|
149 |
$user = $userMapper->fetchOne($companyUser->user_id);
|
| Línea 131... |
Línea -... |
| 131 |
|
- |
|
| Línea -... |
Línea 150... |
| - |
|
150 |
|
| - |
|
151 |
|
| - |
|
152 |
$selected_user_id = $user->id;
|
| - |
|
153 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
| - |
|
154 |
|
| - |
|
155 |
|
| - |
|
156 |
$timeElapsedString = '';
|
| - |
|
157 |
if ($conversation) {
|
| - |
|
158 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| - |
|
159 |
$lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| - |
|
160 |
|
| - |
|
161 |
if ($lastMessage) {
|
| - |
|
162 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
| - |
|
163 |
}
|
| - |
|
164 |
} else {
|
| - |
|
165 |
$unread = 0;
|
| - |
|
166 |
}
|
| - |
|
167 |
|
| - |
|
168 |
|
| - |
|
169 |
array_push($conversations, [
|
| - |
|
170 |
'uuid' => $company->uuid,
|
| - |
|
171 |
'name' => $company->name,
|
| - |
|
172 |
'image' => $this->url()->fromRoute('storage', ['type' => 'company', 'code' => $company->uuid, 'filename' => $company->image], ['force_canonical' => true]),
|
| - |
|
173 |
'profile' => $this->url()->fromRoute('company/view', ['id' => $company->uuid]),
|
| - |
|
174 |
'last_message' => $timeElapsedString,
|
| - |
|
175 |
'count_unread' => $unread,
|
| - |
|
176 |
'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
|
| 132 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
177 |
'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
|
| 133 |
$messageMapper = MessageMapper::getInstance($this->adapter);
|
178 |
'selected' => 1,
|
| - |
|
179 |
'delete_link' => $this->url()->fromRoute('inmail/message/delete', ['id' => $user->uuid]),
|
| - |
|
180 |
]);
|
| - |
|
181 |
}
|
| - |
|
182 |
} else {
|
| Línea 134... |
Línea -... |
| 134 |
$conversations = [];
|
- |
|
| 135 |
|
- |
|
| 136 |
$selected_user_id = 0;
|
- |
|
| 137 |
|
- |
|
| 138 |
$id = $this->params()->fromRoute('id');
|
- |
|
| 139 |
if ($id) {
|
- |
|
| 140 |
|
- |
|
| 141 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
- |
|
| 142 |
$company = $companyMapper->fetchOneByUuid($id);
|
- |
|
| 143 |
if ($company) {
|
- |
|
| 144 |
|
- |
|
| 145 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
183 |
$user = $userMapper->fetchOneByUuid($id);
|
| 146 |
$companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
|
184 |
if ($user) {
|
| 147 |
|
- |
|
| 148 |
if(!in_array($companyUser->user_id, $user_blocked_ids) && !in_array($companyUser->id, $user_blocked_me_ids)) {
|
- |
|
| 149 |
$user = $userMapper->fetchOne($companyUser->user_id);
|
- |
|
| 150 |
|
185 |
|
| 151 |
|
186 |
if (!in_array($user->id, $user_blocked_ids) && !in_array($user->id, $user_blocked_me_ids)) {
|
| 152 |
$selected_user_id = $user->id;
|
187 |
|
| 153 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
- |
|
| 154 |
|
188 |
$timeElapsedString = '';
|
| 155 |
|
189 |
|
| 156 |
$timeElapsedString = '';
|
190 |
$selected_user_id = $user->id;
|
| 157 |
if ($conversation) {
|
191 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
| 158 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
192 |
if ($conversation) {
|
| 159 |
$lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
193 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| 160 |
|
194 |
$lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| 161 |
if ($lastMessage) {
|
195 |
if ($lastMessage) {
|
| 162 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
196 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
| 163 |
}
|
197 |
}
|
| 164 |
} else {
|
198 |
} else {
|
| 165 |
$unread = 0;
|
199 |
$unread = 0;
|
| 166 |
}
|
200 |
}
|
| 167 |
|
201 |
|
| 168 |
|
202 |
|
| 169 |
array_push($conversations, [
|
203 |
array_push($conversations, [
|
| 170 |
'uuid' => $company->uuid,
|
204 |
'uuid' => $user->uuid,
|
| 171 |
'name' => $company->name,
|
205 |
'name' => trim($user->first_name . ' ' . $user->last_name),
|
| 172 |
'image' => $this->url()->fromRoute('storage', ['type' => 'company', 'code' => $company->uuid, 'filename' => $company->image],['force_canonical' => true]),
|
206 |
'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
|
| 173 |
'profile' => $this->url()->fromRoute('company/view', ['id' => $company->uuid]),
|
207 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| 174 |
'last_message' => $timeElapsedString,
|
- |
|
| 175 |
'count_unread' => $unread,
|
- |
|
| 176 |
'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
|
- |
|
| 177 |
'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
|
- |
|
| 178 |
'selected' => 1,
|
- |
|
| 179 |
'delete_link' => $this->url()->fromRoute('inmail/message/delete', ['id' => $user->uuid]),
|
- |
|
| 180 |
]);
|
- |
|
| 181 |
|
- |
|
| 182 |
}
|
- |
|
| 183 |
|
- |
|
| 184 |
|
- |
|
| 185 |
|
- |
|
| 186 |
} else {
|
- |
|
| 187 |
$user = $userMapper->fetchOneByUuid($id);
|
- |
|
| 188 |
if ($user) {
|
- |
|
| 189 |
|
- |
|
| 190 |
if(!in_array($user->id, $user_blocked_ids) && !in_array($user->id, $user_blocked_me_ids)) {
|
- |
|
| 191 |
|
- |
|
| 192 |
$timeElapsedString = '';
|
- |
|
| 193 |
|
- |
|
| 194 |
$selected_user_id = $user->id;
|
- |
|
| 195 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
- |
|
| 196 |
if ($conversation) {
|
- |
|
| 197 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
- |
|
| 198 |
$lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
- |
|
| 199 |
if ($lastMessage) {
|
- |
|
| 200 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
- |
|
| 201 |
}
|
- |
|
| 202 |
} else {
|
- |
|
| 203 |
$unread = 0;
|
- |
|
| 204 |
}
|
- |
|
| 205 |
|
- |
|
| 206 |
|
- |
|
| 207 |
array_push($conversations, [
|
- |
|
| 208 |
'uuid' => $user->uuid,
|
- |
|
| 209 |
'name' => trim($user->first_name . ' ' . $user->last_name),
|
- |
|
| 210 |
'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image],['force_canonical' => true]),
|
- |
|
| 211 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
- |
|
| 212 |
'last_message' => $timeElapsedString,
|
- |
|
| 213 |
'count_unread' => $unread,
|
208 |
'last_message' => $timeElapsedString,
|
| 214 |
'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
|
209 |
'count_unread' => $unread,
|
| 215 |
'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
|
210 |
'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
|
| - |
|
211 |
'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
|
| Línea 216... |
Línea 212... |
| 216 |
'selected' => 1,
|
212 |
'selected' => 1,
|
| 217 |
'delete_link' => $this->url()->fromRoute('inmail/message/delete', ['id' => $user->uuid]),
|
213 |
'delete_link' => $this->url()->fromRoute('inmail/message/delete', ['id' => $user->uuid]),
|
| 218 |
]);
|
214 |
]);
|
| 219 |
}
|
215 |
}
|
| 220 |
}
|
- |
|
| 221 |
}
|
- |
|
| 222 |
}
|
- |
|
| 223 |
|
216 |
}
|
| 224 |
|
- |
|
| 225 |
$records = $conversationMapper->fetchAllByUserId($currentUser->id);
|
217 |
}
|
| 226 |
foreach ($records as $record) {
|
- |
|
| 227 |
if ($selected_user_id) {
|
218 |
}
|
| 228 |
if ($record->sender_id == $currentUser->id && $record->receiver_id == $selected_user_id) {
|
219 |
|
| 229 |
continue;
|
220 |
|
| - |
|
221 |
$records = $conversationMapper->fetchAllByUserId($currentUser->id);
|
| - |
|
222 |
foreach ($records as $record) {
|
| - |
|
223 |
if ($selected_user_id) {
|
| - |
|
224 |
if ($record->sender_id == $currentUser->id && $record->receiver_id == $selected_user_id) {
|
| - |
|
225 |
continue;
|
| 230 |
}
|
226 |
}
|
| 231 |
if ($record->receiver_id == $currentUser->id && $record->sender_id == $selected_user_id) {
|
227 |
if ($record->receiver_id == $currentUser->id && $record->sender_id == $selected_user_id) {
|
| 232 |
continue;
|
228 |
continue;
|
| 233 |
}
|
229 |
}
|
| 234 |
}
|
230 |
}
|
| 235 |
|
- |
|
| 236 |
if ($record->sender_id == $currentUser->id) {
|
231 |
|
| - |
|
232 |
if ($record->sender_id == $currentUser->id) {
|
| Línea 237... |
Línea 233... |
| 237 |
$user = $userMapper->fetchOne($record->receiver_id);
|
233 |
$user = $userMapper->fetchOne($record->receiver_id);
|
| 238 |
}
|
234 |
}
|
| 239 |
if ($record->receiver_id == $currentUser->id) {
|
235 |
if ($record->receiver_id == $currentUser->id) {
|
| 240 |
$user = $userMapper->fetchOne($record->sender_id);
|
236 |
$user = $userMapper->fetchOne($record->sender_id);
|
| 241 |
|
237 |
|
| 242 |
if(in_array($user->id, $user_blocked_ids) || in_array($user->id, $user_blocked_me_ids)) {
|
238 |
if (in_array($user->id, $user_blocked_ids) || in_array($user->id, $user_blocked_me_ids)) {
|
| 243 |
continue;
|
239 |
continue;
|
| 244 |
}
|
- |
|
| 245 |
}
|
- |
|
| 246 |
|
- |
|
| 247 |
$timeElapsedString = '';
|
- |
|
| 248 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($record->id, $currentUser->id);
|
- |
|
| 249 |
$lastMessage = $messageMapper->fetchLastMessagesByConversationIdAndReceiverId($record->id, $currentUser->id);
|
- |
|
| 250 |
|
- |
|
| 251 |
|
- |
|
| 252 |
if ($lastMessage) {
|
- |
|
| 253 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
- |
|
| 254 |
}
|
- |
|
| 255 |
|
- |
|
| 256 |
array_push($conversations, [
|
- |
|
| 257 |
'uuid' => $user->uuid,
|
- |
|
| 258 |
'name' => trim($user->first_name . ' ' . $user->last_name),
|
240 |
}
|
| Línea -... |
Línea 241... |
| - |
|
241 |
}
|
| - |
|
242 |
|
| - |
|
243 |
$timeElapsedString = '';
|
| - |
|
244 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($record->id, $currentUser->id);
|
| - |
|
245 |
$lastMessage = $messageMapper->fetchLastMessagesByConversationIdAndReceiverId($record->id, $currentUser->id);
|
| - |
|
246 |
|
| - |
|
247 |
|
| - |
|
248 |
if ($lastMessage) {
|
| - |
|
249 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
| - |
|
250 |
}
|
| - |
|
251 |
|
| - |
|
252 |
array_push($conversations, [
|
| - |
|
253 |
'uuid' => $user->uuid,
|
| Línea -... |
Línea 254... |
| - |
|
254 |
'name' => trim($user->first_name . ' ' . $user->last_name),
|
| 259 |
'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image],['force_canonical' => true]),
|
255 |
'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
|
| 260 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
256 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| 261 |
'last_message' => $timeElapsedString,
|
257 |
'last_message' => $timeElapsedString,
|
| 262 |
'count_unread' => $unread,
|
258 |
'count_unread' => $unread,
|
| 263 |
'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
|
- |
|
| 264 |
'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
|
- |
|
| 265 |
'selected' => 0,
|
- |
|
| 266 |
'delete_link' => $this->url()->fromRoute('inmail/message/delete', ['id' => $user->uuid]),
|
259 |
'messages_link' => $this->url()->fromRoute('inmail/message', ['id' => $user->uuid]),
|
| 267 |
]);
|
260 |
'send_link' => $this->url()->fromRoute('inmail/message/send', ['id' => $user->uuid]),
|
| 268 |
}
|
261 |
'selected' => 0,
|
| - |
|
262 |
'delete_link' => $this->url()->fromRoute('inmail/message/delete', ['id' => $user->uuid]),
|
| - |
|
263 |
]);
|
| 269 |
|
264 |
}
|
| 270 |
|
265 |
|
| Línea 271... |
Línea -... |
| 271 |
usort($conversations, function ($a, $b) {
|
- |
|
| 272 |
if ($a['selected'] == $b['selected']) {
|
- |
|
| 273 |
if ($a['last_message'] == $b['last_message']) {
|
- |
|
| 274 |
return 0;
|
- |
|
| Línea -... |
Línea 266... |
| - |
|
266 |
|
| - |
|
267 |
usort($conversations, function ($a, $b) {
|
| - |
|
268 |
if ($a['selected'] == $b['selected']) {
|
| - |
|
269 |
if ($a['last_message'] == $b['last_message']) {
|
| 275 |
} else {
|
270 |
return 0;
|
| 276 |
return $a['last_message'] < $b['last_message'] ? -1 : 1;
|
271 |
} else {
|
| 277 |
}
|
272 |
return $a['last_message'] < $b['last_message'] ? -1 : 1;
|
| 278 |
} else {
|
273 |
}
|
| 279 |
return $a['selected'] < $b['selected'] ? -1 : 1;
|
274 |
} else {
|
| Línea 334... |
Línea 329... |
| 334 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
329 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 335 |
$currentUser = $currentUserPlugin->getUser();
|
330 |
$currentUser = $currentUserPlugin->getUser();
|
| Línea 336... |
Línea 331... |
| 336 |
|
331 |
|
| 337 |
$userMapper = UserMapper::getInstance($this->adapter);
|
332 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| 338 |
$now = $userMapper->getDatebaseNow();
|
333 |
$now = $userMapper->getDatebaseNow();
|
| 339 |
|
334 |
|
| Línea 340... |
Línea 335... |
| 340 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
335 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
| Línea 341... |
Línea 336... |
| 341 |
|
336 |
|
| Línea 354... |
Línea 349... |
| 354 |
return new JsonModel([
|
349 |
return new JsonModel([
|
| 355 |
'success' => false,
|
350 |
'success' => false,
|
| 356 |
'data' => 'ERROR_REQUEST_IS_INVALID'
|
351 |
'data' => 'ERROR_REQUEST_IS_INVALID'
|
| 357 |
]);
|
352 |
]);
|
| 358 |
}
|
353 |
}
|
| 359 |
|
354 |
|
| 360 |
$abuseReportMapper = AbuseReportMapper::getInstance($this->adapter);
|
355 |
$abuseReportMapper = AbuseReportMapper::getInstance($this->adapter);
|
| 361 |
$abuse_report_message_ids = $abuseReportMapper->fetchAllDataByUserReportingIdAndTypeReturnIds($currentUser->id, AbuseReport::TYPE_INMAIL_MESSAGE);
|
356 |
$abuse_report_message_ids = $abuseReportMapper->fetchAllDataByUserReportingIdAndTypeReturnIds($currentUser->id, AbuseReport::TYPE_INMAIL_MESSAGE);
|
| 362 |
|
357 |
|
| Línea 363... |
Línea 358... |
| 363 |
|
358 |
|
| 364 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
359 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
| Línea 365... |
Línea 360... |
| 365 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
360 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
| Línea 380... |
Línea 375... |
| 380 |
|
375 |
|
| 381 |
if ($record->sender_id == $currentUser->id) {
|
376 |
if ($record->sender_id == $currentUser->id) {
|
| 382 |
array_push($messages, [
|
377 |
array_push($messages, [
|
| 383 |
'uuid' => $record->uuid,
|
378 |
'uuid' => $record->uuid,
|
| 384 |
'sender_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
379 |
'sender_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
| 385 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $currentUser->uuid],['force_canonical' => true]),
|
380 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $currentUser->uuid], ['force_canonical' => true]),
|
| 386 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
381 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
| 387 |
'receiver_name' => trim($user->first_name . ' ' . $user->last_name),
|
382 |
'receiver_name' => trim($user->first_name . ' ' . $user->last_name),
|
| 388 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
|
383 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid], ['force_canonical' => true]),
|
| 389 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
384 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| 390 |
'side' => 'left',
|
385 |
'side' => 'left',
|
| 391 |
'message' => $record->message,
|
386 |
'message' => $record->message,
|
| 392 |
'type' => $record->type,
|
387 |
'type' => $record->type,
|
| 393 |
'filename' => $record->filename ? $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $record->filename, 'code' => $record->uuid],['force_canonical' => true]) : '',
|
388 |
'filename' => $record->filename ? $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $record->filename, 'code' => $record->uuid], ['force_canonical' => true]) : '',
|
| 394 |
'date' => $timeElapsedString,
|
389 |
'date' => $timeElapsedString,
|
| 395 |
'url_abuse_report' => '',
|
390 |
'url_abuse_report' => '',
|
| 396 |
]);
|
391 |
]);
|
| 397 |
} else {
|
392 |
} else {
|
| 398 |
|
393 |
|
| 399 |
if(in_array($record->id, $abuse_report_message_ids)) {
|
394 |
if (in_array($record->id, $abuse_report_message_ids)) {
|
| 400 |
|
395 |
|
| 401 |
array_push($messages, [
|
396 |
array_push($messages, [
|
| 402 |
'uuid' => $record->uuid,
|
397 |
'uuid' => $record->uuid,
|
| 403 |
'sender_name' => trim($user->first_name . ' ' . $user->last_name),
|
398 |
'sender_name' => trim($user->first_name . ' ' . $user->last_name),
|
| 404 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
|
399 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid], ['force_canonical' => true]),
|
| 405 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
400 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| 406 |
'receiver_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
401 |
'receiver_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
| 407 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $user->uuid],['force_canonical' => true]),
|
402 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $user->uuid], ['force_canonical' => true]),
|
| 408 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
403 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
| 409 |
'side' => 'right',
|
404 |
'side' => 'right',
|
| 410 |
'message' => 'LABEL_ABUSE_CONTENT_REPORTED',
|
405 |
'message' => 'LABEL_ABUSE_CONTENT_REPORTED',
|
| 411 |
'type' => Message::TYPE_TEXT,
|
406 |
'type' => Message::TYPE_TEXT,
|
| 412 |
'filename' => '',
|
407 |
'filename' => '',
|
| 413 |
'date' => $timeElapsedString,
|
408 |
'date' => $timeElapsedString,
|
| 414 |
'url_abuse_report' => '',
|
409 |
'url_abuse_report' => '',
|
| 415 |
]);
|
- |
|
| 416 |
|
410 |
]);
|
| 417 |
} else {
|
411 |
} else {
|
| 418 |
$url_abuse_report = $this->url()->fromRoute('helpers/abuse-report', ['type' => 'message', 'id' => $record->uuid], ['force_canonical' => true]);
|
412 |
$url_abuse_report = $this->url()->fromRoute('helpers/abuse-report', ['type' => 'message', 'id' => $record->uuid], ['force_canonical' => true]);
|
| 419 |
|
413 |
|
| 420 |
array_push($messages, [
|
414 |
array_push($messages, [
|
| 421 |
'uuid' => $record->uuid,
|
415 |
'uuid' => $record->uuid,
|
| 422 |
'sender_name' => trim($user->first_name . ' ' . $user->last_name),
|
416 |
'sender_name' => trim($user->first_name . ' ' . $user->last_name),
|
| 423 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
|
417 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid], ['force_canonical' => true]),
|
| 424 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
418 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| 425 |
'receiver_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
419 |
'receiver_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
| 426 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $user->uuid],['force_canonical' => true]),
|
420 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $user->uuid], ['force_canonical' => true]),
|
| 427 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
421 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
| 428 |
'side' => 'right',
|
422 |
'side' => 'right',
|
| 429 |
'message' => $record->message,
|
423 |
'message' => $record->message,
|
| 430 |
'type' => $record->type,
|
424 |
'type' => $record->type,
|
| 431 |
'filename' => $record->filename ? $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $record->filename, 'code' => $record->uuid],['force_canonical' => true]) : '',
|
425 |
'filename' => $record->filename ? $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $record->filename, 'code' => $record->uuid], ['force_canonical' => true]) : '',
|
| 432 |
'date' => $timeElapsedString,
|
426 |
'date' => $timeElapsedString,
|
| 433 |
'url_abuse_report' => $url_abuse_report,
|
427 |
'url_abuse_report' => $url_abuse_report,
|
| 434 |
]);
|
428 |
]);
|
| Línea 504... |
Línea 498... |
| 504 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
498 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 505 |
$currentUser = $currentUserPlugin->getUser();
|
499 |
$currentUser = $currentUserPlugin->getUser();
|
| Línea 506... |
Línea 500... |
| 506 |
|
500 |
|
| 507 |
$userMapper = UserMapper::getInstance($this->adapter);
|
501 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| 508 |
$now = $userMapper->getDatebaseNow();
|
502 |
$now = $userMapper->getDatebaseNow();
|
| Línea 509... |
Línea 503... |
| 509 |
|
503 |
|
| 510 |
|
504 |
|
| 511 |
$id = $this->params()->fromRoute('id');
|
505 |
$id = $this->params()->fromRoute('id');
|
| 512 |
if (!$id) {
|
506 |
if (!$id) {
|
| Línea 525... |
Línea 519... |
| 525 |
]);
|
519 |
]);
|
| 526 |
}
|
520 |
}
|
| Línea 527... |
Línea 521... |
| 527 |
|
521 |
|
| 528 |
|
522 |
|
| 529 |
$data = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
523 |
$data = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
| 530 |
|
524 |
|
| 531 |
if(!empty($data['file']) && empty($data['file']['error'])) {
|
525 |
if (!empty($data['file']) && empty($data['file']['error'])) {
|
| 532 |
$data['message'] = $data['file']['name'];
|
526 |
$data['message'] = $data['subject'];
|
| 533 |
}
|
527 |
}
|
| 534 |
|
528 |
|
| Línea 535... |
Línea 529... |
| 535 |
$form = new SendForm();
|
529 |
$form = new SendForm();
|
| Línea 536... |
Línea 530... |
| 536 |
$form->setData($data);
|
530 |
$form->setData($data);
|
| 537 |
|
531 |
|
| Línea 538... |
Línea 532... |
| 538 |
if ($form->isValid()) {
|
532 |
if ($form->isValid()) {
|
| 539 |
|
533 |
|
| Línea 540... |
Línea 534... |
| 540 |
$dataPost = (array) $form->getData();
|
534 |
$dataPost = (array) $form->getData();
|
| Línea 713... |
Línea 707... |
| 713 |
}
|
707 |
}
|
| Línea 714... |
Línea 708... |
| 714 |
|
708 |
|
| Línea 715... |
Línea 709... |
| 715 |
$message = $messageMapper->fetchOne($message->id);
|
709 |
$message = $messageMapper->fetchOne($message->id);
|
| 716 |
|
710 |
|
| 717 |
if ($message->filename) {
|
711 |
if ($message->filename) {
|
| 718 |
$filename = $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $message->filename, 'code' => $message->uuid],['force_canonical' => true]);
|
712 |
$filename = $this->url()->fromRoute('storage', ['type' => 'message', 'filename' => $message->filename, 'code' => $message->uuid], ['force_canonical' => true]);
|
| 719 |
} else {
|
713 |
} else {
|
| Línea 720... |
Línea 714... |
| 720 |
$filename = '';
|
714 |
$filename = '';
|
| Línea 728... |
Línea 722... |
| 728 |
|
722 |
|
| 729 |
return new JsonModel([
|
723 |
return new JsonModel([
|
| 730 |
'success' => true,
|
724 |
'success' => true,
|
| 731 |
'data' => [
|
725 |
'data' => [
|
| 732 |
'sender_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
726 |
'sender_name' => trim($currentUser->first_name . ' ' . $currentUser->last_name),
|
| 733 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $currentUser->uuid],['force_canonical' => true]),
|
727 |
'sender_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $currentUser->image, 'code' => $currentUser->uuid], ['force_canonical' => true]),
|
| 734 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
728 |
'sender_profile' => $this->url()->fromRoute('profile/view', ['id' => $currentUser->uuid]),
|
| 735 |
'receiver_name' => trim($user->first_name . ' ' . $user->last_name),
|
729 |
'receiver_name' => trim($user->first_name . ' ' . $user->last_name),
|
| 736 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid],['force_canonical' => true]),
|
730 |
'receiver_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'filename' => $user->image, 'code' => $user->uuid], ['force_canonical' => true]),
|
| 737 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
731 |
'receiver_profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| 738 |
'side' => 'left',
|
732 |
'side' => 'left',
|
| 739 |
'message' => $message->message,
|
733 |
'message' => $message->message,
|
| 740 |
'type' => $message->type,
|
734 |
'type' => $message->type,
|
| Línea 778... |
Línea 772... |
| 778 |
* @param string $now
|
772 |
* @param string $now
|
| 779 |
* @return string
|
773 |
* @return string
|
| 780 |
*/
|
774 |
*/
|
| 781 |
private function timeAgo($timestamp, $now = '')
|
775 |
private function timeAgo($timestamp, $now = '')
|
| 782 |
{
|
776 |
{
|
| 783 |
|
777 |
|
| 784 |
if ($now) {
|
778 |
if ($now) {
|
| 785 |
$datetime1 = \DateTime::createFromFormat('Y-m-d H:i:s', $now);
|
779 |
$datetime1 = \DateTime::createFromFormat('Y-m-d H:i:s', $now);
|
| 786 |
} else {
|
780 |
} else {
|
| 787 |
$now = date('Y-m-d H:i:s');
|
781 |
$now = date('Y-m-d H:i:s');
|
| 788 |
$datetime1 = date_create($now);
|
782 |
$datetime1 = date_create($now);
|
| 789 |
}
|
783 |
}
|
| 790 |
$datetime2 = date_create($timestamp);
|
784 |
$datetime2 = date_create($timestamp);
|
| 791 |
|
785 |
|
| 792 |
$diff = date_diff($datetime1, $datetime2);
|
786 |
$diff = date_diff($datetime1, $datetime2);
|
| 793 |
$timemsg = '';
|
787 |
$timemsg = '';
|
| 794 |
if ($diff->y > 0) {
|
788 |
if ($diff->y > 0) {
|
| 795 |
$timemsg = $diff->y . ' ' .($diff->y > 1 ? $this->translator->translate('LABEL_YEARS_SMALL') : $this->translator->translate('LABEL_YEAR_SMALL') );
|
789 |
$timemsg = $diff->y . ' ' . ($diff->y > 1 ? $this->translator->translate('LABEL_YEARS_SMALL') : $this->translator->translate('LABEL_YEAR_SMALL'));
|
| 796 |
} else if ($diff->m > 0) {
|
790 |
} else if ($diff->m > 0) {
|
| 797 |
$timemsg = $diff->m . ' ' .($diff->m > 1 ? $this->translator->translate('LABEL_MONTHS_SMALL') : $this->translator->translate('LABEL_MONTH_SMALL') );
|
791 |
$timemsg = $diff->m . ' ' . ($diff->m > 1 ? $this->translator->translate('LABEL_MONTHS_SMALL') : $this->translator->translate('LABEL_MONTH_SMALL'));
|
| 798 |
} else if ($diff->d > 0) {
|
792 |
} else if ($diff->d > 0) {
|
| 799 |
$timemsg = $diff->d . ' ' .($diff->d > 1 ? $this->translator->translate('LABEL_DAYS_SMALL') : $this->translator->translate('LABEL_DAY_SMALL') );
|
793 |
$timemsg = $diff->d . ' ' . ($diff->d > 1 ? $this->translator->translate('LABEL_DAYS_SMALL') : $this->translator->translate('LABEL_DAY_SMALL'));
|
| 800 |
} else if ($diff->h > 0) {
|
794 |
} else if ($diff->h > 0) {
|
| 801 |
$timemsg = $diff->h . ' ' .($diff->h > 1 ? $this->translator->translate('LABEL_HOURS_SMALL') : $this->translator->translate('LABEL_HOUR_SMALL') );
|
795 |
$timemsg = $diff->h . ' ' . ($diff->h > 1 ? $this->translator->translate('LABEL_HOURS_SMALL') : $this->translator->translate('LABEL_HOUR_SMALL'));
|
| 802 |
} else if ($diff->i > 0) {
|
796 |
} else if ($diff->i > 0) {
|
| 803 |
$timemsg = $diff->i . ' ' .($diff->i > 1 ? $this->translator->translate('LABEL_MINUTES_SMALL') : $this->translator->translate('LABEL_MINUTE_SMALL') );
|
797 |
$timemsg = $diff->i . ' ' . ($diff->i > 1 ? $this->translator->translate('LABEL_MINUTES_SMALL') : $this->translator->translate('LABEL_MINUTE_SMALL'));
|
| 804 |
} else if ($diff->s > 0) {
|
798 |
} else if ($diff->s > 0) {
|
| 805 |
$timemsg = $diff->s . ' ' . ($diff->s > 1 ? $this->translator->translate('LABEL_SECONDS_SMALL') : $this->translator->translate('LABEL_SECOND_SMALL') );
|
799 |
$timemsg = $diff->s . ' ' . ($diff->s > 1 ? $this->translator->translate('LABEL_SECONDS_SMALL') : $this->translator->translate('LABEL_SECOND_SMALL'));
|
| 806 |
}
|
800 |
}
|
| 807 |
if (!$timemsg) {
|
801 |
if (!$timemsg) {
|
| 808 |
$timemsg = $this->translator->translate('LABEL_NOW') ;
|
802 |
$timemsg = $this->translator->translate('LABEL_NOW');
|
| 809 |
} else {
|
803 |
} else {
|
| 810 |
$timemsg = $this->translator->translate('LABEL_AGO_SMALL') . ' '. $timemsg . '';
|
804 |
$timemsg = $this->translator->translate('LABEL_AGO_SMALL') . ' ' . $timemsg . '';
|
| 811 |
}
|
805 |
}
|
| 812 |
return $timemsg;
|
806 |
return $timemsg;
|
| 813 |
|
- |
|
| 814 |
}
|
807 |
}
|
| Línea 815... |
Línea 808... |
| 815 |
|
808 |
|
| 816 |
|
809 |
|
| 817 |
public function deleteAction()
|
810 |
public function deleteAction()
|
| 818 |
{
|
811 |
{
|
| 819 |
$request = $this->getRequest();
|
812 |
$request = $this->getRequest();
|
| 820 |
if ($request->isPost()) {
|
813 |
if ($request->isPost()) {
|
| 821 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
814 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
| 822 |
$currentUser = $currentUserPlugin->getUser();
|
815 |
$currentUser = $currentUserPlugin->getUser();
|
| 823 |
|
816 |
|
| 824 |
$id = $this->params()->fromRoute('id');
|
817 |
$id = $this->params()->fromRoute('id');
|
| 825 |
if (!$id) {
|
818 |
if (!$id) {
|
| 826 |
return new JsonModel([
|
819 |
return new JsonModel([
|
| 827 |
'success' => false,
|
820 |
'success' => false,
|
| 828 |
'data' => 'ERROR_PARAMETERS_ARE_INVALID'
|
821 |
'data' => 'ERROR_PARAMETERS_ARE_INVALID'
|
| 829 |
]);
|
822 |
]);
|
| 830 |
}
|
823 |
}
|
| 831 |
|
824 |
|
| 832 |
$userMapper = UserMapper::getInstance($this->adapter);
|
825 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| 833 |
$user = $userMapper->fetchOneByUuid($id);
|
826 |
$user = $userMapper->fetchOneByUuid($id);
|
| 834 |
if (!$user) {
|
827 |
if (!$user) {
|
| 835 |
return new JsonModel([
|
828 |
return new JsonModel([
|
| 836 |
'success' => false,
|
829 |
'success' => false,
|
| 837 |
'data' => 'ERROR_REQUEST_IS_INVALID'
|
830 |
'data' => 'ERROR_REQUEST_IS_INVALID'
|
| 838 |
]);
|
831 |
]);
|
| 839 |
}
|
832 |
}
|
| 840 |
|
833 |
|
| 841 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
834 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
| 842 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
835 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
| 843 |
|
836 |
|
| 844 |
|
837 |
|
| 845 |
if ($conversation) {
|
838 |
if ($conversation) {
|
| 846 |
|
839 |
|
| 847 |
if ($conversation->sender_id == $currentUser->id && $conversation->receiver_id == $user->id) {
|
840 |
if ($conversation->sender_id == $currentUser->id && $conversation->receiver_id == $user->id) {
|
| 848 |
$conversation->sender_status = Conversation::STATUS_DELETED;
|
841 |
$conversation->sender_status = Conversation::STATUS_DELETED;
|
| 849 |
if ($conversationMapper->update($conversation)) {
|
842 |
if ($conversationMapper->update($conversation)) {
|
| 850 |
$response = [
|
843 |
$response = [
|
| 851 |
'success' => true,
|
844 |
'success' => true,
|
| 852 |
'data' => 'LABEL_CONVERSATION_WAS_DELETED'
|
845 |
'data' => 'LABEL_CONVERSATION_WAS_DELETED'
|
| 853 |
];
|
846 |
];
|
| 854 |
} else {
|
847 |
} else {
|
| 855 |
|
848 |
|
| 856 |
|
849 |
|
| 857 |
$response = [
|
850 |
$response = [
|
| 858 |
'success' => false,
|
851 |
'success' => false,
|
| 859 |
'data' => $conversationMapper->getError()
|
852 |
'data' => $conversationMapper->getError()
|
| 860 |
];
|
853 |
];
|
| 861 |
}
|
854 |
}
|
| 862 |
}
|
855 |
}
|
| 863 |
|
856 |
|
| 864 |
if ($conversation->receiver_id == $currentUser->id && $conversation->sender_id == $user->id) {
|
857 |
if ($conversation->receiver_id == $currentUser->id && $conversation->sender_id == $user->id) {
|
| 865 |
$conversation->receiver_status = Conversation::STATUS_DELETED;
|
858 |
$conversation->receiver_status = Conversation::STATUS_DELETED;
|
| 866 |
if ($conversationMapper->update($conversation)) {
|
859 |
if ($conversationMapper->update($conversation)) {
|
| 867 |
$response = [
|
860 |
$response = [
|
| 868 |
'success' => true,
|
861 |
'success' => true,
|
| 869 |
'data' => 'LABEL_CONVERSATION_WAS_DELETED'
|
862 |
'data' => 'LABEL_CONVERSATION_WAS_DELETED'
|
| 870 |
];
|
863 |
];
|
| 871 |
} else {
|
864 |
} else {
|
| 872 |
|
865 |
|
| 873 |
|
866 |
|
| 874 |
$response = [
|
867 |
$response = [
|
| 875 |
'success' => false,
|
868 |
'success' => false,
|
| 876 |
'data' => $conversationMapper->getError()
|
869 |
'data' => $conversationMapper->getError()
|
| 877 |
];
|
870 |
];
|
| 878 |
}
|
871 |
}
|
| 879 |
}
|
872 |
}
|
| 880 |
|
- |
|
| 881 |
return new JsonModel($response);
|
873 |
|
| 882 |
|
874 |
return new JsonModel($response);
|
| 883 |
} else {
|
875 |
} else {
|
| 884 |
$response = [
|
876 |
$response = [
|
| 885 |
'success' => false,
|
877 |
'success' => false,
|
| 886 |
'data' => 'ERROR_CONVERSATION_NOT_FOUND'
|
878 |
'data' => 'ERROR_CONVERSATION_NOT_FOUND'
|
| 887 |
];
|
879 |
];
|
| 888 |
}
|
880 |
}
|
| 889 |
|
881 |
|
| 890 |
return new JsonModel($response);
|
882 |
return new JsonModel($response);
|
| 891 |
} else {
|
883 |
} else {
|
| 892 |
$response = [
|
884 |
$response = [
|
| 893 |
'success' => false,
|
885 |
'success' => false,
|
| 894 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
886 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
| 895 |
];
|
887 |
];
|
| 896 |
}
|
888 |
}
|
| 897 |
|
889 |
|
| 898 |
return new JsonModel($response);
|
890 |
return new JsonModel($response);
|